Preface
I needed a break from Flex for mobile, and wanted to see if there were any other good application frameworks that allowed you to deploy to multiple devices beyond Adobe AIR. Tony Lukasavage had written about a few recently, and Matt Guest had written about his quick experience using Corona for games based on the buzz around Robert Nay, the 14 year old who knocked Angry Birds out of the top mobile game slot via Bubble Ball.
While Unity has the best language on the planet, C#, I needed a break from lower level languages. In the past, Ruby and Python were great reprieves for doing smaller projects. In doing some mobile apps, I’ve noticed that for the scope of the project, sometimes 3 weeks or less, the verbose language actually gets in the way. So, I was looking for a higher level language, and Lua in Corona SEEMS to fit the bill, but I’m still learning. I liked how I could save a file in TextMate and and it would just refresh the iPhone/Android emulator. HOTNESS! Uber fast compared to mxmlc and “Building…” in Flash Builder, even when using pure AS3. The interpreted nature of Lua helps speed that up (I guess).
Introduction
I’ve only been reading up on Lua for 1 day, but here’s a quick crash course to get traditional ActionScript programmers up to speed with Lua concepts. If you’ve done any ActionScript 1, or even JavaScript, you’ll find this very familiar to traditional ECMA concepts. If you’re a Java/C guy coming to Flex and now reading this, it may be a little weird.
I’m still learning the OOP & packages Lua stuff, so will post that in a later article. In reading the docs, it’s pretty clear OOP and packages aren’t really something the original language designers figured you’d actually do, so it seems like a ton of work, more than it took in AS1, to get inheritance and packages.
WARNING: This guide was written primarely to help me learn Lua and have all the common comparisons on one page. I’m sure it has errors and misconceptions; if I get railed in the comments, I’ll update this post as soon as possible. Here there be dragons, bitches!
If you’re on a Mac, the best thing to do is go download & install Corona + TextMate, and then install the Corona Bundle for TextMate. For Windows users, you can check out more on their blog.
Output
To show output from your code in ActionScript for the Flash IDE’s console, or Flash Builder’s console, you use trace:
trace("Hello World!");
In Lua, you use print:
print("Hello World!")
You’ll notice there is no semi-colon used in Lua. Like ActionScript they are optional, but most code I’ve seen doesn’t use them. I’ve only met 1 ActionScript coder that didn’t use semi-colons.
There are also no brackets {} in Lua, similar to Python, although the whitespace isn’t as strict[...]
No comments:
Post a Comment