Agile Language Engineering Tutorial

This week, Guido Wachsmuth and I gave a tutorial at the University of Agder on using the tools MMUnit, EProvide, and TEF for agile language engineering. We described how to generate a prototype of a DSL with a test-first approach to metamodel development and with an operational semantics approach for describing the DSL's semantics.

As an example DSL, we used a very simple language for describing the behaviour of a telephone remote control system. The idea is that you can call the system with your mobile phone and use your phone's DTMF tones to control something remotely in your house. The DSL looks like this:
main {
say "main menu";
listen {
1: "control lights" -> lights;

lights {
say "your lights are";
say lights_status();
listen {
1: "switch your lights" -> switch_lights;
0: "return to main menu" -> main;

switch_lights {
say "your lights are now";
say lights_status();
goto main;
You can find the slides of the tutorial here and here. There was also a handout that explains step-by-step how to create the DSL prototype. In this folder, there are some code snippets you may find useful if you want to go through this tutorial.
If you are lazy you can also just download the completed project or watch this screencast showing the prototype in action.


EProvide 2.1.0

Yesterday, we released a new version of EProvide.

(EProvide is an Eclipse EMF-based tool with which you can describe the operational semantics of your DSL using different description languages. The idea behind EProvide is to metamodel not only the static structure of your DSL but also the runtime states. Thus, the runtime state of a DSL program is encoded in a model that changes step-wise over time. With EProvide, these step-wise changes are described with a model transformation that transforms one runtime state to its successor. Based on such a description and on an editor for your DSL, EProvide can execute your models in an animated way so that you can observe and debug model execution.)

The new version is much better integrated into the Eclipse debug framework than its predecessor: you can use Eclipse's standard GUI elements for controlling model execution (suspend, resume, step, drop to frame = reset initial state, terminate). Also, we added a new step-back button to the debug view that allows you to step back in the execution history of your model execution.

You can see the new features demonstrated in this screencast.


Time Machine freezes computer

I let Time Machine backup into a sparse bundle on a windows share. This worked a little slow but otherwise fine until yesterday when Time Machine froze my MacBook every time it ran. To get it back running, I had to turn off the MacBook by holding down the power key for a few seconds. After restart, Mac OS told me the reason: a kernel panic with this backtrace:

panic(cpu 0 caller 0x00321C20): "hfs_UNswap_BTNode: invalid forward link (0xABAC0006)\n"@/SourceCache/xnu/xnu-1228.5.20/bsd/hfs/hfs_endian.c:254
Backtrace, Format - Frame : Return Address (4 potential args on stack)
0x3cb4b768 : 0x12b0fa (0x4592a4 0x3cb4b79c 0x133243 0x0)

After some web search [1], I found out that the reason was probably a defect sparse bundle caused by turning off my computer during backups, which I sometimes do. So the solution was to repair the sparse bundle:

  1. I mounted the windows share on which my Time Machine sparse bundle lies.
    Then, I executed the following commands in the terminal:
  2. Make the sparse bundle available as a device (in my case, it was /dev/disk1, but hdiutil tells you, which device it assigns the sparse bundle to):
    hdiutil attach -nomount -readwrite /Volumes/windows_share/my.sparsebundle
  3. Repair the sparse bundle (this takes some time):
    fsck_hfs -f /dev/disk1


Are writing code and writing text so different?

It seems to me that programming and paper writing modify your brain in incompatible ways. Whenever I have been heavily in programming for a couple of days, I have problems switching to paper writing -- and vice versa. Maybe it is because in paper writing, you are forced to structure your thoughts in a sequential order, whereas in programming, knowing your code structure requires you to keep track of many things in parallel: call and inheritance hierarchies, operation parameters, names of variable, operations, and classes, ...


Eclipse Ganymede OutOfMemoryError

The new version of Eclipse is out now: Ganymede. I installed it and most things seem to work fine. The only problem I had was getting an OutOfMemoryError when starting a second Eclipse instance with the Eclipse plugins I develop. This error occurs in the second Eclipse instance after activating some of the plugins by GUI interaction. Normally, such an error can be solved by increasing the maximum heap size the JVM can use with the VM argument -Xmx. The default size is 128m and usually -Xmx256m is enough for my purposes.

However, in this case, increasing the heap size did not solve the problem. The error that occurred was not the typical OutOfMemoryError. The total heap size was big enough but the PermGen region was too small. This was indicated by the error's message:
java.lang.OutOfMemoryError: PermGen space

To solve this error, I had to increase this region's size with this VM argument (the default size is 64m):


Resizing sparse bundle image for time machine

I use Mac OS X Leopard's time machine to backup my notebook data to a network drive. I configured it according to this tutorial. Everything works fine. Initially, I set the maximum size of the spare bundle image to 15GB. Now I wanted to increase this to 20GB. After some searching, I found the solution:

hdiutil resize -size 20g


Configurable Sequence Highlighting

Sometimes when editing DNA sequences, you wish to highlight specific sequence parts, e.g., all stop codons.
For this, I made an update of the TextMate bundle I wrote for sequence analysis. The new version supports custom highlighting of sequences and can be downloaded from the same location as the old version. There is a new command ("Sequence Analysis" -> "Highlighted Sequences...") for configuring the custom highlighting. It opens a dialog in which you can enter sequence patterns, give each sequence pattern a name and a color, and enable and disable sequence patterns. A sequence pattern can be a single sequence string or a list of multiple sequences separated by dashes ("|"). Unfortunately, you must restart TextMate for the changes to take effect.


Finder integration for restoring .svn folders

I created an Automator workflow for the shell script "svnRecover" I wrote about in an earlier post. This allows to restore the .svn folders in a Keynote/Pages or similar document that is under Subversion control. For this, you simply select More->Automator->SVN_Recover from the document's context menu (see screenshot). You can download the automator workflow here. To install it, unzip it and copy the workflow document into the folder ~/Library/Workflows/Applications/Finder in your home directory. (You do not need to install the shell script separately; it is included in the Automator workflow.)

Update 2008-09-16: I fixed a bug that could lead to the deletion of all contents of folders with extended privileges.


DNA Sequence Analysis with TextMate

I have built my first bundle for TextMate, the famous text editor for Mac OS X. The bundle allows simple DNA sequence analysis tasks, like setting the reading frame, sequence comparison, expressing codons, and determining masses of the expressed amino acids. For sequence comparison, I integrated two tools from EMBOSS: needle and water. These are also accessible via a web interface of the European Bioinformatics Institute.

You can download the bundle here. Just unzip the file and double click it or drag it on the TextMate application. When you edit a sequence file you should select "Fasta" as language at the bottom of TextMate. Then, you can access the sequence analysis commands by pressing Ctrl+Escape.

Have fun!


Remove .svn folders

This is just another svn hack. On the Mac, when copying a Keynote/Pages/Numbers or similar document that is under subversion control, you also copy all its .svn directories. A similar problem to the one I described in this post. Again, a litte shell script can help here. svnCleanAllSvnFolders simply removes all .svn folders inside the current directory—if you call it with "yes" as a parameter; otherwise it just prints out what it would remove.