"Third-Hand" Languages

J.A. Whye, the creator of Corona Project Manager, posted this tweet last night:

Added MoonScript to Corona Project Manager (mix .lua and .moon files). I need more sample code for testing. Anyone got Moon?

I’ve heard of MoonScript before, and just thought it was just another scripting language out there—but I didn’t see how it fit in with J’s Corona Project Manager product (because you can only use Lua with Corona SDK). I decided to look it up.


As it turns out, MoonScript is a scripting language that looks like a hybrid between Python and Ruby, but compiles into Lua. That means Lua developers can actually program in MoonScript without touching any Lua at all. A “third hand” language, if you will, because scripting languages like Lua are “second-hand” by nature (non-technically speaking, of course).

The cool thing is that since your scripts are compiled, you simply use the resulting Lua scripts as if you wrote them yourself (which you did, but you were able to use MoonScript instead of Lua). So theoretically, anywhere you can use Lua, you can use MoonScript—that’s really cool.

For Python or Ruby developers who are transitioning into a Lua-based development environment (e.g. Corona, Moai, LuaCocoa, etc.), it would actually probably be easier to learn MoonScript instead of Lua, especially if you plan to use classes in your project. As it turns out, I like Lua just fine, so for the time being, MoonScript isn’t of much use to me personally.


Even though I don’t plan to use MoonScript immediately, this whole thing got me interested in these “third hand” languages so I decided to search to see if I could find anymore. It wasn’t long before I came across CoffeeScript—which I’ve seen in Hacker News headlines (quite a bit actually), but it never sparked my interest enough to dig any deeper. Now I’m interested.

Unlike MoonScript, which allows you to avoid a language I actually like (Lua), CoffeeScript gives some order to a language I’ve always particularly disliked: JavaScript. What MoonScript is to Lua, CoffeeScript is to JavaScript.

I remember JavaScript back before very many websites used it, and you couldn’t really use it reliably because JavaScript was turned off in a lot of browsers. Since it wasn’t extremely popular, it was mostly used to popup alerts/windows, ads, etc. As a result of all that, and the fact that it was usually embedded directly into HTML, made it feel very “hacky” to me.

Since then, its usage has matured and it has some very serious applications now, but there are still just so many things I don’t like about the language itself—it still feels very “hacked together” in my mind, and some of the conventions and syntax are just strange to say the least. For example, I hate putting functions in parenthesis just to have local variables—that alone feels like I’m using a hack to sort of “trick” JavaScript into letting me have a local environment here or there.

I always thought if I had to use JavaScript, then I could bite the bullet and use it, and maybe even grow to like it eventually—it’s not that bad. But now after looking at CoffeeScript, with its Ruby/Python-inspired syntax and generally “clean” feel to it—I’d actually be pretty excited to work on a JavaScript project right now.

From what I’ve seen of CoffeeScript so far, the only thing I don’t particularly care for is how it uses “->” in place of the “function” keyword. I don’t like “function” either (too long), but I just think they should have used something different than “->”—but that’s a small matter of personal preference, and definitely not a deal-breaker. I have no other gripes about the syntax—Python-style whitespace is something I’d have to get used to, but I don’t dislike it.

Another plus: CoffeeScript seems to have quite a large following (and growing), so I don’t think it’s going away any time soon—that’s very important to me.

Further Reading

I downloaded a copy of The Little Book on CoffeeScript to read in my spare time, because this little language has really sparked my interest. If you decide to read it, definitely get the downloadable version, because it is more up-to-date.

If you foresee yourself doing any kind of JavaScript development at some point (or if you currently do), I highly recommend looking into CoffeeScript. Like Lua, it is very small, not a lot to it, and makes JavaScript a whole lot more bearable.

Even if you’re well-grounded and comfortable in a specific language (such as Lua, PHP, or Ruby, etc), it’ll benefit you to learn another one. Seeing common concepts across multiple languages portrayed differently helps to solidify your understanding and will make you a better programmer.

As an added bonus, CoffeeScript, like Ruby and Python before it, promotes good coding practices—an area I think JavaScript is particularly weak in.

To read more entries, visit the archives or subscribe to the RSS feed.