From Rosetta Code
This programming language may be used to instruct a computer to perform a task.
Official website
Execution method: Interpreted
Garbage collected: Yes
Parameter passing methods: By value
Type safety: Safe
Type strength: Strong
Type expression: Partially implicit
Type checking: Dynamic
See Also:

Listed below are all of the tasks on Rosetta Code which have been solved using Rascal.

Rascal is a domain specific language for source code analysis and manipulation a.k.a. meta-programming. It is currently being developed and tested at CWI. No formal release has been made yet, but alpha quality "previews" are available on the Download page.[1]

The Rascal logo

Why Rascal?

Rascal is a new language for meta-programming, this is the activity of writing meta-programs[2]. Using Rascal you create programs that read, analyse, transform, generate and/or visualize other programs. Meta-programs are programs that analyze, transform or generate other programs. Ordinary programs work on data; meta-programs work on programs.

The range of programs to which meta-programming can be applied is large: from programs in standard languages like C and Java to domain-specific languages for describing high-level system models or applications in specialized areas like gaming or finance. In some cases, even test results or performance data are used as input for meta-programs.

The range of kinds of meta programs that can be applied is also large. There are simple meta programs that generate boilerplate code from a list of items. There are complex meta programs that reverse engineer and statically analyse a big software system before visualizing the results. The point of Rascal is that in all these kinds of meta programs one needs similar operations and similar data-types.

The point of Rascal is to provide a reusable set of primitives to build and manipulate program representations. The point is not to be or provide a unified representation of programs to let generic algorithms operate on. In meta programming the devil is often in the details. Rascal makes sure to not a priori abstract from the important details programming language syntax and semantics.

Rascal is a domain specific programming language. We emphasize programming here because Rascal is intended as an engineering tool for programmers that need to construct meta programs. Rascal programs allow running, inspecting, debugging, tracing, profiling, etc. just as normal programs do. The skills of any good programmer are enough to easily write good Rascal programs.


Typical applications of Rascal are:

  1. Refactoring of Java source code.
  2. Analyzing PHP code.
  3. Searching for buffer overflows in C code.
  4. Analyzing the version history of a large software project.
  5. Implementing a domain-specific language (DSL) for describing games or business processes.

All these cases involve a form of meta-programming: software programs (in a wide sense) are the objects-of-interest that are being analyzed, transformed or generated. The Rascal language is designed for meta-programming following the EASY paradigm. It can be applied in domains ranging from compiler construction and implementing domain-specific languages to constraint solving and software renovation.

Since representation of information is central to the approach, Rascal provides a rich set of built-in data types. To support extraction and analysis, parsing and advanced pattern matching are provided. High-level control structures make analysis and synthesis of complex datastructures simple.


  1. Familiar syntax in a what-you-see is-what-you-get style is used even for sophisticated concepts and this makes the language easy to learn and easy to use.
  2. Sophisticated built-in data types provide standard solutions for many meta-programming problems.
  3. Safety is achieved by finding most errors before the program is executed and by making common errors like missing initializations or invalid pointers impossible.
  4. Local type inference makes local variable declarations redundant.
  5. Pattern matching can be used to analyze all complex datastructures.
  6. Syntax definitions make it possible to define new and existing languages and to write tools for them.
  7. Visiting makes it easy to traverse datastructures and to extract information from them or to synthesize results.
  8. Templates enable easy code generation.
  9. Functions as values permit programming styles with high re-use.
  10. Generic types allow writing functions that are applicable for many different types.
  11. Eclipse integration makes Rascal programming a breeze. All familiar tools are at your fingertips.


  1. Rascal programs are not yet highly optimized so execution maybe slow for some programs.
  2. At the time of writing, this checking is done during execution, but we are working on this.


Here's a list of facts[3] about Rascal that you might find interesting:

  1. Rascal is the successor of the ASF+SDF Meta-Environment.
  2. Like ASF+SDF, it fully supports embedded concrete syntax fragments for "syntax safe" matching and construction of source code.
  3. Like StringTemplate, it supports recursive string templates for code generation in the absence of a context-free grammar.
  4. Tobias Baanders designed the Rascal logo.
  5. It employs a parsing architecture inspired by Scott and Johnstone's GLL parsing.
  6. It's fundamental run-time data representation and manipulation API (pdb.values) is a part of Eclipse IMP.
  7. PDB.values was inspired (mostly) by the ATerm library and RScript.
  8. We used Rascal itself to transform its Java-based interpreter from the Visitor design pattern to the Interpreter design pattern automagically.