Issue: 10.2 (January/February 2012)
Author: Marc Zeedar
Article Description: No description available.
Article Length (in bytes): 6,212
Starting Page Number: 12
RBD Number: 10202
Resource File(s): None
Related Web Link(s):
Known Limitations: None
Full text of article...
IN BRIEF Product Codea Manufacturer Two Lives Left Price $7.99 (via App Store) Contact Info http://twolivesleft.com/Codea/ Pros Based on Lua; excellent app interface; helpful editing controls; great support of iPad hardware (accelerometer, multi-touch, graphics, sound, etc.); ideal for learning how to program; can share projects via email; fun. Cons Based on Lua; no syntax suggestions; weak documentation; the program running window is landscape-only; running programs are limited to two-thirds of the iPad screen; programs can only be run within Codea. Rating (1.0-5.0): 3.9
Programming for the iPad has traditionally been difficult because it requires knowledge of special languages and environments, and because it requires a separate Macintosh to compile from. That code-compile cycle slows things down, especially if you'd just like to tinker. But now there's Codea, a new app that lets you write—and run—code directly on your iPad!
Codea is built upon the Lua programming language (http://www.lua.org/). Lua actually looks very similar to Realbasic code in many ways. Unfortunately, this is deceptive, as I found it's different enough that I couldn't just dive in. You do need to learn a little about Lua in order to actually write a program, though it does seem to be an easy-to-learn language. Still, I wish that Codea would offer syntax help and suggestions built-in, especially while you're coding (like the way Real Studio offers hot help to remind you of the parameters of functions).
The app basically has three modes. The home screen (Figure 1) features a row of built-in example projects (which you can modify). Below that are any projects of your own. You cannot permanently modify any of the examples—any changes you make are temporary unless you copy the example into a new project (via a long tap on an example project icon). While this is simple, the rows get wide when there are lots of projects and it requires a lot of scrolling to get to an example at the end of the list.
The next mode is the Code Editor (Figure 2). This has tabbed windows of the various parts of your program and a text editor for coding. One really nice feature is that the on-screen keyboard has been improved with a row of special keys that make it much easier to type certain types of symbols (such as double quotes and parentheses). Codea supports auto-complete, but the completed words show up down by the keyboard, not where you're typing. There's also a key for bringing up built-in help (see Figure 4).
I found the documentation both too basic and not basic enough: there's little about the Lua language itself, only the additional Codea-specific features. Another problem is that you can't have the help window visible while you're coding so you're forced to remember a command's syntax or go back to help again.
At any time while editing, you can tap a right-arrow button to run your program. This takes us to the third Codea mode, which is the window you see while running programs (Figure 3). This window is always landscape—something I found annoying when I was editing code in portrait orientation. If there's a syntax error in your code, Codea will highlight the error in red. Otherwise the program will try to run. When running, the screen is split into three parts: an area where you can adjust the program's parameters (if it has any), an output window (Lua's "print" commands display here), and the main display for the app. All Codea programs have these windows even if they aren't used, which is limiting in terms of screen real estate and looks ugly, as though you're in a debugger.
The programs Codea can create are surprisingly impressive. The examples include several games (Brickout, Snake, Pong) which show off sprite usage, a cloth simulator that adjusts based on the tilt of your iPad, several graphics demos, and more. Codea gives you full access to much of the iPad's hardware, such as the tilt sensor, multi-touch, sound, graphics, etc. There are powerful routines for moving, rotating, resizing, and transforming graphics. There are also built-in libraries of sprite graphics (Figure 5), though I couldn't find a way to import my own graphics.
All this is terrific for kids or those learning how to program. Ultimately, however, Codea is limited to an experimental toy because of the way programs run within its confines. You cannot compile a program for running elsewhere or without the three-pane window mode. You can share a program via email, so someone else with Codea could run your game. (If I was twelve again, Codea would have me in heaven.)
Codea is a terrific, well-done tool for teaching programming, within the confines of its limitations. It's what I wish Real Studio would have written using RBScript as the base; such a product would have been a great introduction to the Realbasic language (and released for free, it would have been great advertising for Real Studio). As it is, based on Lua, and considering the limitations of what you can do with the programs you write, I see Codea as a fun toy but of minimal practical value to the professional programmer.
Figure 1: The Codea home screen, with access to help, sample projects, and your own custom programs.
Figure 2: Editing code in Codea is surprisingly convenient (if you known Lua).
Figure 3: A game running in Codea. Note that the three-pane window setup cannot be changed, even if the parameters and output windows are not used.
Figure 4: Codea's built-in help.
Figure 5: Codea has built-in sprite library.
End of article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.