| Racket | |
|---|---|
DrRacket onLinux | |
| Paradigm | Multi-paradigm:functional,imperative,logic,meta,modular,object-oriented,reflective |
| Family | Lisp |
| Designed by | PLT Inc. |
| Developer | PLT Inc. |
| First appeared | January 28, 1995; 30 years ago (1995-01-28) |
| Stable release | |
| Typing discipline | Dynamic,static,strong |
| Platform | x86,PowerPC,SPARC,MIPS,ARM |
| OS | Cross-platform |
| License | MIT orApache 2.0[2] |
| Filename extensions | .rkt[3] |
| Website | racket-lang |
| Majorimplementations | |
| Racket,RacketScript Racket to JavaScript (ES6) compiler,Pycket a Racket implementation usingRPython. | |
| Dialects | |
| Typed Racket, FrTime, Lazy Racket, Scribble | |
| Influenced by | |
| Eiffel,[4]Scheme | |
| Influenced | |
| Clojure,[5]Rust,[6][7]Scheme (R6RS)[8] | |
Racket is ageneral-purpose,multi-paradigm programming language. The Racket language is a modern dialect ofLisp and a descendant ofScheme. It is designed as a platform forprogramming language design and implementation.[9] In addition to the core Racket language,Racket is also used to refer to the family of programming languages[10] and set of tools supporting development on and with Racket.[11] Racket is also used forscripting,computer science education, and research.
The Racket platform provides an implementation of the Racket language (including aruntime system,[12] libraries, andcompiler supporting several compilation modes: machine code, machine-independent, interpreted, and JIT) along with the DrRacketintegrated development environment (IDE) written in Racket.[13] Racket is used by theProgramByDesign outreach program, which aims to turncomputer science into "an indispensable part of theliberal artscurriculum".[14][15]
The core Racket language is known for its extensivemacro system which enables creating embedded anddomain-specific languages, language constructs such asclasses ormodules, and separate dialects of Racket with differentsemantics.[16][17][18][19]
The platform distribution isfree and open-source software distributed under theApache 2.0 andMIT licenses.[20] Extensions and packages written by the community may be uploaded to Racket'spackage catalog.
Matthias Felleisen founded PLT Inc. in the mid 1990s, first as a research group, soon after as a project dedicated to producingpedagogic materials for novice programmers (lectures, exercises/projects, software). In January 1995, the group decided to develop a pedagogic programming environment based onScheme.Matthew Flatt cobbled together MrEd, the originalvirtual machine for Racket, from libscheme,[21]wxWidgets, and a few other free systems.[22] In the years that followed, a team including Flatt,Robby Findler,Shriram Krishnamurthi, Cormac Flanagan, and many others produced DrScheme, a programming environment for novice Scheme programmers and a research environment forgradual typing.[13] The main development language that DrScheme supported was named PLT Scheme.
In parallel, the team began conducting workshops for high school teachers, training them in program design and functional programming. Field tests with these teachers and their students provided essential clues for directing the development.
Over the following years, PLT added teaching languages, an algebraic stepper,[23] a transparentread–eval–print loop, a constructor-based printer, and many other innovations to DrScheme, producing an application-quality pedagogic program development environment. By 2001, the core team (Felleisen, Findler, Flatt, Krishnamurthi) had also written and published their first textbook,How to Design Programs, based on their teaching philosophy.
The Racket Manifesto[9] details the principles driving the development of Racket, presents the evaluation framework behind the design process, and details opportunities for future improvements.
The first generation of PLT Scheme revisions introduced features forprogramming in the large with bothmodules andclasses. Version 42 introduced units – a first-class module system – to complement classes for large scale development.[24] The class system gained features (e.g.Java-styleinterfaces) and also lost several features (e.g.multiple inheritance) throughout these versions.[16] The language evolved throughout a number of successive versions, and gaining milestone popularity in Version 53, leading to extensive work and the following Version 100, which would be equivalent to a "1.0" release in current popular version systems.
The next major revision was named Version 200, which introduced a new default module system that cooperates with macros.[24] In particular, the module system ensures that run-time andcompile-time computation are separated to support a "tower of languages".[25] Unlike units, these modules are notfirst-class objects.
Version 300 introducedUnicode support,foreign library support, and refinements to the class system.[24] Later on, the 300 series improved theperformance of the language runtime with an addition of a JIT compiler and a switch to a defaultgenerational garbage collection.
By the next major release, the project had switched to a more conventionalsequence-based version numbering. Version 4.0 introduced the#lang shorthand to specify the language that a module is written in. Further, the revision introducedimmutable pairs and lists, support for fine-grainedparallelism, and astatically-typed dialect.[26]
On 7 June 2010, PLT Scheme was renamed Racket.[27] The renaming coincided with the release of Version 5.0. Subsequently, thegraphical user interface (GUI) backend was rewritten in Racket fromC++ in Version 5.1 using nativeUI toolkits on all platforms.[22] Version 5.2 included a backgroundsyntax checking tool, a new plotting library, a database library, and a new extended REPL.[28] Version 5.3 included a new submodule feature for optionally loaded modules,[29] newoptimization tools, aJSON library, and other features.[30] Version 5.3.1 introduced major improvements to DrRacket: the background syntax checker was turned on by default and a new documentation preview tool was added.[31]
In version 6.0, Racket released its second-generation package management system. As part of this development, the principal DrRacket and Racket repository was reorganized and split into a large set of small packages, making it possible to install aminimal racket and to install only those packages needed.[32]
Version 7 of Racket was released with a new macro expander written in Racket as part the preparations for supporting moving to theChez Scheme runtime system and supporting multiple runtime systems.[33][34] On 19 November 2019, Racket 7.5 was released. The license of Racket 7.5 was less restrictive. They use now either the Apache 2.0 license or the MIT license.[35][36]
On 13 February 2021, Racket 8.0 was released. Racket 8.0 marks the first release where Racket with theChez Scheme runtime system, known as Racket CS, is the default implementation. Racket CS is faster, easier to maintain and develop, backward-compatible with existing Racket programs, and has better parallel garbage collection.[37]
Racket's core language includesmacros,modules,lexical closures,tail calls,delimited continuations,[38] parameters (fluid variables),software contracts,[39]green threads andOS threads,[40][41][42] and more. The language also comes with primitives, such as eventspaces and custodians, which control resource management and enables the language to act like anoperating system for loading and managing other programs.[12] Further extensions to the language are created with the powerful macro system, which together with the module system and custom parsers can control all aspects of a language.[43] Most language constructs in Racket are implemented as macros in the base language. These include amixin class system,[16] a component (or module) system as expressive as opaque ascription in theML module system,[17] andpattern matching.
Further, the language features the first contract system for ahigher-order programming language.[44]Racket's contract system is inspired by theDesign by Contract work forEiffel and extends it to work for higher-order values such asfirst-class functions, objects,reference cells, and so on. For example, an object that is checked by a contract can be ensured to make contract checks when its methods are eventually invoked.
Racket includes bothbytecode andJIT (JIT) compilers. The bytecode compiler produces an internal bytecode format run by the Racketvirtual machine, and the JIT compiler translates bytecode to machine code at runtime.
Since 2004, the language has also shipped with PLaneT, a package manager that is integrated into the module system so thatthird-party libraries can be transparently imported and used. Also, PLaneT has a built-inversioning policy to preventdependency hell.[45]
At the end of 2014, much of Racket's code was moved into a new packaging system separate from the main code base. This new packaging system is serviced by a client program namedraco. The new package system provides fewer features than PLaneT; a blog post by Jay McCarthy on the Racket blog explains the rationale for the change and how to duplicate the older system.[46]
The features that most clearly distinguish Racket from other languages in the Lisp family are its integrated languageextensibility features that support building newdomain-specific andgeneral-purpose languages. Racket's extensibility features are built into the module system to allow context-sensitive and module-level control over syntax.[18] For example, the#%app syntactic form can be overridden to change the semantics offunction application. Similarly, the#%module-begin form allows arbitrary static analysis of the entire module.[18] Since any module can be used as a language, via the#lang notation, this effectively means that virtually any aspect of the language can be programmed and controlled.
The module-level extensibility features are combined with aScheme-likehygienic macro system, which provides more features thanLisp's s-expression manipulation system,[47][48] Scheme 84's hygienic extend-syntax macros, orR5RS'ssyntax-rules. Indeed, it is fair to say that the macro system is a carefully tunedapplication programming interface (API) forcompiler extensions. Using this compiler API, programmers can add features and entiredomain-specific languages in a manner that makes them completely indistinguishable from built-in language constructs.
Themacro system in Racket has been used to construct entire languagedialects. This includes Typed Racket, which is a gradually typed dialect of Racket that eases the migration fromuntyped to typed code,[49] Lazy Racket—a dialect withlazy evaluation,[50] and Hackett, which combines Haskell and Racket.[51] The pedagogical programming languagePyret was originally implemented in Racket.[52][53]
Other dialects include FrTime (functional reactive programming), Scribble (documentation language),[54] Slideshow (presentation language),[55] and several languages for education.[56][57]
Racket's core distribution provides libraries to aid the development of programming languages.[18] Such languages are not restricted tos-expression based syntax. In addition to conventional readtable-based syntax extensions, the directive#lang enables the invocation of arbitrary parsers, which can be implemented using the parser tools library.[58] SeeRacket logic programming for an example of such a language.
The language platform provides aself-hostedIDE[13] named DrRacket, a continuation-basedweb server,[59] agraphical user interface,[22] and other tools. As a viable scripting tool with libraries like commonscripting languages, it can be used for scripting the Unix shell. It can parsecommand-line arguments and execute external tools.
DrRacket (formerly DrScheme) is widely used among introductory computer science courses that teach Scheme or Racket and is lauded for its simplicity and appeal to beginner programmers. The IDE was originally built for use with the TeachScheme! project (nowProgramByDesign), an outreach effort byNortheastern University and a number of affiliated universities for attracting high school students to computer science courses at the college level.
The editor provideshighlighting for syntax and run-time errors, parenthesis matching, adebugger and an algebraic stepper. Its student-friendly features include support for multiple "language levels" (Beginning Student, Intermediate Student and so on). It also has integrated library support, and sophisticatedanalysis tools for advanced programmers. Further,module-oriented programming is supported with the module browser, a contour view, integratedtesting andcoverage measurements, andrefactoring support. It provides integrated, context-sensitive access to an extensive hyper-linked help system named "Help Desk".
DrRacket is available forWindows,macOS,Unix, andLinux with theX Window System and programs behave similarly on all these platforms.
Here is a trivial"Hello, World!" program:
#langracket"Hello, World!"
Running this program produces the output:
Here is a slightly less trivial program:

