Racket (programming language)

Source: Wikipedia, the free encyclopedia.
Racket
Developer
PLT Inc.
First appearedJanuary 28, 1995; 29 years ago (1995-01-28)
Stable release
8.12[1] Edit this on Wikidata
/ 8 February 2024; 2 months ago (8 February 2024)
Apache 2.0[2]
Filename extensions.rkt[3]
Websiteracket-lang.org
Major implementations
Racket, RacketScript Racket to JavaScript (ES6) compiler, Pycket a Racket implementation using RPython.
Dialects
Typed Racket, FrTime, Lazy Racket, Scribble
Influenced by
Eiffel,[4] Scheme
Influenced
Clojure,[5] Rust,[6][7] Scheme (R6RS)[8]

Racket is a

multi-paradigm programming language and a multi-platform distribution that includes the Racket language, compiler, large standard library, integrated development environment (IDE), development tools, and a set of additional languages including Typed Racket (a sister language of Racket with a static type-checker), Swindle, FrTime, Lazy Racket, R5RS & R6RS Scheme, Scribble, Datalog, Racklog, ALGOL 60
and several teaching languages.

The Racket language is a modern dialect of

education, and research.

The Racket platform provides an implementation of the Racket language (including a

The core Racket language is known for its extensive

The platform distribution is

MIT licenses.[20] Extensions and packages written by the community may be uploaded to Racket's package catalog
.

History

Development

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,[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 for soft 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 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.

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.

Version history

The first generation of PLT Scheme revisions introduced features for

interfaces) 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.

first-class objects
.

Version 300 introduced

generational garbage collection
.

By the next major release, the project had switched to a more conventional

On 7 June 2010, PLT Scheme was renamed Racket.

syntax 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] new optimization tools, a JSON 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 a minimal 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 the Chez 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 2021 February 13, Racket 8.0 was released. Racket 8.0 marks the first release where Racket with the Chez 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]

Features

Racket's core language includes

OS 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 an operating 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 a mixin class system,[16] a component (or module) system as expressive as opaque ascription in the ML module system,[17] and pattern matching
.

Further, the language features the first contract system for a higher-order programming language.[44] 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 ensured to make contract checks when its methods are eventually invoked.

Racket includes both bytecode and JIT (JIT) compilers. The bytecode compiler produces an internal bytecode format run by the Racket virtual 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 that third-party libraries can be transparently imported and used. Also, PLaneT has a built-in versioning policy to prevent dependency 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 named raco. 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]

Integrated language extensibility and macros

The features that most clearly distinguish Racket from other languages in the Lisp family are its integrated language

domain-specific and general-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 of function 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 a

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

untyped to typed code,[49] Lazy Racket—a dialect with lazy evaluation,[50] and Hackett, which combines Haskell and Racket.[51] The pedagogical programming language Pyret 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 to s-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] See Racket logic programming for an example of such a language.

Programming environment

The language platform provides a

command-line arguments
and execute external tools.

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

refactoring
support. It provides integrated, context-sensitive access to an extensive hyper-linked help system named "Help Desk".

DrRacket is available for Windows, macOS, Unix, and Linux with the X Window System and programs behave similarly on all these platforms.

Code examples

Here is a trivial "Hello, World!" program:

#lang racket
"Hello, World!"

Running this program produces the output:

"Hello, World!"

Here is 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)
  (if (zero? n) 1 (* n (fact (- n 1)))))

Implementations

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 the Chez Scheme incremental compiler and runtime. The alternate implementation generates platform-independent bytecode and uses Just-in-time compilation to generate machine code as it is loaded.[60]

In addition, there are experimental implementations:

  • RacketScript is an experimental Racket to JavaScript (ES6) compiler. It allows programmers to use both JavaScript’s and Racket’s ecosystem and aims to make this interoperability as smooth as possible.[61]
  • Pycket is a Racket implementation generated using the RPython framework.[62]

Applications and practical use

Apart from having a basis in

GUI
framework.

Racket has several features useful for a commercial language, among them an ability to compile standalone executables under Windows, macOS, 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 video games.[64]

