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 (Domain Name Service) 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 [1] I've been playing around with Lua [2].

No, really!

I've been having a blast programming in a prototyped-based [3], dynamic, [4] partially functional [5] scripting language [6] for the past month. I haven't had this much fun with a language since learning 68000 Assembly Language [7].

Yes, I know, I hate such languages [8], but over the past month, I've given it much thought as to why I [DELETED-like-DELETED] 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 [9]) 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 [10]—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 [11].

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 …

[1] /boston/2009/09/15.1

[2] http://www.lua.org/

[3] http://en.wikipedia.org/wiki/Prototype-based_programming

[4] http://en.wikipedia.org/wiki/Dynamic_programming_language

[5] http://en.wikipedia.org/wiki/Functional_programming

[6] http://en.wikipedia.org/wiki/Scripting_language

[7] http://en.wikipedia.org/wiki/Motorola_68000#The_instruction_set

[8] /boston/2008/01/11.1

[9] http://www.mantex.co.uk/samples/spell.htm

[10] http://www.php.net/manual/en/types.comparisons.php

[11] http://luarocks.luaforge.net/rocks/

Gemini Mention this post

Contact the author