Racket
Racket
donate
docs
packages
Racket version 9.1
is available.
Racket, the Programming Language
#lang racket/gui
define
my-language 'English)
define
translations
#hash([Chinese . "你好 世界"]
[English . "Hello world"]
[French . "Bonjour le monde"]
[German . "Hallo Welt"]
[Greek . "Γειά σου, κόσμε"]
[Portuguese . "Olá mundo"]
[Spanish . "Hola mundo"]
[Thai . "สวัสดีชาวโลก"]
[Turkish . "Merhaba Dünya"]))
define
my-hello-world
hash-ref
translations my-language
"hello world"))
message-box
"" my-hello-world)
Mature
Racket is a mature and stable product. From the beginning, it has supported cross-platform graphical programming (Windows, macOS, Linux).
Package System
GUI Framework
Standalone Binaries
Foreign Interface
Practical
Racket includes a rich set of libraries, covering the full range from web server apps to mathematics and scientific simulation software.
Web Applications
Database
Math & Statistics
Full List →
Extensible
In Racket, programmers define their own loops with
powerful macros
. Indeed, these macros are so powerful that programmers make entire
domain-specific languages
as libraries. No tools, no Makefiles required.
Intro To Macros
Macros In Depth
Making New Languages
Sample #Langs
Robust
Racket is the first language to support
higher-order software contracts
and
safe gradual typing
. Programmers can easily deploy these tools to harden their software.
The Contract Guide
High-Order Contracts
The Typed Racket Guide
Gradual Typing
Polished
Racket comes with support for major editors. The main bundle includes an innovative and extensible interactive development environment that has inspired other IDE projects.
DrRacket Guide
VS Code/Magic Racket
Emacs Integration
Vim Integration
Racket, the Language-Oriented Programming Language
#lang typed/racket
;; Using higher-order occurrence typing
define-type
SrN (
String
Number
))
tog ((
Listof
SrN) ->
String
))
define
(tog l)
apply
string-append
filter
string?
l)))
(tog (
list
5 "hello "
1/2 "world" (
sqrt
-1)))
#lang scribble/base
@; Generate a PDF or HTML document
@(
require
only-in
racket ~a))
@(
define
N 99)
title
{Bottles: @
italic
{Abridged}}
@(
apply
itemlist
for/list
([n (
in-range
N 0 -1)])
item
{@(
~a
n) bottles.}))
#lang datalog
ancestor(A, B)
:-
parent(A, B).
ancestor(A, B)
:-
parent(A, C), ancestor(C, B).
parent(john, douglas).
parent(bob, john).
ancestor(A, B)?
Little Macros
#lang racket
provide
time-it)
require
for-syntax
syntax/parse))
define-syntax
(time-it stx)
syntax-parse
stx
[(_ task)
#'(thunk-time-it (
() task))]))
define
(thunk-time-it task)
define
before (cim))
define
answer (task))
define
delta (- (cim) before))
printf
"time: ~a ms\n" delta)
answer)
define
cim current-inexact-milliseconds)
Racket allows programmers to
add new syntactic constructs
in the same way that other languages permit the formulation of procedures, methods, or classes. All you need to do is formulate a simple rule that rewrites a custom syntax to a Racket expression or definition.
Little macros can particularly help programmers with DRY where other features can’t. The example
on the left
above
shows how to define a new syntax for measuring the time a task takes. The syntax avoids the repeated use of lambda. Note also how the macro is exported from this module as if it were an ordinary function.
General Purpose
#lang racket/gui
;; let's play a guessing game
define
frame (
new
frame%
[label "Guess"]))
define
secret (
random
5))
define
((check i) btn evt)
define
found? (
if
i secret) "Yes" "No"))
message-box
"?" found?)
when
i secret)
send
frame show #false)))
for
([i (
in-range
5)])
new
button%
[label (
~a
i)]
[parent frame]
[callback (check i)]))
send
frame show #t)
Racket comes with a comprehensive suite of libraries:
a cross-platform GUI toolbox
, a
web server
, and more.
Thousands of additional packages
are a
single command
away: 3D graphics, a bluetooth socket connector, color maps, data structures, educational software, games, a quantum-random number generator, scientific simulations, web script testing, and many more.
Macros work with these tools. The example
on the left
above
shows the implementation of a small number-guessing game. It is implemented in the GUI dialect of Racket, and demonstrates a number of language features.
Big Macros
Getting to know the full Racket macro system will feel liberating, empowering, dazzling—like a whole new level of enlightenment. Developers can easily create a collection of co-operating macros to implement
algebraic pattern matching
, simple
event-handling
, or a
logic-constraint solver
While Racket is a functional language, it has offered a sub-language of
classes and objects, mixins and traits
, from the beginning. The macro-based implementation of a Java-like class system lives in a library and does not need any support from the core language. A Racket programmer can thus combine functional with object-oriented components as needed.
Easy DSLs
Some languages convey ideas more easily than others. And some programming languages convey solutions better than others. Therefore Racket is a language for
making languages
, so that a programmer can write every module in a well-suited language.
Often
an application domain
comes with several languages. When you need a new language, you make it—on the fly. Open an IDE window; create a language right there, with just a few keystrokes; and run a module in this new language in a second IDE window. Making new languages really requires no setup, no project files, no external tools, no nothing.
IDE Support
Racket comes with its own IDE,
DrRacket
née DrScheme
), and it sports some unique features. For example, when a programmer mouses over an identifier, the IDE draws an arrow back to where it was defined.
A programmer immediately benefits from DrRacket while using an alternative language, say
Typed Racket
. Racket macros, even complex ones and those used to make new languages, record and propagate a sufficient amount of source information for DrRacket to act as if it understood the features of the new language.
Any Syntax
Racket programmers usually love parentheses, but they have empathy for those who need commas and braces. Hence, building languages with conventional surface syntax, like that of
datalog
, is almost as easy as building parenthetical languages.
Racket’s ecosystem comes with
parsing packages
that allow developers to easily map any syntax to a parenthesized language, which is then compiled to ordinary Racket with the help of Racket’s macro system. Such a language can also exploit the hooks of the IDE framework, so that its programmers may take advantage of Racket’s IDE.
Racket, the Ecosystem
Software
Software
Download Racket
Source Code
Bug Reports
Nightly Snapshot Builds
Packages
Tutorials & Documentation
Tutorials & Documentation
Quick Introduction
Systems Programming
The Racket Guide
The Racket Reference
Web Applications
All Documentation
Community
Community
Discourse
and
Discord
These are the most active places for Racketeers.
Slack
),
Reddit
, and
Mailing lists
Racketeers are here, too!
Mastodon
, and
Blog
Keep in touch.
Wiki
and
Learn more from articles and talks.
Team
and
Contributing
Racket’s development benefits from a large distributed pool of contributors.
Friendly Environment Policy
Applies to all Racket venues.
Racket Programming Language Foundation
Make a tax-deductible contribution to support our work.
Books
Books
The Racket Guide
A detailed overview of the Racket Language.
Realm of Racket
Learn to program with Racket, one game at a time.
Beautiful Racket
Make your own programming languages with Racket.
Server: Racket
Develop a web application with Racket.
All Racket Books
Education
Education
The Racket Summer School
a summer school for researchers, professionals, and (under)graduate students to the Racket philosophy of programming languages
Program by Design (aka TeachScheme!)
a curriculum and training program for high school teachers and college faculty
Bootstrap
a curriculum and training program for middle-school and high-school teachers
Swag
Swag
Racket T-Shirts
— the perfect way to meet friends, influence people, and stay warm.
Racket Stickers
— the indispensable accessory for laptops and textbooks.
Thank you
To
the NSF
DARPA
the
Fund for the Improvement of Postsecondary Education (FIPSE)
at the
US Department of Education
the
Exxon Foundation
CORD, partners of the Academy of Information Technology,
Microsoft
Mozilla
Google
and many
individuals
for their generous support over the years.
US