World Library  
Flag as Inappropriate
Email this Article

Racket (programming language)

Article Id: WHEBN0003350021
Reproduction Date:

Title: Racket (programming language)  
Author: World Heritage Encyclopedia
Language: English
Subject: Scheme (programming language), Macro (computer science), List of programming languages by type, Arc (programming language), Shriram Krishnamurthi
Collection: Academic Programming Languages, Articles with Example Racket Code, Cross-Platform Free Software, Educational Programming Languages, Extensible Syntax Programming Languages, Free Compilers and Interpreters, Functional Languages, Lisp Programming Language Family, Object-Oriented Programming Languages, Pedagogic Integrated Development Environments, Programming Languages Created in 1994, R6Rs Scheme, Scheme (Programming Language) Compilers, Scheme (Programming Language) Implementations, Scheme (Programming Language) Interpreters, Scheme Implementations, Software Using the Lgpl License
Publisher: World Heritage Encyclopedia

Racket (programming language)

DrRacket on Ubuntu GNU/Linux
Paradigm(s) Multi-paradigm: functional, procedural, modular, object-oriented, logic, reflective, meta
Designed by PLT Inc.
Developer PLT Inc.
Appeared in 1994
Stable release 6.1[1] / August 2, 2014 (2014-08-02)
Typing discipline Dynamic, strong, static
Dialects Typed Racket, Lazy Racket, Scribble, FrTime, more
Influenced by Scheme, Eiffel[2]
Influenced Scheme,[3] Rust, Clojure[4]
Platform x86, PowerPC, SPARC, MIPS, ARM
OS Cross-platform
License LGPL
Filename extension(s) .rkt, .rktl, .rktd, .scrbl, .plt, .ss, .scm
Website .orgracket-lang

Racket (formerly named PLT Scheme) is a general purpose, multi-paradigm programming language in the Lisp/Scheme family. One of its design goals is to serve as a platform for language creation, design, and implementation.[5][6] The language is used in a variety of contexts such as scripting, general-purpose programming, computer science education, and research.

The platform provides an implementation of the Racket language (including a sophisticated run-time system,[7] various libraries, JIT compiler, and more) along with a development environment called DrRacket (formerly named DrScheme) written in Racket itself.[8] The IDE and an accompanying programming curriculum is used in the ProgramByDesign outreach program, an attempt to turn computing and programming into "an indispensable part of the liberal arts curriculum".[9][10] The core language is known for its extensive macro system which enables the creation of embedded and domain-specific languages, language constructs such as classes or modules, and separate dialects of Racket with different semantics.[11][12][13][14]

The platform distribution is free and open source software distributed under the LGPL license. Extensions and packages written by the community are uploaded to Racket's centralized package catalog.


  • History 1
    • Development 1.1
    • Version history 1.2
    • Racket 1.3
  • Features 2
    • Macros and extensibility 2.1
  • Programming environment 3
    • DrRacket IDE 3.1
  • Code examples 4
  • Applications and practical use 5
  • References 6
  • Further reading 7
  • External links 8
    • Tutorials 8.1
    • Style guide 8.2
    • Website and documentation 8.3



Matthias Felleisen founded PLT in the mid 1990s, first as a research group, soon after as a project dedicated to the production of pedagogic materials for novice programmers (lectures, exercises/projects, software). In January 1995, the group decided to develop a pedagogic programming environment based on Scheme. Matthew Flatt cobbled together MrEd—the original virtual machine for Racket—from libscheme,[15] wxWidgets, and a few other free systems.[16] 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 for soft typing.[8] The main development language that DrScheme supported was called PLT Scheme.

In parallel, the team started 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 the direction of the development.

Over the following years, PLT added teaching languages, an algebraic stepper,[17] a transparent read-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.

Version history

The first generation of PLT Scheme revisions introduced features for programming in the large with both modules and classes. Version 42 introduced units — a first-class module system — to complement classes for large scale development.[18] The class system gained features (e.g. Java-style interfaces) and also lost several features (e.g. multiple inheritance) throughout these versions.[12] 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.[18] In particular, the module system ensures that run-time and compile-time computation are separated to support a "tower of languages."[19] Unlike units, these modules are not first-class objects.

