Creating Languages in Racket

Reference: Matthew Flatt (2012). Communications of the ACM, Vol. 55, No. 1. Source file: 2063176.2063195.pdf. URL

Summary

Practitioner-oriented introduction to Racket’s support for language-oriented programming: building domain-specific languages as a natural extension of ordinary programming. Flatt develops a text-adventure game incrementally, starting from Racket’s core, adding pattern-matching macros (define-syntax-rule) for define-place, define-thing, define-verb, then packaging these extensions into a module language (#lang txtadv) with its own non-parenthesised reader syntax and IDE (DrRacket) support.

The article demonstrates the full spectrum from simple syntactic abstraction via macros up through module languages that replace the default reader, showing how Racket smooths the path from library to full DSL.

Key Ideas

  • Language-oriented programming as a practical paradigm
  • define-syntax-rule and syntax-case macros for pattern-based extension
  • Module languages (#lang ...) package extensions as first-class languages
  • Static checks can be implemented via macro-level type tagging
  • DrRacket provides IDE integration for custom languages

Connections

Conceptual Contribution

Tags

#racket #dsl #language-oriented-programming #macros

Backlinks