Adventures with Corona, Part 2: Where Corona Needs Improvement

In my first look at Ansca’s Corona SDK, I mentioned several features that Corona offers where Adobe AIR is currently lacking. These were compelling enough for me to rewrite my tablet game, Gridshock HD, with Corona for the iPad version. That said, it wasn’t all sunshine, lollipops, and rainbows. Some of Corona’s core APIs and functionality can feel a bit half baked in places. Let me share some of the places that seem, to me, in most need of some love.

Platform API Support

In Corona, there are a number of features that are currently only supported on iOS. Among the most compelling features, I noticed that In-App Purchase and OpenFeint are both marked iOS-only, and there are some others too. In particular, OpenFeint’s leaderboards and achievements are a big reason for why I chose Corona for Gridshock HD on iPad. I know that players demand OpenFeint and/or Game Center, and I simply cannot use either in AIR right now. As great as it is to see OpenFeint available in Corona, I’m not a big fan of runtime-included features that aren’t cross-platform.

On the other hand, the ability to extend Corona with native code would be awesome, just like it would be awesome to have the same thing in AIR. If native extensions existed, the power would be in my hands to choose whether I want to (or am even able to) implement a feature on a specific platform. The development effort for robust extension APIs is, of course, a big task, and I understand that a young platform like Corona might want to include a few high-demand third-party features out of the box before they get around to more daunting things.

Regardless, I’m sure that there are constantly feature requests for Corona to include an API for <insert personal favorite library here>. If native extensions were available, individual developers would be free to add two very valuable types of functionality:

  1. Highly specialized features that few other developers need.

  2. Features that might be coming the future, but there’s an immediate need that cannot wait.

With those out of the way, Ansca can focus on core APIs that work well across all supported platforms and that are useful to the largest majority of their customers—making everyone happier. In addition to native extension support in the runtime, a place to share (or maybe even sell) extensions would be ideal so that folks like me, who never want to touch Objective-C, can look through what others have already built.

Simulator

In the simulator, what you see on your PC may not be what you see on the device. Sometimes, that’s impossible to fix, since some features just can’t work on desktops (Although, I’d like to see more console output that basically says, “you called function X correctly, but it cannot be used in the simulator. Please test on device”). Sometimes, though, the simulator can do things that device builds cannot. In my opinion, that’s much worse. For instance, I saw multi-line text working in the Windows simulator, but discovered that an iOS build only displayed a single line. With simulators, it’s best not to get my hopes up.

The Mac version of the simulator has skins for iPhone and iPad. It makes sense, on one hand, because the Windows version can’t output iOS builds due to Apple’s stupid rules. However, I can’t be the only Corona developer who codes on Windows and builds on Mac. Even if it requires extra notification that I can’t build for iOS, those skins would be super helpful. Alternatively, I would like to be able to add completely custom device skins. In the latter case, all I really care about is specifying a custom screen resolution for the device. If I can get 320×480 or 640×960, then I simply don’t care if the skin looks like an iPhone or not.

Finally, the console output for runtime errors in the simulator always seems to get cut off. On Windows, at least. I can’t remember off-hand if the Corona Terminal on Mac has the same problem. Anyway, I can live without a debugger, but then the stack trace must be as detailed as possible when that’s the case. Half missing information could be the difference in finding an error in seconds versus finding an error four hours later. I’m sure you can guess which I’d prefer.

Language

Lua’s standard library is probably as stark and barebones as you can get. Basically, it provides some math functions, some string functions, and a few functions that turn a table (usually called an object in other languages) into an array by adding and removing from numeric keys. Some of the most basic things I’ve come to expect from a standard library just aren’t there. For instance, how often do you call indexOf() on arrays? I do it all the time, and I was forced to write my own version in Lua. It may not be optimal, and I’d rather use something that a dedicated person or team has vetted better than I could with my time constraints.

On one hand, the small standard library makes sense. The language itself is tiny, and that’s a big advantage. On the other hand, I wonder if the wheel has been reinvented tens of thousands of times by various Lua developers. From what I can tell, there isn’t one true community-supported standard library out there, like I would have expected. Maybe I missed it. Honestly, though, I get the impression that most people throw the Lua interpreter into their C++ games and write super short scripts that don’t need much supporting utility code. Anything complex just goes in the C++ layer.

Corona is different. In Corona, all your code except the super low-level stuff is written with Lua. Corona developers have a more pressing need for a robust standard library that is closer to what’s available from the top-level classes and functions in JavaScript or ActionScript. If Ansca has big dreams for much larger game projects built with Corona, they need to spend some time filling in the gap here so that developers aren’t bogged down in low-level implementation.

Moreover, if Ansca wants to support any kind of open source community, a standard library declared from on high will nip a couple of potential problems in the bud. Since I’ve yet to see any Lua code that uses some sort of namespacing, name collision is pretty much inevitable. Likewise, duplicate functionality will be rampant as everyone includes their own flavor of the missing core library. For anyone that wants to mix and match third-party libraries, that’s going to be a mess of headaches. As Corona-targeted libraries get more complex, the chances of this happening grow exponentially.

Choose the Best Tool for the Job

I enjoyed porting Gridshock HD to Corona. I learned a new language that I hope to develop with again in the future, and I was able to take advantage of features that aren’t available to me in my usual environments. It has given me some inspiration and expectations that I intend to take back with me to Flash. I might be a little more harsh on Adobe’s runtimes when I give feedback now, but any criticism I make will be because I want to see Flash Player and AIR continue to be the best at what I use them for.

