I've been playing around with Lua (my current favourite dynamic language) in two areas of late: Quines (programs who print their own source code when run), and mod_wombat - a Lua module for Apache2.
First off, a quine:
s="s=%qprint(s:format(s))"print(s:format(s))
That one is a port of a classic C quine from Wikipedia over to Lua:
main() { char *s="main() { char *s=%c%s%c; printf(s,34,s,34); }"; printf(s,34,s,34); }
Of course, if you're going for shortest quine possible, then it would have to be this one:
Yes, that is an empty (zero byte) file. The Lua interpreter will happily execute a zero byte source file, and will output nothing while doing so, which matches the source file (again, a duplicate of a C one from 1994; http://www0.us.ioccc.org/1994/smr.hint)
Moving on to mod_wombat, I've set up a virtual private server and installed mod_wombat on it. This allows me to make scripted web pages using Lua instead of PHP - something which pleases me greatly. mod_wombat needs work (and a website, etc.), but it is getting some love from Google's Summer of Code, so perhaps one day Lua will be a common language for web development. I'll be posting a link to a mod_wombat powered blog about mod_wombat sometime soon (hosted on the aforementioned VPS), so stay tuned.
Comments
PHP vs. Lua
Quick question - why do you prefer Lua over PHP (sorry if that's a question deserving a 4 page response)? Is Lua code cleaner? Is Lua common enough to find a programmer for it -
We've been having some problems with PHP (not sure if it's just the developers) and have been looking into using different languages.
mod_wombat
Hi Corsix,
I have the question (I try to use mod_wombat in my dedicated server): Did you have any problems with mod_wombat when run lua script? Is it stable solution - apache + mod_wombat + mysql, have you any improvements for that?
thx,
Hibernaculus
Post new comment