Xtend2, Eclipse Indigo Feature #5

Xtend2, Eclipse Indigo Feature #5

The Eclipse Indigo release is now less than 1 week away, which means I’m into the Top 5 Entries in my Eclipse Indigo Top 10 List.  Number 5 on my Top 10 List is near and dear to my heart as I started using some of this technology 5 years ago when it was hosted at openArchitectureWare.  In fact, I spent 5 1/2 years of my life studying Model Driven Development, and I find the entire Model-2-Text and Text-2-Model fascinating.

Number 5 on my Top 10 Indigo Feature List is Xtend 2. Xtend 2 (part of the Xtext project) is a code generation language compiled to performant Java code.  The language supports a number of constructs such as:

  • Both static and injected dynamic extensions
  • Closures
  • Polymorphic method dispatching
  • Smart string processing
  • Type inference
  • and more…

But the best way to demonstrate this is through a real example.  Let’s assume we get tired of writing Top 10 Lists and we simply want to specify the elements and have the blogs write themselves. We could use the smart string processing of Xtend 2 to describe the Model-2-Text transformation

While this particular example would simply output text, we could enhance the transformation to write out HTML, XML, DocBook, LaTeX, etc…  From here, we could use Xtext to describe a Top 10 List Grammar:

Xtext now has a graphical view of the grammar

There are also a new quick fix options available, refactoring support and a content assist improvements.

Once we have our grammar, we can now use the generated language (and generated tool support) to create our top 10 list

Finally we can call the generator to create the textual representation of the post:

Sven Efftinge is the master mind of the whole X family (according to Peter Friese).  Kudos also go out to Sebastian Zarnekow, Jan Köhnlein, Holger Schill, Moritz Eysholdt and Dennis Huebner.

5 Comments
  • Posted at 8:54 pm, June 16, 2011

    Hmmm…think I’ll stick with DocBook.

  • Posted at 8:59 pm, June 16, 2011

    Wow, that’s a lot more powerful than I realized Xtext was…

  • Posted at 6:19 pm, June 17, 2011

    What a cool post with such excellent details!

  • Dread
    Posted at 9:48 pm, June 27, 2011

    >@David. What, you don’t like my documentation publishing system that I developed in 10 minutes 😉 .

    Humm… may be you have forgotten 5 1/2 years to get these 10 minutes ;).