Racket is used to teach students algebra through game design in the Bootstrap program.[65]

References

  1. ^ Error: Unable to display the reference properly. See the documentation for details.
  2. ^ Tobin-Hochstadt, Sam; Gerard, Sage; Dueck, Joel; Flatt, Matthew; Software Freedom Conservancy; Chestek, Pamela (2019-11-15). "Completing Racket's relicensing effort". Retrieved 2019-12-27.
  3. ^ "DrRacket Files". Retrieved 21 July 2019. The standard file extension for a Racket program file is ".rkt". The extensions ".ss", ".scm", and ".sch" are also historically popular.
  4. ^ Strickland, T.S.; Fellesisen, Matthias (2010). "DLS 2010: Contracts for First-Class Classes" (PDF).
  5. ^ Bonnaire-Sergeant, Ambrose (2012). A Practical Optional Type System for Clojure (Thesis). The University of Western Australia.
  6. ^ "Planet2 questions".
  7. ^ "Rust Bibliography". GitHub. 23 November 2022.
  8. ^ Sperber, Michael; Dybvig, R. Kent; Flatt, Matthew; Van Straaten, Anton; et al. (August 2007). "Revised6 Report on the Algorithmic Language Scheme (R6RS)". Scheme Steering Committee. Retrieved 2011-09-13.
  9. ^ a b Felleisen, M.; Findler, R.B.; Flatt, M.; Krishnamurthi, S.; Barzilay, E.; McCarthy, J.; Tobin-Hochstadt, S. (2015). "The Racket Manifesto" (PDF). Proceedings of the First Summit on Advances in Programming Languages: 113–128.
  10. ^ "Dialects of Racket and Scheme". Retrieved 2011-08-15.
  11. ^ "Welcome to Racket". Retrieved 2019-05-15.
  12. ^ a b Flatt; Findler; Krishnamurthi; Felleisen (1999). Programming Languages as Operating Systems (or, Revenge of the Son of the Lisp Machine). International Conference on Functional Programming.
  13. ^ a b c Findler; Clements; Flanagan; Flatt; Krishnamurthi; Steckler; Felleisen (2001). "DrScheme: A Programming Environment for Scheme" (PDF). Journal of Functional Programming.
  14. ^ Felleisen; Findler; Flatt; Krishnamurthi (2004). "The TeachScheme! Project: Computing and Programming for Every Student". Journal of Computer Science Education.
  15. ^ "Overview". Program by Design. Retrieved 2011-08-17.
  16. ^ a b c Flatt, M.; Findler, R. B.; Felleisen, M. (2006). "Scheme with Classes, Mixins, and Traits" (PDF). Asian Symposium on Programming Languages and Systems.
  17. ^ a b Flatt, M.; Felleisen, M. (1998). "Units: Cool Modules for Hot Languages". Programming Language Design and Implementation.
  18. ^ a b c d Tobin-Hochstadt, S.; St-Amour, V.; Culpepper, R.; Flatt, M.; Felleisen, M. (2011). "Languages as Libraries" (PDF). Programming Language Design and Implementation.
  19. S2CID 3887010
    .
  20. ^ "Racket: Software License". Retrieved 2015-10-20.
  21. . Retrieved 7 July 2013.
  22. ^ a b c "Rebuilding Racket's Graphics Layer". 2010-12-08. Retrieved 2017-12-11.
  23. ^ Clements, J.; Flatt, M.; Felleisen, M. (2001). "Modeling an Algebraic Stepper" (PDF). European Symposium on Programming Languages.
  24. ^ a b c "Racket Core Release Notes". Archived from the original on 2013-07-05. Retrieved 2012-04-15.
  25. ^ Flatt, M. (2002). "Composable and Compilable Macros". International Conference on Functional Programming.
  26. ^ "PLT Scheme version 4.0". 2008-06-12. Archived from the original on 2013-02-02. Retrieved 2012-08-07.
  27. ^ "From PLT Scheme to Racket". Racket-lang.org. Retrieved 2011-08-17.
  28. ^ "Racket 5.2". PLT, Inc. 2011-11-09. Retrieved 2012-06-16.
  29. ^ "Submodules". 2012-06-03. Retrieved 2012-08-07.
  30. ^ "Racket 5.3". PLT, Inc. 2012-08-07. Retrieved 2012-08-07.
  31. ^ "Racket 5.3.1". PLT, Inc. 2012-11-07. Retrieved 2012-11-07.
  32. ^ "Racket 6.0". PLT, Inc. 2014-02-26. Retrieved 2016-02-23.
  33. ^ "Racket-on-Chez Status: January 2018". 2018-01-05. Archived from the original on 2018-06-28. Retrieved 2018-04-13.
  34. ^ "building Racket on Chez Scheme (Experience Report)" (PDF). 2019-08-01. Retrieved 2019-07-25.
  35. ^ "Racket 7.5 release". Packt Hub. 22 November 2019. Retrieved 2019-11-28.
  36. ^ "Racket v7.5". Racket | Blog. Retrieved 2019-11-28.
  37. ^ "Racket v8.0".
  38. ^ Flatt, M.; Yu, G.; Findler, R. B.; Felleisen, M. (2007). "Adding Delimited and Composable Control to a Production Programming Environment" (PDF). International Conference on Functional Programming.
  39. ^ "Contracts".
  40. ^ "Threads".
  41. ^ "Futures".
  42. ^ "Places".
  43. ^ Flatt, Matthew (2012). "Creating Languages in Racket". Communications of the ACM. Retrieved 2012-04-08.
  44. ^ Findler, R. B.; Felleisen, M. (2002). "Contracts for Higher-Order Functions" (PDF). International Conference on Functional Programming.
  45. ^ Matthews, J. (2006). "Component Deployment with PLaneT: You Want it Where?". Scheme and Functional Programming Workshop.
  46. ^ "The Racket package system and Planet".
  47. ^ Flatt, Matthew (2002). "Composable and Compilable Macros, You Want it When?" (PDF). International Conference on Functional Programming.
  48. ^ Flatt, Culpepper, Darais, Findler, Macros that Work Together; Compile-Time Bindings, Partial Expansion, and Definition Contexts
  49. ^ Tobin-Hochstadt, S.; Felleisen, M. (2008). "The Design and Implementation of Typed Scheme". Principles of Programming Languages.
  50. ^ Barzilay, E.; Clements, J. (2005). "Laziness Without All the Hard Work: Combining Lazy and Strict Languages for Teaching". Functional and Declarative Programming in Education.
  51. ^ "The Hackett Programming Language". Alexis King's Blog. Retrieved 16 June 2019.
  52. ^ The Pyret Crew (24 May 2011). "The Pyret Code; or A Rationale for the Pyret Programming Language". Pyret. Retrieved 16 June 2019.
  53. ^ "Programming and Programming Languages". Index of /. 20 September 2017. Retrieved 16 June 2019.
  54. ^ Flatt, M.; Barzilay, E.; Findler, R. B. (2009). "Scribble: Closing the Book on Ad Hoc Documentation Tools". International Conference on Functional Programming.
  55. ^ Findler, R. B.; Flatt, M. (2004). "Slideshow: Functional Presentations". International Conference on Functional Programming.
  56. ^ Felleisen, M.; Findler, R. B.; Flatt, M.; Krishnamurthi, S. (2009). "A Functional I/O System (or Fun for Freshman Kids)" (PDF). International Conference on Functional Programming.
  57. .
  58. ^ a b "Parser Tools: lex and yacc-style Parsing". Retrieved 2011-08-16.
  59. ^
    S2CID 17731194
    .
  60. ^ Implementations
  61. ^ RacketScript
  62. ^ Pycket
  63. ^ Barzilay, E.; Orlovsky, D. (2004). "Foreign Interface for PLT Scheme" (PDF). Scheme and Functional Programming.
  64. ^ "Functional mzScheme DSLs in Game Development". Retrieved 2012-05-08.
  65. ^ "Bootstrap". bootstrapworld.org. Retrieved 2015-08-11.

Further reading

External links