Xtext at DemoCamp London in June 2009

This Monday the Eclipse DemoCamp took place in London at Skills Matter. You will find a comprehensive review at InfoQ by Alex Blewitt where you can read about NatTable (Dan Pollitt) and JQantLib/OSGi (Richard Gomes) as well as Xtext. And thanks to Eren Aykin you will find a video podcast of the latter, too!

This time I tried to spread the idea of DSLs with chess and different ways of expressing moves within the game. In the first part of my presentation I processed cryptic notations like “Rd2-c2″ or more natural equivalents such as “rook at d2 moves to c2″ to work with them as true Java objects and eventually visualized chess fields. Second, I tried to emphasize the value of DSLs in today’s software projects where we implemented another DSL live at the DemoCamp in the end. You will find my slides at SlideShare again.

It was quite informative to chat with the Eclipse folks in London afterwards. Most of them have a pragmatic view at modeling and tools in general. I really appreciate this! Thank you, Neil, for organizing this event and inviting via twitter.

Links

Source Code

Loading chess DSL text files as Java objects:

package org.xtext.example.chess;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.xtext.example.ChessStandaloneSetup;

public class JavaTest {

	public static void main(String[] args) {
		String filename = "some/path/MyModel.chess";
		Game g = getGame(filename);
		System.out.println(g.getWhitePlayer() + " vs. " + g.getBlackPlayer());
		for (Move m : g.getMoves())
			System.out.println(m.getSource() + " to " + m.getDest());
	}

	private static Game getGame(String filename) {
		ChessStandaloneSetup.doSetup();
		ResourceSet rs = new XtextResourceSet();
		Resource res = rs.getResource(URI.createFileURI(filename), true);
		return (Game) res.getContents().get(0);
	}

}

6 Responses to “Xtext at DemoCamp London in June 2009”

  1. Alex Blewitt Says:

    Thanks for the presentation! The use case (chess moves) was great, and actually, for the first time some of the text modelling made sense. Most other use cases (employees/locations/addresses etc.) really suggest leaning towards a database rather than a text-oriented format anyway, but the chess moves worked really well. I especially liked the generation of the chess boards afterwards; you should make that demo available on the Xtext site.

  2. Karsten Thoms Says:

    Cool that your presentation is also available as video. I also like the Chess example. Rd2-c2 without a given context first is a brilliant example to motivate textual DSLs! And as always you are a great presenter.

  3. Heiko Behrens Says:

    Thank you for your feedback, guys. I am planning to publish the chess example with a more sophisticated editor in the future, Alex.

  4. Heiko Behrens (Blog) » Blog Archive » Announcing the Xtext Webinar on Wednesday, 15th June Says:

    [...] and frameworks and demonstrate its capabilities with a refined version of an example I presented in London last week. After that we discuss the versatile possibilities for extending and customizing the framework and [...]

  5. Özgün Says:

    Hi Heiko,

    first of all, thanks again! As many others, I also think, that you have a gift with presenting the things, you know :)

    Sorry for asking again, but do you know when you will be able to publish the Xtext code for the (meanwhile so famous:)) chess example?

    Best

    Özgün

  6. Heiko Behrens Says:

    Thank you for this complement, Özgün. As you might have seen by the stagnation of new blog posts I haven’t found much the time to write about new stuff recently. There are two more post in the pipeline (one about iPhone programming, one about Xtext in practice). After that, I will write about an extended version of this chess example accompanied by a screencast.

    Please apologize the delay.

Leave a Reply