#langracket(require2htdp/image)(letsierpinski([n8])(if(zero?n)(triangle2'solid'red)(let([t(sierpinski(-n1))])(freeze(abovet(besidett))))))
This program, taken from the Racket website, draws aSierpinski triangle, nested to depth 8.
Using the#lang directive, a source file can be written in different dialects of Racket. Here is an example of the factorial program in Typed Racket, astatically typed dialect of Racket:
#langtyped/racket(:fact(Integer->Integer))(define(factn)(if(zero?n)1(*n(fact(-n1)))))
Racket currently has two implementations. Both support Linux, Windows and MacOS on a variety of architectures and are supported as at version 8.8 (2023). The default implementation uses theChez Scheme incremental compiler and runtime. The alternate implementation generates platform-independent bytecode and usesJust-in-time compilation to generate machine code as it is loaded.[60]
In addition, there are experimental implementations:
Apart from having a basis inprogramming language theory, Racket was designed as a general-purpose language for production systems. Thus, the Racket distribution features an extensive library that covers systems and network programming, web development,[59] a uniform interface to the underlying operating system, a dynamicforeign function interface,[63] several flavours ofregular expressions, lexer/parser generators,[58]logic programming, and a completeGUI framework.
Racket has several features useful for a commercial language, among them an ability to compile standalone executables under Windows, macOS, and Unix, aprofiler anddebugger included in theintegrated development environment (IDE), and aunit testing framework.
Racket has been used for commercial projects and web applications. A notable example is theHacker News website, which runs onArc, which is developed in Racket.Naughty Dog has used it as a scripting language in several video games.[64]
Racket is used to teach students algebra through game design in theBootstrap program.[65]
The standard file extension for a Racket program file is ".rkt". The extensions ".ss", ".scm", and ".sch" are also historically popular.
| 1958 | 1960 | 1965 | 1970 | 1975 | 1980 | 1985 | 1990 | 1995 | 2000 | 2005 | 2010 | 2015 | 2020 | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| LISP 1, 1.5,LISP 2(abandoned) | |||||||||||||||
| Maclisp | |||||||||||||||
| Interlisp | |||||||||||||||
| MDL | |||||||||||||||
| Lisp Machine Lisp | |||||||||||||||
| Scheme | R5RS | R6RS | R7RS small | ||||||||||||
| NIL | |||||||||||||||
| ZIL (Zork Implementation Language) | |||||||||||||||
| Franz Lisp | |||||||||||||||
| muLisp | |||||||||||||||
| Common Lisp | ANSI standard | ||||||||||||||
| Le Lisp | |||||||||||||||
| MIT Scheme | |||||||||||||||
| XLISP | |||||||||||||||
| T | |||||||||||||||
| Chez Scheme | |||||||||||||||
| Emacs Lisp | |||||||||||||||
| AutoLISP | |||||||||||||||
| PicoLisp | |||||||||||||||
| Gambit | |||||||||||||||
| EuLisp | |||||||||||||||
| ISLISP | |||||||||||||||
| OpenLisp | |||||||||||||||
| PLT Scheme | Racket | ||||||||||||||
| newLISP | |||||||||||||||
| GNU Guile | |||||||||||||||
| Visual LISP | |||||||||||||||
| Clojure | |||||||||||||||
| Arc | |||||||||||||||
| LFE | |||||||||||||||
| Hy | |||||||||||||||