Version 300 introduced Unicode support, foreign library support, and refinements to the class system.[18] Later on, the 300 series improved the performance of the language runtime with an addition of a JIT compiler and a switch to a default generational garbage collection.

By the next major release, the project had switched to a more conventional sequence-based version numbering. Version 4.0 introduced the #lang shorthand to specify the language that a module is written in. In addition, the revision introduced immutable pairs and lists, support for fine-grained parallelism, and a statically-typed dialect.[20]


On June 7, 2010, PLT Scheme was renamed Racket.[21] The renaming coincided with the release of Version 5.0. Subsequently, the GUI backend was rewritten in Racket from C++ in Version 5.1 using native UI toolkits on all platforms.[16] Version 5.2 included a background syntax checking tool, a new plotting library, a database library, and a new extended REPL.[22] Version 5.3 included a new submodule feature for optionally loaded modules,[23] new optimization tools, a JSON library, and other features.[24] 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.[25]


Racket's core language includes macros, modules, lexical closures, tail calls, delimited continuations,[26] parameters (fluid variables), software contracts,[27] green and OS threads,[28][29][30] and more. The language also comes with primitives, such as eventspaces and custodians, which control resource management and enables the language to act like an operating system for loading and managing other programs.[7] 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.[31] Unlike programming languages that lack macro systems, most language constructs in Racket are written on top of the base language using macros. These include a mixin class system,[12] a component (or module) system as expressive as ML's,[13] and pattern matching.

In addition, the language features the first contract system for a higher-order language.[32] Racket's contract system is inspired by the Design by Contract work for Eiffel and extends it to work for higher-order values such as first-class functions, objects, reference cells, and so on. For example, an object that is checked by a contract can be insured to make contract checks when its methods are eventually invoked.

Racket's compiler is a bytecode compiler that translates to an internal bytecode format that is run by the Racket virtual machine. On x86 and PowerPC platforms, the bytecode is further compiled using a JIT compiler at runtime.

Since 2004, the language has also shipped with PLaneT, a package manager that is integrated into the module system so that third-party libraries can be transparently imported and used. Additionally, PLaneT has a built-in versioning policy to prevent dependency hell.[33]

Macros and extensibility

The feature that distinguishes Racket from other languages in the Lisp family is its integrated language extensibility. Racket's extensibility features are built into the module system to allow context-sensitive and module-level control over syntax.[14] For example, the #%app syntactic form can be overridden to change the semantics of function application. Similarly, the #%module-begin form allows arbitrary static analysis of the entire module.[14] Since any module can be used as a language, via the #lang notation, this effectively means a programmer can control virtually any aspect of the language.

The module-level extensibility features are combined with a Scheme-like hygienic macro system, which provides more features than Lisp's S-expression manipulation system,[34][35] Scheme 84's hygienic extend-syntax macros, or R5RS's syntax-rules. Indeed, it is fair to say that the macro system is a carefully tuned application programming interface (API) for compiler extensions. Using this compiler API, programmers can add features and entire domain-specific languages in a manner that makes them completely indistinguishable from built-in language constructs.

The macro system in Racket has been used to construct entire language dialects. This includes Typed Racket—a statically typed dialect of Racket that eases the migration from untyped to typed code,[36] and Lazy Racket—a dialect with lazy evaluation.[37] Other dialects include FrTime (functional reactive programming), Scribble (documentation language),[38] Slideshow (presentation language),[39] and several languages for education.[40][41] Racket's core distribution provides libraries to aid the process of constructing new programming languages.[14]

Such languages are not restricted to S-expression based syntax. In addition to conventional readtable-based syntax extensions, Racket's #lang makes it possible for a language programmer to define any arbitrary parser, for example, using the parser tools library.[42] See Racket logic programming for an example of such a language.

Programming environment

The language platform provides a self-hosted IDE[8] named DrRacket, a continuation-based web server,[43] a graphical user interface,[16] and other tools. Racket is also a viable scripting tool and can be used for scripting the Unix shell and includes libraries like all common scripting languages.

