Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 10.2 ('Assumption Approach')
Instant purchase and download via GumRoad!

REVIEW

iApp: Codea

Issue: 10.2 (January/February 2012)
Author: Marc Zeedar
Article Description: No description available.
Article Length (in bytes): 6,934
Starting Page Number: 12
Article Number: 10202
Related Web Link(s):

http://twolivesleft.com/Codea/
http://www.lua.org/

Full text of article...

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.

End of article.