Tuesday, October 13, 2009
Going to the moon
“I hear you banging away at the keyboard,” said Bunny. “Will R like what you're working on?”
“Oh, I'm sure he'd like what I'm working on,” I said, “but whether he would pay me is another matter … ”
That was when I got The Look.
So, if I'm going to be banging away at the keyboard, might as well get a post out …
Over the past month, when I haven't been disinfecting websites and telling the people over at WC that no, their network is fine but we'll reinstall all the DNS servers anyway for Smirk and cramming in the hour here or there converting PHP from an undocumented hugely overwrought PHP framework to a documented and slightly overwrought PHP framework I've been playing around with Lua.
No, really!
I've been having a blast programming in a prototyped-based, dynamic, partially functional scripting language for the past month. I haven't had this much fun with a language since learning 68000 Assembly Language.
Yes, I know, I hate such languages, but over the past month, I've given it much thought as to why I like love Lua and hate the rest of the crowd.
Unlike Perl, which was designed by an insane linguist with a pediliction for punctuation who felt that a language of nothing but exceptions (much like spelling in the English language) would be fun, Lua is a simple language (heck, it's positively tiny—only 21 reserved words) that is very regular, with just a sprinkling of syntactic sugar to make it nice. Oh, and no sigils required on variables.
PHP is designed by rabid wombats—enough said.
Lua feels more like Python or JavaScript, only without the syntactic significance of whitespace and a consistant syntax for defining functions, both regular and anonymous, unlike Python, and has a much smaller code base than JavaScript, probably making it easier to embed.
And unlike Ruby, it's fast. I've found Lua to be faster than any of the other scripting languages I've mentioned so far.
It really comes down to a small, consistent scripting language that is easy to extend with C (or embed into a C/C++ application). And when I say small, I mean small. Twenty-one reserved words, twenty-six operators (like “(”, “)” or “‥”) and only 118 functions in the standard library, unlike the hundreds or thousands you'll find in the other languages.
Some people might not like the “batteries not included” feature of Lua, but since it's intended to be an embedded scripting language, that isn't much of a liability. You get a scripting language that allows you to declare variables, functions (both named and anonymous), closures, coroutines (or threads, if you want to think of them that way) and flow control. And I've been amazed at the extensions available for Lua.
So expect a deluge of Lua-related posts as I finally document what I've been doing for fun for the past month.
Sigh ‥ back to R's project and mucking with PHP …