Wednesday, July 11, 2012

Seven Languages in Seven Weeks!

Xtext 2.3 is out and with it are seven cool example languages we’ve built during the last weeks. We built them so you can learn the ideas behind the new API to implement JVM-based languages. The languages are all at github ready to be cloned and tried out including working examples and comprehensive documentation. Let me briefly introduce the examples:

A Scripting Language

What’s a scripting language? Well, basically just a language which lets you start coding without any boilerplate class declaration or main method craziness.

A Logo clone (little tortoise)

And finally a fun Logo-clone which shows how to use the interpreter.

A Build Language

When I saw Gradle the first time my thought was: This can be done in a much nicer way with Xtext. So here’s the proof:

MongoDB Documents

MongoDB is designed for schema less (read untyped languages). That’s perfectly ok and sometimes even useful. But: when you use it from Java things start to become ugly: Java is just a bad fit for generic data structures such as JSON which is why there are endless mapper frameworks and the like to bridge the gap between typed and untyped. The DSL we built is hybrid, in that it’s just a static facade over the still dynamic MongoDB document and it still provides the generic API as well.

Guice Modules

Xtext is powered by Guice and it’s a great framework. This languages lets you describe Guice modules in a declarative way with static analysis and further possibilities to generate ready to use injectors.

Http Routing

This is a little language that lets you dispatch incoming HTTP requests. It’s very similar to the DSL used in Play! but is built to be used together with dependency injection.

Template Language

A template language for HTML, which demonstrates how to add new expressions.