CodeCombat Blog

News, features and tips for teachers, computer science advocates, and other heroes in education

New Experimental Languages: Python, Lua, Clojure, and Io

We've just finished judging the CodeCombat Parser Challenge on ChallengePost, wherein our mighty Archmages picked their favorite programming languages to add to CodeCombat. In addition to JavaScript and CoffeeScript, you can now play any CodeCombat level in Python, Lua, Clojure, or Io! (Python isn't totally done, Io has some big bugs, and none of them have any documentation–that'll come as we solidify the new languages.)

The Winners

1st Place - MacBook Air: basicer (Rob Blanckaert) for his Lua parser, Lua 2 JS

I'm a software developer from NYC. I first saw the challenge posted when I was at the TechCrunch hackathon. I had previously been working on some code that use the Mozilla AST format to do model generation for a DBO project. I was having a lot of fun messing with the AST and code generation, so this challenge seemed right up my alley.

The contest had already been running for a while when I found it, but I got caught up quickly. I wrote the bulk of the code in a giant twenty four hour chunk of coding fury and presented it on stage at TechCrunch Disrupt. It got a lot of applause from the programmers in the audience, but didn't seem to impress the more business/product-minded judges. In the morning the parser was running Lua code, but there was still a lot of work ahead catching corner cases and integrating with Aether. I spent he next two weeks trying to get more and more samples of other peoples code running, as well as hanging out with the other awesome contestants in the CC chatroom. It was really awesome how the other contestants helped each other with their integration and really a great experience.

Tied for 2nd Place - iPad Air: vickychijwani (Vicky Chijwani) for his Clojure parser, Closer.js

I'm a software developer at Adobe by day, and work on my own projects by night. I have a huge drive to learn more about all things programming, because creating valuable stuff from thin air makes me feel like -- well, like an archmage. I also wanted to learn Clojure. The CodeCombat challenge was a perfect fit to satisfy my curiosity!

Initially I wasn't serious about participating. The idea was to give myself a reason to learn Clojure. So I went through a lot of tutorials and books, familiarizing myself with the fundamentals and idioms of the language. It started becoming more and more fun as I got my hands dirty with other cool stuff -- compilers, functional programming, TDD, CoffeeScript -- and suddenly I realized, I had a real shot at making this work. After that, the idea that thousands of young programmers would be able to learn Clojure and functional programming by playing on CodeCombat was more than enough to keep me going. One huge advantage of participating was that I quickly got to know tons of extremely useful Clojure functions and data structure subtleties that I otherwise would've known only with a few years of experience with it. Altogether this was hands down the most fun I've had with a side project!

Tied for 2nd Place - iPad Air: differenttmatt (Matt Lott) for his Python parser, Filbert

I'm a SF-based software engineer. I had filed CodeCombat away as a cool project to contribute to, and when I got back to it the parser challenge had just started. I enjoy researching programming languages, so it was a perfect fit.

Writing a parser is a cool academic and practical exercise. I know Python and JavaScript a whole lot better now, and recommend anyone interested in programming give it a try.

Fourth Place - iPad Air: dariusf (Darius Foo) for his Io parser, Iota

I'm a second-year Computer Science student at the National University of Singapore. Since starting school I've had a deep fascination with programming languages, and this challenge felt like a great opportunity to teach myself more about the area.

It was great fun. I've always found writing parsers and compilers to be a mental workout, much like solving a puzzle, and writing this was no different. In the process I learned a lot about Io, the node.js ecosystem, and parsers in general.

That said, the project was not easy: there were moments of self-doubt, and times where I was stumped as to how to move forward. It was, however, immensely gratifying to see the parser take shape, and that made it worthwhile.

Thanks to all everyone who took a crack at the challenge! We'll be hard at work documenting and polishing the new languages. Until they're shiny, you can find them in the editor config menu from the playback settings cog while playing:

... Wait, how do you run Python/Lua/Clojure/Io in the browser?

Aha, that's the trick, isn't it! Our transpiler, Aether, first uses the JavaScript-based parsers that these fine Archmages contributed to create an abstract syntax tree (AST). But instead of producing, say, a Python AST, they produce a JavaScript-compatible AST in the Mozilla SpiderMonkey format. Then Aether takes over, transforming and normalizing and generating code and reparsing and transforming and instrumenting and sandboxing and transmogrifying until the original Python code is not only safe to run as JavaScript in any player's browser (in a Web Worker), but also maintains Python semantics and can access JavaScript versions of Python standard libraries at runtime.

(If that doesn't make any sense, but you're still curious, don't worry: we'll do a longer post on this soon.)

End result?

You can code in Python (or Lua, or Clojure, or Io, or CoffeeScript, or plain JavaScript) on any of our existing levels. Your code is running inside our game engine (which is written in CoffeeScript), in your browser. Whoa.

More languages coming! Tell us what you want to see, or even take a crack at a parser yourself.