I've been a zone leader with DZone since 2008, and I'm crazy about community. Every day I get to work with the best that JavaScript, HTML5, Android and iOS has to offer, creating apps that truly make at difference, as principal front-end architect at Avego. James is a DZone Zone Leader and has posted 640 posts at DZone. You can read more from them at their website. View Full User Profile

Eclipse Indigo Highlights: Five Good Reasons To Check Out Xtext 2.0

  • submit to reddit

Modelling is a huge part of the Eclipse eco-system, and the Indigo release train brings Xtext 2.0, the new version of the award winning framework for developing domain specific languages. Besides hundreds of bug fixes and significant performance improvements, Xtext 2.0 introduces a refactoring framework and support for rich hover information. A new expression language can be embedded in any DSL and allows users to write computational logic right within their own language. The statically typed template language Xtend eases the development and maintenance of code generators, which are now tightly integrated with Eclipse.

"Xtext 2.0 comes with huge performance improvements and lots of shiny new IDE features such as refactorings and rich hovers for all domain-specific languages (DSL). The most important addition is the statically-typed base language which can be reused within any DSL, which unveils a whole new world of possibilities."

Xbase: A Reusable Expression Language 

Xbase is a partial programming language implemented in Xtext and can be embedded and extended within other languages written in Xtext. Expressions are at the heart of every programming language, but can be difficult to get right. Xbase helps you to allow more complex programming within your DSL, using an expression language that is closely related to Java. 

You can read more about how Xbase works at Sven Efftinge's blog, or just take it for a spin in the new Indigo release.

Xtend: A Code Generation Language

Xtend is a statically-typed programming language which tightly integrates with, and runs on, the Java VM.  It improves on the following concepts:

  • Advanced Type Inference - You rarely need to write down type signatures
  • Full support for Java Generics - Including all conformance and conversion rules
  • Closures - concise syntax for anonymous function literals
  • Injected extension methods - Enhance closed types with new functionality injected via JSR-330
  • Multiple dispatch aka polymorphic method invocation
  • Operator overloading - make your libraries even more expressive
  • Powerful switch expression - type based switching with implicit casts
  • No statements - Everything is an expression
  • Template syntax with intelligent whitespace handling
  • Translates to Java not bytecode - understand what's going on and use your code for platforms such as Android or GWT



Refactoring Framework

All Xtext based languages now get support for rename refactorings for free, simply by adding the RefactorElementNameFragment. See Jan Köhnlein's blog post about this for more details.

Xtext Refactoring from Xtext Team on Vimeo.



Support For Rich Hovers

Rich Hovers are now shown on any reference or declaration.

You'll also get quick fix hovers for Xtext grammars.


Performance Improvements

There are some huge improvements in Xtext 2.0. Check out the difference in build time: 

Not to mention the memory usage improvements: 


Mark Unknown replied on Thu, 2011/06/23 - 7:42am

Since the announcements coming out about the impending release of Indigo I've been looking at XText. It seems to be developing into a beautiful hammer. What I can't seem to figure out is what nails to use it on. Some good, real world (how to use in business apps, not IDEs) examples of "nails" would be great. I have heard them talked about but not actually shown. I am sure they are out there somewhere.

Cloves Almeida replied on Thu, 2011/06/23 - 10:03pm

In general, you write DSLs in order to provide higher-abstraction. Say, for instance, declaring "entities" instead of "class passing as entities", or "workflow" instead of "xml passing as workflow", or "access rules" instead of "java code passing as access rules".

When dealing with business apps with hundreds of these, declaring stuff in a easier-to-read-and-understand way instead of plain Java or XML can help a lot.

Mark Unknown replied on Fri, 2011/06/24 - 7:38am in response to: Cloves Almeida

Hey Cloves, Yeah, I do get the concepts. And definitely how it is better than xml - I've used Drools in xml and the dsl. But I am looking for a concrete example of something real world for the "business domain". Not a Foo-Bar example nor a contrived or partial example. Most of us are not language nor api developers. We are business app developers. For rules and workflow we can just use an existing tool (i.e. Drools and jBPM).

John J. Franey replied on Fri, 2011/06/24 - 3:39pm in response to: Mark Unknown

And there is a business manager out there willing to publish his nontrivial dsl for your edification at the expense of his competitiveness? Maybe you expect more than can be delivered.

Here is Tom Schindl's example just introduced....a java/fx editor using xtext. This is not a business domain editor (unless your business produces java/fx code) but it is not contrived or trivial.

Mark Unknown replied on Sat, 2011/06/25 - 2:09pm in response to: John J. Franey

I am not expecting something to be "delivered". Just trying to get some insight on how it could be used ... other than the way example you gave, which is another IDE tooling type example, although very good and which XText seems to be built for. I'll keep looking though. Not sure what your problem is. I am not asking for a handout. I am not asking some "business manager" (like they would know how to use Java let alone XText) to publish his dsl. I did do some googling and reading BEFORE I posted this.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.