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.
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.
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.
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.