Programming in Lua
Published March 23rd, 2006 in General Programming
After I read a bit about how great Lua is as an embedded and configuration language I decided to give it a try. I read through a few online tutorials, and I browsed the Lua docs, but I really can’t read books on the computer. So I bought the “Programming in Lua” book by Roberto Ierusalimschy. I’m just a little ways into the book, but I’m impressed by the Lua language. It’s very simple, compact, easy to use, and best of all it’s great for extending existing apps. In fact, while working on Kiwi I wrote a few pieces of code in Objective-C that are bound to change frequently, so much so that I was considering how I could make it pluggable. For example, before a message is displayed it goes through a little bit of preprocessing with regex’s and such. One of the preprocessors pulls out the >’s from the e-mail and replaces the chunk with a <blockquote>…</blockquote>. By doing this it makes it easy for the style of the output to be configured using a WebView and some CSS. However, some people might not want to strip out the >’s, and maybe they want to do some extra processing before the message is displayed. I think the perfect solution for this is going to be Lua and an Objective-C bridge. Things can be easily configured and changed while maintaining it’s simplicity and speed, for now though, I’m going to start with inserting Lua in a few simple places and I’ll see where it takes me
Awesome. I love lua.
Make sure to check out this objc bridge (which you might know about already- but just in case..):
http://www.pixelballistics.com/Software/LuaObjCBridge/Contents.html
I’m really starting to like Lua as well, it’s like Python but cleaner. It’s so simple and clean; it’s a beautiful language. How difficult has integrating Lua and Cocoa been?
Integrating it is really really easy. I’ve got a wrapper class you can use if you’d like as well, just shoot me an email if you are interested.
The only problem I’ve encountered is trying to represent NSMutableStrings on the lua side… I’m not quite sure how to make it act like a real string, yet still able to compare using lua strings. I’m not sure that’s even possible.
How about F-Script: http://www.fscript.org/ It’s designed to work especially with Obj-C