Xtext or EMFText… that is the question

I just finished a project building a textual DSL and a code generator for a client and after some intensive investigation, Xtext seemed the best alternative.

Today, I learned that EMFText just released a new version (1.2), and it looks very promising. It seems I'll have to investigate the two tools and make a comparison now. I'm sure both tools are good and that my choice of Xtext will stand, but building languages have become an important part of my business, so I better get on top of all technologies.

At first look, the two approaches look very similar.

Similarities

Both tools seem to provide the exact same result. You can define a textual language; you'll end up with a good eclipse-based editor for your language that provides the essential features we have come to expect for such an editor. That is:

  • Syntax highlighting
  • On the fly parsing with error/warnings
  • Auto-completion
  • Outlining

Both tools use EMF for their abstract syntax. Both tools seem to rely on code-generated ANTLR for the parsing of the concrete syntax. Both tools provide excellent editors for editing syntax files. Both tools seem reasonably well documented.

What then is different?

There are a few things that popped up on first review. I thought I write them up immediately… Maybe the Xtext and EMFText teams can keep me straight as I make the comparison?

Different process

In Xtext you would typically define your abstract and concrete syntax together. Xtext does support an externally defined abstract syntax, but that is not its default process.

EMFText assumes that you already have defined your abstract syntax in EMF. Using the EMF-based abstract syntax, you create the concrete syntax by creating a textual definition in a language defined by EMFText. The concrete syntax is defined in a file and contains a reference to the abstract syntax definition, a section of options (mostly for code-generation, similar to what you normally see in the gen-model of EMF if that helps you), and then the EBNF grammar. Here is the suggested development process for EMFText:

Emftext_process

I don't think one approach is superior to the other. There are times when the abstract syntax is dominant where the EMFText approach seems cleaner. Other times nobody cares about the abstract syntax and the Xtext approach seems more appropriate.

Code generation options

EMFText does not tie in to a code generation framework. This is not an issue for experienced Eclipse programmers familiar with the modeling tools. One may for instance easily integrate it with JET or any of the other M2T or M2M projects (after all, the model is parsed and available in it EMF).

Xtext on the other hand by default integrates with Xpand and Xtend. This means that your project is immediately ready for a code generator.

If your goal is to generate code and you do not have a lot of experience integrating modeling technologies in Eclipse, Xtext will probably allow for an easier learning curve (e.g., a single documentation spanning language definition and code generation). However, there are projects where the only goals I've had were to generate the EMF content.

Again, I would not claim that one approach is superior to the other… They are just different.

Predefined languages

EMFText comes with a few predefined languages that you can download from the Concrete Syntax Zoo. This may potentially be an advantage if you want to extend existing languages or simply want some examples for inspiration.

Documentation and tutorials

There is a lot more documentation for Xtext than for EMFText right now. That doesn't necessarily mean that Xtext is better documented. I'll have to go through an exercise of using EMFText on a real project before I judge, but my first impression is that Xtext has better documentation.

More later

That's all for now. When I've collected all my data and have some time to write it all up, I'll make a comparison matrix 🙂

No Comments Yet.

Leave a comment