Am I now a Corona developer? I’m certainly not leaving Flash behind. However, I’ll be keeping an eye on Corona to see where it ends up. I don’t have current plans for more Corona games, but I may change my mind if certain features are compelling enough, or if I decide that I haven’t played with Lua enough lately. We’ll see. It’s another useful tool to have at my disposal. I’m very glad that I spent some time learning to use it.

About Josh Tynjala

Josh Tynjala is a frontend developer, open source contributor, bowler hat enthusiast, and karaoke addict. You might be familiar with his project, Feathers UI, an open source user interface library for Starling Framework that is included in the Adobe Gaming SDK.

Discussion

  1. Pingback: Adventures with Corona, Part 1: What Corona offers that’s better than Adobe AIR « Josh Talks Flash

  2. John Lindquist

    The scariest thing I ran into was when I worked for a few hours using a lua OOP library (I think it was called “LOOP”) which worked great in the simulator and then when I built to the device, nothing happened. I had to scrap everything and just iterate from scratch.

    (And, like you said, I’m super annoyed that the Windows simulator doesn’t support an iPad skin. They’re been promising it for months and it seems like it’d be the easiest thing in the world, but still nothing.)

  3. carlos icaza

    Thanks for two great blog[s] and feedback about our Corona SDK, we will continue to keep improving Corona so that it meets the demanding needs such as yours.

    @john : thanks for the jab 😉 too.

    carlos
    co-founder ansca

  4. Philippe

    Thanks for the argumented evaluation of Corona – I’m very interested by the cross-mobiles (and standalone unlike AIR) target it offers and I hope they’ll continue improving in this direction.

    But LUA limitations when it comes to “more than a little script” is the reason why I started FlashDevelop after my initial scite:ascs project.

    Even if LUA is a lovely (little) language I think Corona should consider offering a JS binding, kind of like what Impact JS’ developer is experimenting: http://www.phoboslab.org/

  5. Flexwiz

    ” I get the impression that most people throw the Lua interpreter into their C++ games and write super short scripts that don’t need much supporting utility code. Anything complex just goes in the C++ layer. ”

    How very true – I used LUA for years for C++ based games and as an scripting addon its great. However scripts are not real code, and I would not dream of writing an entire project in LUA – its just not designed for that purpose.

    Many have tried, and ended up with terrible spaghetti code since there are hardly any OOP features. Sure, Corona is awesome for small games, but anything with over 200 lines of code belongs with a more suitable language (AS3, ObjectiveC, take your pick).

  6. Josh Tynjala

    Yeah, Lua isn’t very opinionated about OOP, but it has the capabilities. A smart developer could provide a pretty awesome library for OOP (based on meta-tables, or whatever) that would be very beneficial to Corona and other Lua environments. I know there’s a “class” library out there, but I’m thinking something with more capabilities.

    Personally, I had no problem creating class-like units of code in separate Lua files. Honestly, following best practices I learned in AS3, and porting over some libraries like signals, I felt like Lua was just as capable as AS3 for building games, without turning my code into spaghetti. Languages like Lua and JavaScript make it easier to be messy, unfortunately, but they also give freedom that isn’t available in stricter languages, and I really like the balance.

  7. Sam

    Hi Josh, I’ve been reading your posts and they are very entertaining, but the question keeps arising in the back of my head: Why are you going to all this trouble dealing with all these high level abstractions like Corona and AIR when Cocos 2D for the iPhone is pure Objective C with an API built to suit Flash devs? Along with This you have access to all facets of functionality, because it’s native Objective C written in XCode.

  8. Josh Tynjala

    Good question, Sam. Simple answer: I don’t like Objective-C. It wasn’t a difficult language to learn, but I simply wasn’t having fun using it. It’s been ages since I had to manage my own memory, and while my skills are still there from when I worked with C++ years ago, it felt like a giant leap backwards. Combine that with the ugly syntax, and I didn’t even finish a single game. Bottom line, if I don’t enjoy my work as a game developer, that’s the exact opposite of my primary goal from when I decided to take some time off from a real job to try it out.

    Give me a super flexible language like Lua or JavaScript (or ActionScript), with a garbage collector, and I’m on my way to expressing myself and enjoying it. If I can have more fun playing with the language sometimes, then that’s a language I want to use, even if it isn’t quite as fast as native code. I’ll even work around missing features that I would have access to if I chose native instead.

    Thankfully, AIR now has native extensions. I only need to write a little bit of native code (or maybe I’ll be able to find extensions that other developers have already created) and then I can use anything from ActionScript. Hopefully, Corona will let me do the same someday.

  9. Pingback: Where Corona SDK Falls (kinda) Flat | Producerism

  10. T

    Great write-up, and you cover a few things I mentioned in a similar post highlighting some gripes with Corona SDK.

    Also, like you I really enjoy porting apps to Corona, and have a hard time seeing any cons with learning how to use Corona (and by proxy, Lua). AS3 and Lua are infinitely easier to use (and learn) than Obj-C, or any other solutions I’ve come across for targeting both Android and iOS.

    Looking forward to reading your thoughts on the improvements that came with AIR 3 announced yesterday at Adobe MAX. I already found that the performance increase was very substantial.

  11. Pingback: Nurturing and maintaining a relationship with a big corporation while choosing the best paths for your own needs and interests « Josh Talks Flash