DrRacket IDE

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 (now ProgramByDesign), an outreach effort by Northeastern University and a number of affiliated universities for attracting high school students to computer science courses at the college level.

The editor provides source highlighting for syntax and run-time errors, parenthesis matching, a debugger 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 sophisticated analysis tools for advanced programmers. In addition, module-oriented programming is supported with the module browser, a contour view, integrated testing and coverage measurements, and refactoring support. It provides integrated, context-sensitive access to an extensive hyper-linked help system named "Help Desk".

DrRacket is available for Windows (95 and up), Mac OS X, Unix, and Linux with the X Window System and programs behave similarly on all these platforms.

Code examples

Here's a trivial "hello world" program:

#lang racket
"Hello, World!"

Running this program produces the output:

"Hello, World!"

Here's a slightly less trivial program:

The result of this program, as shown in DrRacket
#lang racket
(require 2htdp/image)
(let sierpinski ([n 8])
  (if (zero? n)
    (triangle 2 'solid 'red)
    (let ([t (sierpinski (- n 1))])
      (freeze (above t (beside t t))))))

This program, taken from the Racket website, draws a Sierpinski 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, a statically typed dialect of Racket:

#lang typed/racket
(: fact (Integer -> Integer))
(define (fact n)
  (cond [(zero? n) 1]
        [else (* n (fact (- n 1)))]))

Applications and practical use

Apart from having a basis in programming language theory, Racket was designed to be used as a general-purpose language in production systems. Thus, the Racket distribution features an extensive library that covers systems and network programming, web development,[43] a uniform interface to the underlying operating system, a dynamic foreign function interface,[44] several flavours of regular expressions, lexer/parser generators,[42] logic programming, and a complete GUI framework.

Racket has several features useful for a commercial language, among them an ability to generate standalone executables under Windows, Mac OS X and Unix, a profiler and debugger included in the integrated development environment (IDE), and a unit testing framework.

