Alex Payne writes online here.

See also the archive, books & talks.

An individual post follows.

C4 Day Two: Gus Mueller on Lua integration

The third session of the day was presented by Gus Mueller of Flying Meat, developer of VoodooPad and other Mac indie favorites. Like Brent Simmons before him, Mueller did his presentation from VoodooPad. Given that his presentation was about integrating a new technology into VoodooPad this had a nice meta effect.

Mueller’s talk was on integrating the Lua scripting language into Cocoa applications. VoodooPad Pro is designed to give users maximum flexibility to organize and manipulate their data, and a programmatic solution is clearly the best fit. Mueller advocated scripting languages for their lack of a compile cycle and the ease of runtime manipulation, and Lua in particular for its speed, easy integration with C/Objective-C, and increasing industry support particularly in the gaming domain.

Lua has a number of interesting characteristics, we learned. It’s written in ANSI C and compiles more or less everywhere. It offers dynamic typing, automatic garbage collection, and thread safety. Its speed comes in part from a simple register-based VM and the use of pointers for string comparison (all strings are unique). The language has no array construct, just “tables” which can be accessed via dot or bracket syntax and which are enumerated from one rather than the conventional zero. Other oddities include the use of ~= for negation rather than != (though functions can be renamed) and the limitation of a single file handle at a time.

Mueller demonstrated simple code for vanilla C integration, and suggested both LuaObjCBridge and his own LuaCore libary for Objective-C integration. We were then treated to a demo of adding a Lua scripting menu to TextEdit, which took a staggeringly small amount of code. With the demo complete and the talk having gone quickly, Mueller sheepishly opened up the floor for questions.

One of the first questions was, of course, “why not AppleScript?” After all, AppleScript is designed expressly for allowing application developers to extend functionality and customization to motivated users via a simple syntax. But Mueller shot back the equally obvious answer to this obvious question: AppleScript is ugly. Other scripting languages were brought up as well, including Python and F-Script. But Python takes too long to load according to Mueller, and can’t be sandboxed to his liking. F-Script was shot down mostly for aesthetic reasons. Audience members rushed in to defend Python but Mueller is sold on Lua’s ease of integration and performance, and understandably so.

A nice talk, if a little short on content that’s not readily available on Google.