In Racket, programmers define their own loops with powerful macros. Indeed, these macros are so powerful that programmers make entire domain-specific languages as libraries. No tools, no Makefiles required.
Racket allows programmers to add new syntactic constructs in the same way that other languages permit the formulation of procedures, methods, or classes. All you need to do is formulate a simple rule that rewrites a custom syntax to a Racket expression or definition.
Little macros can particularly help programmers with DRY where other features can’t. The example on the leftabove shows how to define a new syntax for measuring the time a task takes. The syntax avoids the repeated use of lambda. Note also how the macro is exported from this module as if it were an ordinary function.
Macros work with these tools. The example on the leftabove shows the implementation of a small number-guessing game. It is implemented in the GUI dialect of Racket, and demonstrates a number of language features.
While Racket is a functional language, it has offered a sub-language of classes and objects, mixins and traits, from the beginning. The macro-based implementation of a Java-like class system lives in a library and does not need any support from the core language. A Racket programmer can thus combine functional with object-oriented components as needed.
Some languages convey ideas more easily than others. And some programming languages convey solutions better than others. Therefore Racket is a language for making languages, so that a programmer can write every module in a well-suited languages.
Often an application domain comes with several languages. When you need a new language, you make it—on the fly. Open an IDE window; create a language right there, with just a few keystrokes; and run a module in this new language in a second IDE window. Making new languages really requires no setup, no project files, no external tools, no nothing.
Racket comes with its own IDE, DrRacket (née DrScheme), and it sports some unique features. For example, when a programmer mouses over an identifier, the IDE draws an arrow back to where it was defined.
A programmer immediately benefits from DrRacket while using an alternative language, say Typed Racket. Racket macros, even complex ones and those used to make new languages, record and propagate a sufficient amount of source information for DrRacket to act as if it understood the features of the new language.
Racket programmers usually love parentheses, but they have empathy for those who need commas and braces. Hence, building languages with conventional surface syntax, like that of datalog, is almost as easy as building parenthetical languages.
Racket’s ecosystem comes with parsing packages that allow developers to easily map any syntax to a parenthesized language, which is then compiled to ordinary Racket with the help of Racket’s macro system. Such a language can also exploit the hooks of the IDE framework, so that its programmers may take advantage of Racket’s IDE.