Monday, March 07, 2011

Xtend Screencast Part 3 - Rich Strings (i.e. Codegeneration)

Xtend is a programming language with special support for code generation and traversing typed object graphs (like EMF models). It is developed with Xtext 2.0. So the question is what is so special about code generation, that we need special support in a language? Well it's mostly string concatenation, and the most readable way of doing string concatenation is using a template syntax.

Today's screencast covers rich string expressions. It resembles the basic template syntax known from Xpand but in Xtend they are expressions, so you can use them everywhere a normal expression is expected. The new and unique aspect about Rich Strings is their intelligent whitespace handling system, including nice tool support. See it yourself:

You can get your hands on this at EclipseCon in just two weeks and/or at JAX in two months.
The final release of Xtext 2 and the new Xtend language is June 22nd (Eclipse Indigo).


  1. I really love your screencasts!

    I tried it by myself, but run in some problems. I used M5 with Eclipse 3.6.2.

    For example, if I write this method:
    String test(){
    return "hello world"

    It says: Couldn't resolve reference to JvmIdentifiableElement 'return'

    Do I miss something (imports maybe), or should i use a nightly build, to get your screencast running? (Which version is your screencast?)

  2. M5 is a very early state (at that time we had no return expression, for instance).
    Please use the nightly update site or wait for M6 (due next week).
    We are almost language-feature complete and will use the remaining time (till June) to fix bugs as ell as improving the UI, the performance, and the documentation.

  3. Indeed it's very cool.
    Some I don't understand so far.
    Is there no recursion issue while calling the generate method within the body again?

  4. @rischuster : the method is called with a different class object (i.e. the inner class).