Lua and Corona

image_thumb3

After mocked up my main interface and define my feature list, I evaluated the things I can and cannot do with the current Corona SDK (I can’t get access to the beta SDK as I am using the trial version). My list of CAN’T do includes:

- no support for SQLLite database (this is crucial in my case as I will have a list of places that must be available, even if the user is not connected) – I am addressing this with data in a text file. This is not the way I would like to implement but, considering I will have only hundreds of records, it will work;

- no MapKit integration, meaning I will not be able to render a map in a small part of the screen (when the user taps “see in the map” I will have to render a full HTML file showing the map, over the main screen;

- no native components nor keyboard available in landscape mode. This is hard, specially because I was thinking to address iPad as one of my targeting platform (Apple requires that the iPad interface works both in Portrait or Landscape);

- no email integration (I can’t create the email’s body programmatically);

Ansca has published its roadmap for Corona but, although several topics seems to be in their list, dates are far from final (in most cases they only say Q2/Q3, meaning something may be available from April to September– this is not the best way to get new customers to their platform!)

Knowing my limits, I read all Corona documents, plus the Lua official book and started to code. Some findings at this moment (please feel free to correct me if I missed something):

- You can’t find the same number of Lua samples in the web as you do for languages like Javascript or PHP. It is hard to move on when you are stuck;

- Lua book is not updated (the live code is different than the code printed);

- Corona does not implement the full Lua 5, meaning some functions are not available (after hours trying to work with dofile, for example, I figured out this is not available in Corona);

[Update: Scott's comment below confirms that all Lua 5.1 is implemented in Corona. Thanks for this info. I hope Ansca can create a table with the functions not available due security issues with the iPhone SDK]

- Because Corona does not have integration with SQLLite yet (Lua  can do that), I have to work a lot with arrays, a concept Lua does not have – the closest thing is tables. Problem is, tables are much more difficult/confuse to use than arrays (if you are familiar with arrays). Basic functions like arrayName.count (counts the number of elements in an array) do not exist in Lua tables (yes, in order to count how many elements I have in an array, I had to create a function who reads element by element and return the number found – crazy!).

[Update: Clearly I missed this info. There is a way to count arrays without the function I have used. In fact is is much simpler than I even imagined: to count the number of elements in a table called "places", all you have to do is: #places]

Although I expect a miserable life in the next weeks, developing in a language I do not know, without many examples to search, plus the fact Corona SDK documents could be improved (also it is oriented to games instead of apps), I will keep you posted on my progresses.

[Update: I agree that Corona offers lots of good examples and samples but I still think they could improve their documentation.]

Why am I doing that? Because I really think it is going to be easier to learn Lua/Corona plus developing my features according the limitations, than to learn Object-C. Time will tell if I am right or wrong (and you are going to know from here).

BTW, I have written a few functions I will comment in the next postings.

Alex

One thought on “Lua and Corona

  1. Wow… quite a negative take on Corona. I’d have to dispute a lot of what you’re commenting about.

    First off, there is pretty decent documentation right there available on the website for Corona. The entire API is documented most with examples included. Additionally, there’s a guide for how to use Corona, a build guide, and an installation/setup guide.

    For lua programming, there are tons of example code and tutorials out there… a quick trip to google will find those. How hard is that?

    Ansca provides, at present count, some 20 different sample apps all available for you to download, modifiy, and work through. Not to mention the tutorial which walks you through a lot of the sample apps.

    Why you take issue with arrays vs tables is beyond me. You seriously need to actually get the blue Programming in Lua book (or even the free version that is currently available online) if you don’t know how to get the count of elements in a table. It’s trivial to do and you certainly don’t need a specialized function to count them. Seriously, you need to learn lua, you indicate you’ve read the book but I find that hard to believe. Perhaps you are reading the 5.0 book instead of the 5.1 book (blue PiL)… the bPiL is certainly up to date.

    Yes, there are some parts of the lua spec which are not included for various reasons. You complain about dofile… why not simply require it and encapsulate your “dofile file” in a table or function? Then you can just call the resulting function or execute the table. There are plenty of very easy ways around not having access to dofile and to indicate you spent hours trying to make dofile work? Come on… that’s pretty ridiculous.

    There are some things that are missing, but this is a relatively young tool and the roadmap clearly shows the future will be quite bright.

    If you’re looking to Corona as a “forms” type app solution, you need to do some better research. There are several frameworks out there which would be much better for forms-based Apps.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>