So I have been working these past months on my own programming language. It has been something that I've always wanted to do so I'm very happy that I can announce it here. Without further ado: Killa. I finished the 0.1 version months ago but real life just got busy on my end and I have been slacking this post for ages.
added some new ones from the top of my head and made it all work using the Lua 5.2 virtual machine, so... Why to bother? could you ask. Why indeed, with so many new and wonderful and exciting languages like Clojure, D, Haskell, Haxe, and trusted powerhorses like Python, Ruby and your favorite one here, creating a new half baked one could be just me following the new craze of "everybody can make his own programming language" (in 21 days).
Then it was Lua. I found Lua due to my work as a game programmer. Lua is kind of mainstream in the game industry for scripting, and it's a good little language, at least that was my first impression: it's pretty solid, it has a permissive license, an active community, it's very small and easy to embed inside your game engine, it doesn't take much memory and it's quite fast... but man: Why on earth have the array indexes to start from 1 instead of 0? and Why global by default variables? and Why the Pascal-like syntaxis? and Why not ternary operator? and Why not this and this and that? There were so many little annoyances that irked me daily. Somebody could think that I created Killa just because of external appearances, I don't think so. For me Lua was broken by the myriad of its little annoyances, but it's core was very useful and it was a waste not to use it.
I also believe that every programming language is by definition broken because none can do every task optimally. Lua was broken for me because I was a programmer working most of the time in a C-like world, having to change languages was a pain. By this definition, Killa is broken too, but it's broken for different people and for different reasons than Lua.
So I suppose that Killa has a place to fill and stay. I'm happy with the current status, but of course it needs lots of work to be stable. For now let me show you how the language looks, the little program below solves the Project Euler 393 problem under 9 seconds on my computer:
Not as fast as Python for this problem, but Python has the advantage of having immutable tuples that can be used as dictionary keys, I suspect that makes the above algorithm run faster in Python, because in Killa I had to use string keys and additional data handling was required. Also this problem needed support of big numbers that I added to Killa as an extension just now. It's just the port of lbc from Lua to Killa, but because the original library is under the GPL license I can not add it by default to Killa. I plan to maintain Killa under a permissive license for the sake of my fellow game developer peers. GPL-like licenses are very cumbersome for game development.
That's it. I need to explain with more detail the features of Killa in a future post, until then: happy coding!
UPDATE: I used bitwise operators to get the time down to 1.12 seconds, faster than Python (1.8 seconds)!
Sunday, September 23, 2012
Sunday, September 16, 2012
Last week I found a nice video about algorithmic combinatorial explosion. It was very interesting but it's a bit sad to see the big sister throwing away her life in order to teach her little students the perils of trying to compute combinatorial problems that grow very fast. The problem they studied didn't seem to be hard, just enumerate all the ways you can go from one corner to the opposite corner in a rectangular grid without passing the same node twice. Deceptively simple, for a 1x1 grid there are only 2 ways, for a 2x2 grid there are 12 ways: