On this page:
Teach Yourself Racket

Teach Yourself Racket

(a flânerie by Prabhakar Ragde)

Racket is a modern functional programming language, a dialect of Lisp and Scheme, good for exploration of ideas and rapid prototyping. Since 2001, it has been my preferred first programming language for beginners, and I also recommend it to those with computing experience, due to the low overhead of installation and experimentation. It comes with DrRacket, which is my model of what an integrated development environment (IDE) should be: gentle enough for the complete beginner, but sophisticated enough for experts.

This document offers a quick, shallow, and incomplete introduction to the language for mature programmers with experience in an imperative language (C, C++, Java, Python, etc.). Although I have grouped it with my other flâneries, it is less a stroll than a sprint.

High school and undergraduate students, as well as those with no prior experience with computation, will be better off with a more careful introduction to Racket and ideas of functional programming such as that afforded by How To Design Programs (Second Edition), or my own Functional Introduction to Computer Science (in progress). Both of these take advantage of a series of teaching languages implementing small subsets of Racket. Even experienced programmers could benefit from the HtDP "programming by design" approach. But patience is sometimes a luxury we cannot afford and sometimes a virtue we choose to forego.

In addition to HtDP, I have been inspired by The Racket Guide, Teach Yourself Scheme in Fixnum Days, The Little Schemer, The Scheme Programming Language, and many blog posts and mailing list contributions. My thanks to the dynamic and friendly Racket community.

    1 Basics

      1.1 Getting started

      1.2 Programs, expressions, and values

      1.3 Definitions

      1.4 Some notes on style

      1.5 Conditional expressions

      1.6 Recursion

      1.7 Compound data

      1.8 Modules

      1.9 Testing

    2 Pure Functional Programming

      2.1 Lambda

      2.2 Higher-Order Functions

      2.3 Local Variables

      2.4 Pattern Matching

    3 Impure Functional Programming

      3.1 Input and Output

      3.2 Mutation

    4 Advanced Racket

      4.1 Iterations and Comprehensions

      4.2 Regular Expressions

      4.3 Exceptions

      4.4 Prompts and Continuations

      4.5 Concurrency

      4.6 Macros

      4.7 Typed Racket

      4.8 Scribble