Racket has been used for commercial projects and web applications. A notable example is the Hacker News website, which runs on Arc, which is developed in Racket. Naughty Dog has used it as a scripting language in several of their video games.[45]


  1. ^ Racket blog, [1]
  2. ^ Strickland, T.S.; Fellesisen, Matthias (2010). "DLS 2010: Contracts for First-Class Classes". 
  3. ^ Sperber, Michael; Dybvig, R. Kent; Flatt, Matthew; Van Straaten, Anton, et al. (August 2007). Report on the Algorithmic Language Scheme (R6RS)"6"Revised. Scheme Steering Committee. Retrieved 2011-09-13. 
  4. ^ Bonnaire-Sergeant, Ambrose (2012). A Practical Optional Type System for Clojure (Thesis). The University of Western Australia. 
  5. ^ "Welcome to Racket". Retrieved 2011-08-15. 
  6. ^ "Dialects of Racket and Scheme". Retrieved 2011-08-15. 
  7. ^ a b Flatt; Findler; Krishnamurthi; Felleisen (1999). "Programming Languages as Operating Systems (or, Revenge of the Son of the Lisp Machine)". 
  8. ^ a b c Findler; Clements; Flanagan; Flatt; Krishnamurthi; Steckler; Felleisen (2001). "DrScheme: A Programming Environment for Scheme". Journal of Functional Programming. 
  9. ^ Felleisen; Findler; Flatt; Krishnamurthi (2004). "The TeachScheme! Project: Computing and Programming for Every Student". Journal of Computer Science Education. 
  10. ^ "Overview". Program by Design. Retrieved 2011-08-17. 
  11. ^ "Macros Matter". 2007-05-03. Retrieved 2011-08-08. 
  12. ^ a b c Flatt, M.; Findler, R. B.; Felleisen, M. (2006). "Asian Symposium on Programming Languages and Systems". 
  13. ^ a b Flatt, M.; Felleisen, M. (1998). "Programming Language Design and Implementation". 
  14. ^ a b c d Tobin-Hochstadt, S.; St-Amour, V.; Culpepper, R.; Flatt, M.; Felleisen, M. (2011). "Programming Language Design and Implementation". 
  15. ^ Benson, Brent W. Jr. (October 26–28, 1994). Written at Santa Fe, NM. "Proceedings of the USENIX Symposium on Very High Level Languages". Berkeley, CA: USENIX Association. pp. 7–19.  
  16. ^ a b c "Rebuilding Racket's Graphics Layer". 2010-12-08. Retrieved 2011-08-23. 
  17. ^ Clements, J.; Flatt, M.; Felleisen, M. (2001). "European Symposium on Programming Languages". 
  18. ^ a b c "Racket Core Release Notes". Retrieved 2012-04-15. 
  19. ^ Flatt, M. (2002). "International Conference on Functional Programming". 
  20. ^ "PLT Scheme version 4.0". 2008-06-12. Retrieved 2012-08-07. 
  21. ^ "From PLT Scheme to Racket". Retrieved 2011-08-17. 
  22. ^ "Racket 5.2". PLT, Inc. 2011-11-09. Retrieved 2012-06-16. 
  23. ^ "Submodules". 2012-06-03. Retrieved 2012-08-07. 
  24. ^ "Racket 5.3". PLT, Inc. 2012-08-07. Retrieved 2012-08-07. 
  25. ^ "Racket 5.3.1". PLT, Inc. 2012-11-07. Retrieved 2012-11-07. 
  26. ^ Flatt, M.; Yu, G.; R. B.; Felleisen, M. (2007). "International Conference on Functional Programming". 
  27. ^ "Contracts". 
  28. ^ "Threads". 
  29. ^ "Futures". 
  30. ^ "Places". 
  31. ^ Flatt, Matthew (2012). "Creating Languages in Racket". Communications of the ACM. Retrieved 2012-04-08. 
  32. ^ Findler, R. B.; Felleisen, M. (2002). "International Conference on Functional Programming". 
  33. ^ Matthews, J. (2006). "Scheme and Functional Programming Workshop". 
  34. ^ Flatt, Matthew (2002). "International Conference on Functional Programming". 
  35. ^ Flatt, Culpepper, Darais, Findler, Macros that Work Together; Compile-Time Bindings, Partial Expansion, and Definition Contexts
  36. ^ Tobin-Hochstadt, S.; Felleisen, M. (2008). "Principles of Programming Languages". 
  37. ^ Barzilay, E.; Clements, J. (2005). "Functional and Declarative Programming in Education". 
  38. ^ Flatt, M.; Barzilay, E.; Findler, R. B. (2009). "International Conference on Functional Programming". 
  39. ^ Findler, R. B.; Flatt, M. (2004). "International Conference on Functional Programming". 
  40. ^ Felleisen, M.; Findler, R. B.; Flatt, M.; Krishnamurthi, S. (2009). "International Conference on Functional Programming". 
  41. ^ Felleisen, M.; Findler, R. B.; Flatt, M.; Krishnamurthi, S. (2004). "The Structure and Interpretation of the Computer Science Curriculum". Journal of Functional Programming. 
  42. ^ a b "Parser Tools: lex and yacc-style Parsing". Retrieved 2011-08-16. 
  43. ^ a b Krishnamurthi, Hopkins; McCarthy; Graunke; Pettyjohn; Felleisen (2007). "Implementation and Use of the PLT Scheme Web Server". Journal of Higher-Order and Symbolic Programming. 
  44. ^ Barzilay, E.; Orlovsky, D. (2004). "Scheme and Functional Programming". 
  45. ^ "Functional mzScheme DSLs in Game Development". Retrieved 2012-05-08. 

Further reading

  • Felleisen et al., 2013. Realm of Racket. No Starch Press.
  • Felleisen et al., 2003. How to Design Programs. MIT Press.

External links


  • Quick: An Introduction to Racket with Pictures
  • F*dging up a Racket—shows how to write a Brainfuck dialect for Racket
  • Raw strings in Racket—a reader extension for raw strings

Style guide

  • How to Program Racket

Website and documentation

  • Official website
  • Blog
  • Code Repository
  • PLaneT
  • The Racket Guide
  • The Racket Reference
  • All Racket Documentation
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.

Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.