Spoofax in Quadraad

April 20, 2011

The following text appeared in the April 2011 issue of Quadraad, a magazine for the Faculty of Electrical Engineering, Mathematics, and Computer Science of TU Delft.

The Spoofax Language Workbench

Simplifying the Design of Domain-Specific Languages

It is the mission of the Software Language Design and Engineering group to enable software engineers to effectively design, implement, and apply domain-specific languages. To that end they are they developing the Spoofax Language Workbench.

Our society increasingly depends on software. All software is written in a programming language, a language that is understood by computers. To create software that does something useful, a software engineer has to translate ideas into a working program. Since most programming languages have been designed to write many different types of programs, the distance between idea and program can be quite large and involve many seemingly irrelevant details.

Lost in Translation

Consider, for example, an online book shop. In essence, a book shop is a collection of books that can be browsed or searched and from which clients can order books. These are the types of concepts that a software engineer should be concerned with when developing a book shop. However, when developing a web application with a traditional programming language, he is confronted with the fact that the book shop program runs in (at least) three different computers: the browser, the server, and the database. Instead of thinking about the discounting policy for books, he needs to think about decoding URLs and processing form requests. Such irrelevant details make software more complex than necessary.

Domain-Specific Languages

Domain-specific languages (DSLs) address this problem by providing a notation and concepts that are close to the application domain. For example, we have developed WebDSL, a domain-specific language for programming web applications. In WebDSL, the developer can express what kinds of things the application deals with (books, clients, orders) and what can be done with those things (browsing, searching, ordering). The WebDSL compiler then translates this to a program, including all the details that are not of interest to the developer, but are necessary for the program to work.

Language Workbench

There are many other domains for which DSLs would be useful. However, creating languages is not part of the tool box of most software engineers. It is the mission of the Software Language Design and Engineering group at TU Delft to enable software engineers to effectively design, implement, and apply domain-specific languages. To that end we are developing the Spoofax Language Workbench. With Spoofax a language designer defines the syntax (notation), the semantics (meaning), and the editor services for a language, using DSLs for language definition. From a language definition, Spoofax automatically creates a complete Integrated Development Environment (IDE) for the new language. Figure 1 shows an IDE for a web programming language built with Spoofax; it provides all the editor services that are common in modern IDEs, such as syntax highlighting, inline error markers, and content completion. Figure 2 shows how Spoofax is used to define a language and test its IDE in the same environment.

Language Design in Education

Language workbenches such as Spoofax enable the next generation of software engineers to solve software problems through linguistic abstraction. In the Delft computer science curriculum we prepare our students for that future. In the Compiler Construction course students build a compiler for a small object-oriented language and implement a full fledged IDE plugin. In the master course Model-Driven Software Development, students design their own DSL from scratch.

Future Work

Spoofax is a great language implementer’s workbench. In the next phase of research we want to enrich Spoofax into a language designer’s workbench by providing intelligent design assistance based on analysis of (partial) language definitions and example programs. Another direction for research is the generation of web-based IDEs from language definitions to support software development `in the cloud’.

A Language for Your Domain?

Are you working in a domain of software development that requires too much attentention to irrelevant details? We are very much interested in exploring new software domains to develop DSLs for. Do you already have a language (design) and need an IDE? We are also interested in benchmarks for our language workbench.