Tim Cameron Ryan
Computer stuff maker from Boston, Massachusetts.
Student at Olin College of Engineering.
See the projects I've been working on.
Or view my resume.
-
Mug, a Java Compiler
CoffeeScript is my favorite new language at the moment. It’s a syntatically light preprocessor to JavaScript, influenced by Python and Ruby, that exposes the niceties of JS’s loose typing and lambdas without gaudy
vars and(function () { ... })s littering your code. Once you start using its comprehensions and loop structures, it feels silly to go back to scripting Java-inspired syntax on the web.Perhaps what I enjoy most about CoffeeScript is that it isn’t an entire language, just a syntax. Because of that, we can rather easily repurpose jashkenas’ work from compiling to JavaScript to any language—in this case, Java.
You can interactively play with a demo of Mug, a CoffeeScript-to-Java Compiler. It can take a subset of CoffeeScript code and compile it to valid (albeit gaudy) Java source. The resulting code, however verbose, is 1:1 with its input, accompanied by some generated class structs and scope objects. Objects in JavaScript become glorified
HashMaps, and type conversions are largeswitchstructures.The results of such a hacky conversion are actually surprisingly fast on HotSpot. For the “Binary Trees” benchmark, the Mug compiled version runs about ~3–4x slower than V8 on my machine, but ~7x faster than Rhino, while still maintaining many of the benefits of a dynamic language (closures, prototypical inheritance, hashes, etc.) The question becomes you value the tradeoff of flexibility and speed.
As a CoffeeScript compiler, Mug is obviously lacking the features of a complete JavaScript implementation. But just as CoffeeScript was meant to improve the experience of programming on the web, Mug could conceivably develop its own semantics and be a light preprocessor for Java. While there are many alternativesto programming the JVM, I expect that a class of “little languages” like CoffeeScript that compile into more familiar languages will start cropping up. Rather than reinvent the programming experience, these simply make the existing programming experience programmers are forced into easier for day-to-day use.
Github
@timcameronryan
LinkedIn
Email me