First released in 1993, Lua (which means "moon" in Portuguese) was designed as an embeddable, interpreted scripting language. It's small, fast, and very elegant, and so flexible that it has found its way into a whole galaxy of commercial applications.
For example, the user interface of Adobe's Photoshop Lightroom is written in Lua (I raved about this app when it was first released in 2006), as is Logitech's Squeezebox music player and Damn Small Linux. According to Wikipedia, DSL uses "Lua to provide desktop-friendly interfaces for command-line utilities without sacrificing lots of disk space." (I reviewed DSL in 2005.)
I must digress for a moment and note that it appears from the Wikipedia article on DSL, as well as a number of blog comments, that Damn Small Linux may be faltering. Wikipedia says: "Due to infighting among the project's originators and main developers, DSL development seems to be at a standstill, and the future of the project is uncertain, much to the dismay of many of the users." Dismay indeed, and given that the DSL site seems dead (activity appears to have more or less stopped in 2008 after the 4.4 release of the OS) it may be DSL RIP, QED.
Anyway, Lua is easy to learn and you can download it in many implementations from the Lua Web site.
The classic first program in Lua is pretty unremarkable:
This prints "hello" (natch). A slightly more interesting Lua program is a factorial calculator:
function fact (n)
if n == 0 then
return n * fact(n-1)
print("enter a number:")
a = io.read("*number") -- read a number
... but only slightly.
That code is from "Programming in Lua by Roberto Ierusalimschy, which was written for Lua 5.0. Now Lua is at version 5.1, that work is a little out of date but still useful as a starting point.
Now, should you be an iPad owner you might like to try Codea for iPad, a programming tool publishing by the curiously named Two Lives Left, that embeds a Lua interpreter into an iOS app designed for the iPad.
This is a really good looking app with elegant graphics and a well-designed user interface.
From the startup screen you can either load an existing project or create a new one. A Codea project consists of a tabbed window with the classes that make up an application on separate tabs and, at execution time, a two column layout with a program parameters panel, a text output panel, and execution controls (back, play, pause, and reset) on the left and the program graphical display pane on the right.
What's really cool in the Codea programming environment is how well it is integrated with the iPad. If you want to change a number, poke it with your finger then either release and edit with the keyboard or hold and drag up or down to increase or decrease the value. To change a color, poke the value with your finger and up pops a color picker. You can also select sprites in much the same way. Full Lua documentation is also built-in.
The demo programs are fairly impressive. There's a simulation of a sheet of cloth that swings fairly naturally when you move the iPad (the Codea system can access data from the accelerometers and detect multiple simultaneous screen touches), some multi-touch demos, a couple of visually quite complex games, and a drum machine.
What's missing? The ability to import or export code either locally or to and from an external resource, access to networking functions, you can't hide the left hand control panels so the application can run full screen, and any kind of code protection so you could actually produce a real app for use in your enterprise. The author, Simeon Nasilowski, tells me he has plans for all sorts of enhancements which may well include all I've asked for, but for now, he's not committing to a schedule.
Simeon tells me that that about 10,000 copies have been sold for the princely sum of $7.99 each since Codea's release Oct. 26, which is pretty impressive. Codea gets a rating of 4 out of 5.
Finally this week, I want to recommend a book called "Acts of the Apostles" by a friend of mine, John F.X. Sundman. This is not a religious text as you might first assume, but rather a science fiction novel in what I think of as the "old school, hard Sci-Fi" style.
I mention this book here in Gearhead because it is exactly what you, my geeky readers, will like. Sundman is very much one of us with a passion for technology and the ability to actually make it not only interesting but also central to a human story.
"Acts" starts with an engineer struggling to debug a timing problem on a custom chip called the "Kali." This scene is promptly followed by a murder and the story rapidly unfolds to include a collection of Silicon Valley characters, Scud missiles, Gulf War Syndrome, a manipulative billionaire genius, nanomachines, neurobiology, genetic programming, and much deviousness, intrigue, and skullduggery. As a writer on Slashdot commented: "It's what Tom Clancy would write if he were smart."
It's been a while since I've read a story that was quite so geekily entertaining. Highly recommended.
Gibbs finds little time to read in Ventura, Calif. Your unfinished book list to email@example.com.
Read more about software in Network World's Software section.