Skip to content
Tutorials Center
My learning

Topics

Lesson 4 of 38 ยท Getting Started

Racket, Scheme Dialects and the Ecosystem

A map of the Scheme and Racket world: the R5RS, R6RS and R7RS standards, major implementations, the Racket package catalog, and how to choose where to start.

"Scheme" is not one program you download. It is a family of languages described by a series of standards, with many independent implementations. Racket is the largest member that decided to be its own language. Knowing the map saves a lot of confusion when you read older books or search for help.

This lesson is an overview. The code snippets are real Scheme and Racket, shown read-only, with a small runnable example at the end that works the same way in nearly every dialect.

The standards

Standard Year What to know
R5RS 1998 Tiny, beloved, used by SICP-era books. No modules, no records, no exceptions.
R6RS 2007 Added libraries, records, exceptions, Unicode strings. Controversial for its size.
R7RS-small 2013 A return to a small core with a library system. The current common standard.
R7RS-large in progress A growing set of extra libraries.

Most of what you learn in this course is the common core: define, lambda, let, cond, if, pairs and lists, recursion, tail calls, call/cc, and macros. It works in almost any dialect with only surface differences.

Major implementations

Popular Schemes

Chez Scheme Very fast native compiler.
GNU Guile Embeds in C programs.
CHICKEN Compiles to C.
MIT/GNU Scheme The SICP classic.

All speak the same core language.

1 / 2
  • Chez Scheme: an extremely fast compiler. Today it is also the engine inside Racket CS, the current Racket implementation.
  • Guile: the GNU extension language; embeds into C programs and runs parts of GNU Guix.
  • CHICKEN: compiles to C and has a big package ecosystem ("eggs").
  • Gambit, Gauche, Chibi, Cyclone, Larceny: each has a niche such as small size, scripting, or embedding.
  • MIT/GNU Scheme: the implementation used in SICP-era courses.

Racket's differences from standard Scheme

Racket started as a Scheme, but it deliberately changed some things:

  • Immutable pairs. cons makes immutable pairs; use mcons for mutable ones. set-car! does not exist in #lang racket.
  • Square brackets are parentheses. [ and ] are interchangeable with ( and ); the convention is to use them for let bindings and cond clauses.
  • More names. first, rest, empty, filter, foldl, for loops, string-join, hash tables, structs, and so on are built in.
  • Modules everywhere. Every file is a module and #lang picks its language.
  • Other conventions. else is a keyword inside cond; #t and #f can also be written #true and #false; the empty list is '() or empty.

The same idea written in several dialects:

SCHEME
;; R5RS / R7RS style
(define (square x) (* x x))
(display (map square '(1 2 3)))
(newline)
RACKET
;; Racket style
#lang racket
(define (square x) (* x x))
(displayln (map square '(1 2 3)))

Both print (1 4 9). Note that Racket would print '(1 4 9) if it were an unprinted top-level expression, as you saw in the REPL lesson.

The Racket ecosystem

  • Documentation: docs.racket-lang.org (also raco docs). The Racket Guide teaches, the Racket Reference is complete.
  • Packages: raco pkg install <name> fetches from the package catalog (pkgs.racket-lang.org): web servers, parsers, plotting, databases.
  • Teaching languages: the How to Design Programs (HtDP) languages (#lang htdp/bsl) restrict Racket to help beginners.
  • Typed Racket: #lang typed/racket adds a gradual static type system.
  • Other languages: #lang scribble/manual (documentation), #lang datalog, #lang algol60, and many you can define yourself.

Which one should you learn? If you want a complete, friendly environment with docs, a GUI and an IDE, choose Racket. If you want a tiny, standards-focused language or to embed one in a program, pick Guile, CHICKEN or Chibi. This course uses Racket for real code and sticks to ideas that carry over to every Scheme.

Code that works everywhere

Here is a small program with no dialect-specific features. It runs under the stand-in interpreter and, with trivial changes, in Racket, Guile or Chez:

Portable Scheme

A real dialect difference: R5RS prints with display and newline, while Racket adds displayln. A portable program sticks to display and newline, and uses (define (f ...) ...), cond, let and lambda, which are the same in every dialect.

Where this course goes

Chapter What you gain
Syntax and evaluation Reading Lisp code and how it runs
Lists and recursion The central data structure and its natural algorithms
Higher-order functions map, filter, fold, closures
Continuations and tail calls Non-local control, loops, generators
Macros and languages Writing new syntax, then new #langs
Modules, contracts, applications, projects Real programs

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which Scheme standard is the current small-core standard with a library system?

    R7RS-small (2013) returned to a small core and added a library system. R6RS was larger and R5RS predates libraries.
  2. 2. What does Racket CS use as its engine?

    Racket CS is built on Chez Scheme, a very fast Scheme compiler.
  3. 3. In #lang racket, how do cons cells differ from R5RS pairs?

    Racket pairs are immutable. Mutable pairs are a separate type created with mcons.
  4. 4. Which is true of [ ] in Racket?

    Square brackets are read exactly like parentheses; they just make nested forms easier to see.

Summary

  • Scheme is a family defined by the R5RS, R6RS and R7RS standards; Racket began as a Scheme and became its own language.
  • Chez, Guile, CHICKEN and MIT/GNU Scheme are major Schemes; Racket CS runs on Chez.
  • Racket's differences: immutable pairs, [ ] brackets, many built-in names, modules and #lang.
  • The core idioms in this course work in every dialect.

Next: S-expressions and How Evaluation Works