If something, then this is a belated post. Prolog was the language of July and now it’s September. Anyway, before I completely fail, let’s just wrap it up and go on the next language with this one month hiatus in August.
I really enjoyed the language and one month is indeed barely enough to start doing something useful. So I have to come back to it again and maybe keep reading about it in the meantime. It’s actually quite interesting to try to figure out Prolog code on paper, without actually running something. I think one of the books I was reading had plenty of exercises like this: without running the code, can you guess what is it doing? Needless to say, there were plenty of tricky bits/
From the comments
During two months, some additional resources did show up. A dear commenter on the previous post recommended me the following book: Richard O’Keefe: The Craft of Prolog. I got about a third, maybe halfway through it and it’s interesting, written long time ago in a style that since gone out of fashion, unfortunately. It’s a programming book that is fun to read and one can see that the author is very knowledgeable. Some aspects of the book didn’t age very well, though. The author keeps comparing Prolog to other languages – many of them are not very widely available either. Also, some of the language features are specific to his version of Prolog, that wasn’t the same one I was using. Would recommend, though!
This last part, the different implementations of the same language, can be a real problem. Of the three compilers available for me, all of them had specific strengths and weaknesses. Guess they are converging, but not quite yet. So far I was mostly using SWI Prolog, but this might change in the future.
The said commenter also recommended a cross-compiler, doing Prolog-to-C magic, for portability and other goodness. Can grab it from here: http://ftp.shaw.ca/irvinsh/prolog.tar.gz I haven’t had time to try it yet, but once I have, I’ll do a comparison.
This latter one has a Hungarian author so I’m even more intrigued, we used to have great computer scientists (John von Neumann / Neumann János, anyone?), so I hope we keep up that tradition. (Oh, yeah, and had great physicists as well, maybe I can do more on that front later).
I was only skimmed them a little bit, but looks like these will be good addition for my “programming for fun and efficiency” library.
Will update the original LotM:Prolog page with these links as well. Now onto September’s Language, fortunately I have idea what I want to learn for the next ~3.5 weeks. October will be something Artificial Intelligence related since I signed up for the AI-class.
I really should have started to write this up about two weeks ago, just after StartupWeekend Taipei really happened. Better late than never (if there was ever a good excuse then this is), so taking some time out on this typhoon weekend, here’s my experience of that good 54 hours.
Start
After StartupBus and the Taiwan Enterpreneurship Challenge, I cannot deny that I have a lot of fun at these kinds of events. So I signed up for Startup Weekend Taipei quite a long time ago, especially since I had a free StartupWeekend voucher from Microsoft BizSpark.
I kept recommending the event to more and more people and it seems there were quite a few of my friends who wanted to come but couldn’t because it was all sold out. “Sold out” in this case is 150 participants. That’s probably about the same number of people as on all the Busses, though this time stationary and all in one place. I wasn’t sure what mixture of people will come, just that it will be quite different as Taiwan still seems to have less of a hacker culture.
It turned out that more than 2/3 of the people were Taiwanese and much smaller proportion of foreigners than I expected. This is great – for Taiwan. For me it was a bit of a roadblock.
25 people went up to the stage to pitch their ideas in the hope of getting a team. Of those, only 5 were in English. After the pitching everyone got their three pieces of voting post-it notes and could mark which ideas they liked the most. Based on the votes, only the most popular 12 pitches were kept and only those people could carry on their ideas. Well, since Taiwanese were really not voting for ideas pitched in English, there were in the end 2 ideas that I could join up with… This time it worked out well (oops, is this a spoiler?), but next time probably the organizers should look at this whether the procedure of setting up teams worked or not.
12 teams for 150 people also meant that every team was huge… At the Bus our team had 8 people and I felt it was pretty big. Certainly if I want to start my own company I would probably get going with less then that.
Actually, that large team count is good for getting things done once we agreed on what’s to be done, but it’s pretty bad for reaching such agreement.
Our team had 7 people: 3 coders, 1 designer, 3 marketing/business planning. One (two) sentence pitch: Restaurant search engine for menu items. Tell us what you wanna eat, we show you where are the restaurants serving that in the neighbourhood.
Simple idea, but with our team we had quite a bit of back and forth when discussing the focus of execution. I tend to get very involved once I’m sold on an idea, maybe a little bit too involved. After a bit of discussion I had the role of back-end designer, creating the infrastructure on which all of the user-facing services can be built. I choose that one, because I felt that’s the part of the architecture where I can add the most in terms of making something that other people can rely on and can build on relatively easily. I do feel that without a good back-end no amount a front-end glitter can save things….
Of course in part I chose this role because on the Bus I worked with a great team who taught me a lot about that and wanted to try myself out.
Exercise for the first evening (Friday night): A long, long discussion about a name. Next up is getting some ideas of the feature set then simplify, cut, reduce and then reduce some more. It’s great, I recommend it to everyone. I think I was a bit too combative at that time (sorry, Dobes!), but at least I realized that and tone back quite a bit. Since at 11pm they closed the venue we went home till the morning. I wanted to get something little done by that time so I can show that off for the team. Of course I slept like a log instead.
Next morning (Saturday) I woke up quite early, earlier than usually on a weekday. That’s a very good sign. At the venue they already had some breakfast prepared for everyone. I was too nervous and excited to eat in the beginning. Then when I tried my bagel an hour later, it was amazing! Run back to the table to get another one, but obviously everyone is enjoyed them a lot and were less nervous. All of them were grabbed up.
After some more discussion we got working on an actual thing. The technology used:
Bottle, a Python micro-framework, it’s a single file. I like it a lot, have to check it out more later, especially because there are a swarm of Python micro-frameworks so good to know the strength and weaknesses of each.
MongoDB, through MongoLab, wanted to use for our database and geolocation “nearest place” lookup, but run into some weird Unicode bugs that I couldn’t solve in about an hour. Scratch that, will check it when there’s time
Google AppEngine, hosting and database. Perfect for this kind of thing. Had some problem with data export and import (“list” datatypes are not imported back correctly) so I wrote some custom remote imports and all fine at this level. Oh, and Geomodel, that’s useful.
lots and lots of Javascript (jQuery, Mustache, something for the instant search,…) for the front-end. That wasn’t me, so not exactly sure what else was going on there. I was checking with the front-end people only as much as it affected the schema of the API response.
Most of the day was spent on setting up an API, working out data lookup with the chosen database and structure, making a data input interface, some helper pages, and fixing a lot of bugs. Saturday evening we had basically everything down conceptually that we needed to have working. Going home at night again was a bit of bug fixing (let’s call it The Time of Duh).
Home stretch
Sunday morning getting up pretty early again, I love this kind of inspired work when I just cannot stop myself. All the way to the venue I was thinking how to use this experience to improve my day job (though it is pretty inspired already, so I guess I’m lucky).
Most of the day was spent by fixing more and more bugs, getting the front-end right (not me, fortunately, I have no real sense of design), getting some real data, real restaurants and menus into the database, figuring out and polishing the pitch, working on the feedback from the surveys our marketing people were doing since Friday evening, do some Facebook page based hyping….. This sort of StartupWeekend stuff.
I was hoping that we could get an Android app in the end as well, but the person who was working on that I felt over-complicated the thing. Yeah, because I don’t know how much the others must have thought that I’m over-complicating my job… Anyway, I haven’t been writing Android code since the Bus, but actually in about 2.5 hours there it was, an map interface showing real data from our real database. Slap on a search bar and you are golden. There wasn’t any time for finishing that up, but still I was satisfied – it was possible because of a good back-end. (okay, enough of this patting myself on the back, dude)
Then it was finally time to pitch. The panel of judges was impressive. Real investors and business people from Taiwan, US and China, about a dozen of them, maybe more. All very experienced people.
Our presentation was quite good, because the team really prepared for the questions, really answered the concerns an investor would have and covered all our bases. Many of the other presentations were more emphasizing “fun”, had “pie in the sky” models, or had something that some of the judges already gave them feedback in the development phase and they didn’t fix it. It’s probably mostly down to experience. I haven’t pitched before, so I guess I’m not the most reliable source of useful information about this.
Anyway, the punchline: we got first prize.
Of course it feels pretty good. Some non-monetary things (mostly services by the sponsors), but there was a last minute donation of NT$60.000 (about US$2000) from the judges. That comes handy, my share will run that server I’m renting and pay for some domain names for future projects….
Postscript
The event has been covered on TechOrange and Penn-Olson So two people from the team will actually continue Foodjing. They are based in a different city, and there are some other, administrative issues why I wouldn’t be able to take part in that, but it’s all fine. When they get it done, I’m sure I’ll be an user. And I have plenty of lessons to take home:
I really can get excited about a lot of different ideas. Most ideas do have a useful core that can be developed, so on an event like this, the idea that one chooses almost makes no difference. Choose the team instead of the pitch.
One weekend is perfectly fine to get something done. In the end we had a working (albeit ugly) prototype. If it was done now, can be done any time. Got to use my weekends better.
Talk more to people who can and willing to help. Had a lot of mentors who had great feedback on everything.
This is not a hackathon. I took it as it was one, and my goal was getting something working. Talking to some of the organizers it took me by surprise that this is really business and by real I mean real. That these things we are making are as real as it gets. I was just thinking in terms of fun, have to take things more seriously, but without losing the ability of having a good time.
This time we succeeded. This cannot make me risk-averse that I don’t try anything unless I’m sure to win, cannot go to the next StartupWeekend with the mindset that I have to win again.
There will always be more ideas. For every one of them that fails, or succeeds but goes on without me, there will be 10 more that can be taken up. So where’s my next 10?
All in all, it was a great time and looking forward to the next event like this.
It is again a very different choice, logic programming. Been playing with it for the last two weeks or so, and it really makes me think differently about programming and programs. Logic and complex thinking was always a favorite past-time of me (e.g. solving puzzles and such), but only now I realized that I do have a lot to practice in this area.
Prolog is also one of the older languages (feels like a “classmate” of Lisp and Fortran) so it was the first language in the series where I could actually go to a library, take out some books to learn it, and that book wasn’t hopelessly out of date (try to do the same thing with Python or Ruby…). Since these books were also written by academics and not necessarily computer scientists, their whole approach is different, in a way more curious, though probably less practical.
In the end, I think what I would like to gain is a tool that I can use to attack problems that are intractable or at least very difficult in other languages.
Start
One of the first thing I found hard to figure out was how to actually run a program. So in a nutshell: even if most of the interaction is within an interpreter-like environment, all the basics have to be prepared in a file and loaded.
E.g. I prepare a file like this (based on Ender’s Game), call it ender.pl:
Then starting Prolog I can load the file with the [‘ender.pl’]. form, and ask questions like who is Ender’s sister? Who are Theresa’s kids? Who are Peter’s siblings?
I’m a few days behind schedule since Lua was June’s language, but here it comes, some summary of my experience, after setting things up in the first part.
Overview
I really liked this language, and I’m sure I’ll keep learning it. Very useful and lots of interesting concepts. I haven’t seen an embedded language before, and some parts
Most of what I picked up was from Beginning Lua Programming and Programming in Lua. Lua Missions was another very useful experience: a “fill in the blank” type of source code collection, which drilled my understanding of the Lua concepts. Some sections felt a little short, so maybe later I’ll think whether there are any more questions I can come up with. Very well worth the time!
There are two things that stand out: tables and local environments.
Tables
If I have to refer to my knowledge of Python, then Lua tables are like Python lists and dicts rolled into one and then some. Here’s one such table:
x = {1, 2, 3, y = "something", ["or else"]="what"}
The first three elements are giving an array (and one can loop over them), then the last two are key-value pairs. One tricky thing is that the “y” there is actually a string (the same as [“y”]), just made it more readable with syntactic sugar. Since variables (references to variables) can be keys as well, this can get confusing if one has a variable called “y”… There are quite a few things about tables that are confusing, but actually pretty consistent so my fuses are not blowing that much as they were in the beginning (for example: how the length is looked up, how to iterate through the different values) .
They are very complex animals so some things are quite complex to do, which in turn enables quite complex things to be done. Pretty much any kind of data structure can be built upon them. So all in all, I’m enjoying them with all their quirks. Also, “weak tables” are an interesting concept (where certain table entries can garbage collected).
Scopes
In Python, the name spaces and environments seem to be on the sidelines (at least what I’ve seen so far): people need it and have to us it, but nothing more than that. In Lua this is taken to a whole new level: scopes can be essential parts of the way algorithms are implemented and neat tricks can be played.
I tried to come up with some good example and failed, here’s a “duh” one:
function newCounter ()
local i = 0
return function () -- anonymous function
i = i + 1
return i
end
end
c1 = newCounter()
print(c1()) -- 1
print(c1()) -- 2
This is a bit like Python’s “yield” type of generator, without anything special.
Also, in Python there are only two kinds of variables (I think): local and global: either just for you or for everyone. Here they have one more: upvalues, where the variable is local to a parent, so children environment can access them but the parent’s parents cannot. They are strange beasts as well, e.g. the code itself cannot really know if a variable is upvalue or global, only that it can access that.
And of course these scopes help embedding to not just be possible but straightforward and powerful. Local environments can be restricted, some things selectively enabled, and all this transparently, so the script running might not even know that it’s being in the Matrix.
The Lua Experience
Good
Fast, both start up and running
Language itself is quite small, possible to wrap one’s head around quite easily
Written in ANSI C, so basically on every architecture where one can run C, one can have Lua as well
Tables are great and once one mastered them, are really Swiss Army Knives
Built in interpreter (though could use a little love like iPython)
The “…” syntax for variable number of arguments
Astrological naming convention – modules are rocks, the exercises I linked previously are missions, web framework is Kepler…
Bad
There seem to be a lot of reserved names (e.g. in metatables) that would be pretty much impossible to figure out with a book (and/or an iPython-like helpful environment), though this is a problem probably only when starting out with Lua
Ugly
While some complex things can be solved, some simple things can require complex coding (e.g. in case of the tables when using “__index” and “__newindex“) and there are things that are not even possible. Or I just misunderstood some sections of the book.
Using a lot of syntactic sugar (especially in the object oriented section), that I feel need some more practice to pick up, as things can be done in multiple ways
The tables’ syntactic sugar covered way of handling string keys, convenient when things go well, mighty confusing at even the slightest problem
Too few projects using Lua, too few sources of information (this is not the language’s fault, though)
Project
Originally I wanted to do some useful programming in every language I learn during the Language of the Month series. I failed with Scala (lazy), and now failed with Lua too (underestimating the difficulty). I’m using VLC a lot and it has Lua scripting enabled, so I wanted to do a plugin that can be useful for me later as well. This didn’t work out very well, mainly because it feels the VLC Lua interface is not very well documented, one mostly have to find some examples that exist already and use them. I ended up wasting a lot of time and still don’t quite understand how to do certain things I would like for my code, and don’t even know if it’s possible to do or not. Will come back to it later, until that here are a few links that helped me to get started:
VLC Lua FAQ – detailed list of available API functions, but almost no context and examples
Example: Streaming Radio Player Extension – someone who have gone further down this road than me and has a working extension. Very educational, especially to see how concise and straightforward it can be, because the VLC Lua API seems to be thought out well.
Since my first (crazy) swing at anything business I consider myself “infected”. It seems like that is only a matter of time I start my own venture, for better or worse. It is just too much fun and to difficult to stay out of it.
Challenge
In line with that attitude, now I notice all kinds of related events, and fortunately some of them are in the neighbourhood. So, last Sunday found me at an entrepreneurship challenge – a business plan competition. It was organized by a local startup, Enspyre. It’s founder is a serial entrepreneur who started at the age of 15. The company itself also runs an internship program to find interesting/creative people, and I have no doubt that the event was aimed inspiring young people to start something new – which in turn would boost their own business. I say, double-clever!
The audience was quite mixed, of the 25-30 participants more than half was Taiwanese, mostly students in their sophomore and senior years. The rest of it were strange foreigners (your’s truly is no exception), from Indian software engineer to Filipino Business majors and American expats. The day was supposed to be learning by doing. First, some current entrepreneurs and VCs present their take on what is a business idea and how a business plan and a pitch comes out of it. Then, in the space of a couple of hours, people would form more-or-less random groups, come up with ideas, refine them, do some numbers of how much capital the idea would need, prepare a pitch, deliver it – and see how it flies with the real VC judges. Most of the people did each and every step of this process for the very first time. Sounds intense? It was and also incredibly stimulating.
Experience
In the initial “name card exchange” phase I was really slow – or at least slower then the rest of the people. I did want to know a little bit about my potential team mates, so ended up talking more to them than the other (I guess 5 sentences instead of 1). This made me in the end one of the last person to choose a team. That’s not a problem, I like random, usually works out brilliantly.
Out of the 5 members, our team had 4 Taiwanese students (2 business, 1 psychology, 1 medical science) and me. The language posed a little bit of difficulty, but I’d say we worked around it pretty well (I came a long way in terms of patience since I started learning Chinese as well). It was pretty amazing to work with them, especially because we all didn’t know each other, and that I could resist pushing my own things.
Some lessons learned:
The original business ideas were pretty bad. Many of the better ones were maybe a bit too conventional. On the other hand, when we revisited them, each and every was brainstormed into something I could feel excited about and would be totally happy to start working on. It was absolutely awesome to hear and discuss their ideas, to live through the process. Later talking to some other groups, their ideas just grew but none of them changed substantially upon review. Sign that we had a naturally agile team?
The language barrier is pretty big at the moment. Once one gets beyond that, by either having more patience, communicating even a tiny bit in their native language, or letting them discuss things between themselves for a whole, creativity really shines. There’s a lot of potential in this country. (Not that I didn’t know that earlier:)
Feedback from VCs, even – and maybe especially – before pitching is invaluable. That is, if I can say my question clearly and concisely enough. And that gave me a duh moment: of course they want everyone to succeed. If your idea/pitch is boring, they are going to waste the time. If there are few creative people then they will have fewer investment opportunities. So it is their very on selfish interest to do everything for you to succeed. Don’t abuse it (i.e. make it more trouble for them to help then the potential reward) and you have the best teachers.
It’s good to take the back seat sometimes. I didn’t push that our group would develop one idea originating from me, but one that more people in the team liked. I had advantage in the language front so pitching wouldn’t have thought me much, I insisted that the girl (Ping) who came up with our original idea would do the pitch – regardless of her English. She protested first but in the end I’m sure she liked it. This way she had some awesome experience and I could also see (ie. introspect) how do I listen e.g. to a pitch – even our own. I’m sad to say, that I’m a terrible listener. Got to fix that, and glad I had a chance to realize it.
As we were told multiple times during the day, the team is more important than the idea. After working together for a few hours I can certainly see how that comes into play very-very quickly. The business ideas I had these days lack any kind of consideration who would I do them together with – really should think about who else is in my social circle who I should consider because no matter how idealistic I am, I won’t make it completely on my own.
Guess these are just part of what I have realized, the rest of it will probably pop up every now and again in the coming weeks and months.
And now for the punchline: out of the 6 teams we took home the first prize. We came up with an idea that could impress other people who are doing this for a long time (and one of whom were telling us how the salesgirls pamper you much better when buying an Armani suit than at any other boutique – a lifestyle clearly out of my league). Their feedback was that out of the 6 pitches, ours was the one that could be done realistically, on a sane budget, with sane assumptions and might just work! It is an interesting feeling. I want to keep this and continue growing on it. Already started: my part of the bounty for winning went for recovering the entrance fee and “investing” in more resources for my journey (“Technology Ventures”).