03 Mar 2017

Languages as Dotfiles

posted by Leif Andersen and Ben Greenman

Tired of writing (require (for-syntax syntax/parse)) at the top of your Racket programs? This post shows how to make a #lang to customize your default programming environment.

more →

05 Feb 2017

On Application

posted by Jack Firth

Today I wanted to write about function application. Specifically, how to redefine and customize application with Racket. We’ll also look at some Racket packages that define interesting and useful forms of function application.

The theory

Application is the process of combining a function and arguments to evaluate a result. Application defines one half of lambda calculus, the formal model underlying much of modern functional programming. The other half is abstraction, which is creating new functions. Creating and applying functions is the heart of Racket and many other functional languages.

So how are functions applied in Racket? What makes (if (< 5 10) 'foo 'bar) a macro use and (< 5 10) a function use?

That’s actually a trick question, because function application is a macro in Racket. During macro expansion, the Racket expander inspects the first element of an expression to determine if it has a binding to a macro. If it doesn’t, rather than assume the expression is a function application, the expander inserts an artificial identifier named #%app into the expression. So in the above example, the expression (< 5 10) is converted to (#%app < 5 10). This #%app identifier doesn’t refer to a single specific #%app like the if refers to if from racket/base, rather it refers to whatever the enclosing environment defines #%app to be (which by default means ordinary function application from racket/base).

However, imported modules can provide their own definitions of function application by providing an #%app macro. Let’s define our own #%app that, in addition to applying a function, prints out a trace message. First let’s define a helper function to implement the tracing:

more →

24 Jan 2017

Racket v6.8

posted by Vincent St-Amour

Racket version 6.8 is now available from http://racket-lang.org/

  • Racket sports a new logo, courtesy of Matthew Butterick.

  • MacBook Pro laptops with touch bars are supported.

  • Support for FreeBSD on PowerPC.

  • Initial support for GTK3 on Wayland is available. GL contexts, GC blits, and dialog placement currently do not work.

  • The macro stepper provides a command-line interface via the raco macro-stepper command.

  • Typed Racket more efficiently represents and computes types and propositions, resulting in faster type checking for many programs. For more details, see this blog post by Andrew Kent.

  • The bytecode optimizer can reduce more expressions of the form (equal? x y) to (eqv? x y) or (eq? x y) when the type of x or y is known.

  • The bytecode optimizer avoids dropping stack frames in some reductions. This provides better stack traces for errors when errotrace is enabled.

  • The bytecode compiler detects more optimization opportunities, including when variables always hold a boolean value. In particular in expressions like (or (symbol? x) (something)), the optimizations avoid the creation of an intermediate variable to store the result of (symbol? x).

  • The syntax form preserves syntax properties on all template pieces.

  • The scribble/html/extra module provides renderers for HTML elements that are part of the WHATWG HTML standard but not part of the scribble/html language by default (e.g., map, time, video).

  • The DeinProgramm teaching languages support pattern matching using the match form.

  • In the DeinProgramm languages, define-record-procedures supports specifying signatures as part of the form, instantly enabling properties quantifying over such records.

The following people contributed to this release:

Aleksej Saushev, Alex Knauth, Alexander Hedges, Alexander Shopov, Alexis King, Andrew Kent, Asumu Takikawa, Ben Greenman, Celeste Hollenbeck, Craig Allen, Don March, Georges Dupéron, Gustavo Massaccesi, James Bornholt, Jay McCarthy, Jerry James, John Clements, Juan Francisco Cantero Hurtado, Leandro Facchinetti, Leif Andersen, Matthew Butterick, Matthew Flatt, Matthias Felleisen, Max New, Mike Sperber, Phil Nguyen, Reid D McKenzie, Reuben Thomas, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Shu-Hung You, Spencer Florence, Stephen Chang, Tim Brown, Tony Garnock-Jones, Vincent St-Amour, WarGrey Gyoudmon Ju, and William G Hatch.

Feedback Welcome

more →

20 Jan 2017

(seventh RacketCon)

posted by Vincent St-Amour


(seventh RacketCon) will be held on October 7th, followed by Racketeer Office Hours on October 8th. This year, RacketCon will be in Seattle, WA, with support from the Racket group at the University of Washington.

RacketCon is a yearly event where members of the Racket community get together, featuring talks and demos about the things you do with Racket.

Racketeer Office Hours is a new event that we’re trying out this year. It is a free-form day for Racketeers to get together and collaborate on ongoing projects, start new ones, and get help and advice from other members of the community.

Registration is not open yet, but we’ll let you know when it is.

See you in Seattle!

Vincent St-Amour, Matthew Butterick, and Matthew Flatt with help from Emina Torlak and Amanda Robles at UW

more →

14 Dec 2016

The redesigned Racket blog

posted by Matthew Butterick

I love Racket. But a few months ago, I really wanted to kill this blog.

Why? Because who reads blogs, right? It’s like getting 4% interest on your savings — so 2006. This is Racket. We’re from the future. No, really. We even have a futures visualizer. Take a look. Do you visualize any blogs?

But my amigo Sam Tobin-Hochstadt had some wise words. “MB,” he said, “we’re not killing the blog. But tell you what: we’ll let you redesign it.”

“OK! Yeah! I’ll show you!”

And this is really Sam’s genius. After you talk to him, not only have you entirely changed your mind, you’ve volunteered to do all the work.

But man, blogs. Have you seen the first blog ever, from 1994? Good news — it’s still online. For the first couple years they were known as personal websites. Then they were called weblogs. Then just blogs. For a while after that, it seemed like everyone was starting a blog. Then everyone was redesigning a blog. Then everyone was ignoring a blog.

Racket didn’t have an official blog back then — this one was started in 2007 — but there are some interesting blog-like records in the archives. For instance, the HISTORY.txt file in the main repo. It chronicles every release back to version 0.27, in September 1995. AFAIK that code is still used today.

Today, blogging persists. But most of today’s tools are calculated to make it as easy as possible. Too easy, perhaps? Not to sound curmudgeonly. But to my mind, the diaristic aspects of blogs were always incidental. Their most important purpose was to give millions of nerds a pretext to learn about web technology. In the ’70s, these nerds were typing out BASIC computer games. These days, I suppose they’re all writing their own JavaScript front-end frameworks. Ten years from now, what — harvesting dilithium crystals in the delta quadrant? (I’m being coy. I do have a futures visualizer.)

So, the Racket blog. My major objection is that until yesterday, it was built on the moldering skeleton of Blogger, which has, against all odds, stumbled into this century. Merely a small cut above Geocities. Surely we Racketeers could do better.

I turned to Greg Hendershott’s static-blog engine Frog. A very slick Racket package that turns Markdown source files into HTML. If you must blog — please try it.

The rest of the design draws on the typography & color themes I used for the Racket documentation — still the best-looking docs in the business. For the headlines, I added something new — the Cooper Hewitt typeface, designed for the namesake Smithsonian museum. Very lovely and totally free.

Thank you to Sam Tobin-Hochstadt, Greg Hendershott, Vincent St-Amour, and Robby Findler for helping me complete this project. As Matthias Felleisen did in his first post for this blog, I dedicate my work “to all things macros and everything else that matters in Racket.”

PS. I did succeed in killing the comments form. Not everything from the ’90s needs to be preserved.

more →

26 Oct 2016

Racket v6.7

posted by Vincent St-Amour

Racket version 6.7 is now available from http://racket-lang.org/

  • Racket supports building graphical applications on Android through the racket-android project: https://github.com/jeapostrophe/racket-android

  • The Racket REPL comes with line-editing, command and result history, and various meta-commands out of the box, via the racket/interactive module. See the racket/interactive and xrepl documentation for details.

  • The package system supports authentication when installing packages from git, using the raco pkg config git-checkout-credentials configuration option.

  • HTTP libraries, as well as raco pkg, support proxying via HTTP CONNECT.

  • Typed Racket provides typed versions of racket/os and racket/db/sqlite.

  • The PLT_COMPILED_FILE_CHECK environment variable provides more fine-grained control over when .zo files are consulted.

  • The documentation search supports searching for #langs and #readers via the “L:” and “R:” search prefixes.

  • The file/glob module implements globbing for path-strings.

  • Optimizations in the bytecode compiler improve performance for structure, list, string, and byte-string operations.

The following people contributed to this release:

Alex Knauth, Alex Harsanyi, Alexis King, Andrew Kent, Asumu Takikawa, Ben Greenman, Brian Lachance, Chongkai Zhu, Daniel Feltey, Georges Dupéron, Gustavo Massaccesi, Jay McCarthy, John Clements, Jonathan Schuster, Leif Andersen, Marc Burns, Matthew Butterick, Matthew Flatt, Matthias Felleisen, Mike Sperber, Robby Findler, Rohin Shah, Ryan Culpepper, Sam Tobin-Hochstadt, Spencer Florence, Stephen Chang, Stephen De Gabrielle, Tim Brown, Tony Garnock-Jones, Vincent St-Amour, WarGrey Gyoudmon Ju, and William J. Bowman.

Feedback Welcome

more →

22 Jul 2016

Racket v6.6

posted by Vincent St-Amour

Racket version 6.6 is now available from http://racket-lang.org/

  • The new Macro Profiler command-line tool (raco macro-profiler) shows how macros contribute to the final expanded code size of a program.

  • Typed Racket supports intersection types. This allows the type system to track more information, and for programmers to express more precise types.

  • Typed Racket produces up to 4x smaller compiled files compared with Racket 6.5, reducing the size of the Racket distribution by 50M.

  • Typed Racket issues warnings in cases where the contract generated for Any was not strict enough in the past. These warnings will become errors in a future release. Warnings are enabled via View -> Show Log in DrRacket, and shown by default on command-line Racket.

  • Typed Racket enforces uses of cast more correctly, by checking both the “casted-to” and “casted-from” types. Previously, only the former were checked. In some cases, this will produce contract errors in programs that did not have errors before.

  • syntax-parse raises an error when an ellipsis pattern has an empty match rather than diverging, and it logs a warning when it statically detects a nullable pattern, such as ((~seq) ...). In the next version of Racket, it will reject the pattern instead, and it will remove special handling that currently makes some uses of such patterns terminate.

  • htdp/dir: The create-dir function delivers data information for files in a new field. The domain of its functions are backwards compatible.

The following people contributed to this release:

Alex Knauth, Alexander Shopov, Alexis King, Andrew Kent, Asumu Takikawa, Ben Greenman, Bernardo Sulzbach, Brian Lachance, Chris Jester-Young, Dan Feltey, Eric Dobson, Georges Dupéron, Gustavo Massaccesi, James Bornholt, Jay McCarthy, John Clements, Leandro Facchinetti, Leif Andersen, Maksim Kochkin, Matthew Flatt, Matthias Felleisen, Mike Sperber, Paul Stansifer, Pedro Caldeira, Philip McGrath, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Spencer Florence, Stephen Chang, Stephen De Gabrielle, Tim Brown, Tony Garnock-Jones, Vincent St-Amour, WarGrey Gyoudmon Ju, William J. Bowman, and Zeina Migeed.

Feedback Welcome

more →

28 Apr 2016

Racket v6.5

posted by Ryan Culpepper

Racket version 6.5 is now available from http://racket-lang.org/

  • Typed Racket and the racket/contract library generate code with lower overhead, speeding up typed/untyped interaction in a number of gradual typing programs we studied.

  • Macros written using syntax-parse automatically emit more accurate error messages.

  • The contract profiler captures costs from more contract combinators, including all those in the main distribution.

  • Hash table and set iteration, via both existing and new non-generic sequences, performs better, up to twice as fast on microbenchmarks.

  • The Racket optimizer detects many more optimization opportunities, including when variables always hold numbers.

  • The db library supports single-result CALL statements in MySQL.

  • The net/dns library supports SRV records.

  • The racket/unix-socket library supports listen and accept operations.

The following people contributed to this release:

Adrien Tateno, Alex Knauth, Alexander Shopov, Alexis King, Andrew Kent, Asumu Takikawa, Ben Greenman, Chen Xiao, Chris Jester-Young, Daniel Feltey, Eric Dobson, Georges Dupéron, Gustavo Massaccesi, Ian Harris, Jay McCarthy, Jens Axel Søgaard, John Clements, Leandro Facchinetti, Lehi Toskin, Leif Andersen, Łukasz Dąbek, Marc Kaufmann, Matthew Flatt, Matthias Felleisen, Michael McConville, Mike Sperber, Paul Stansifer, Philippe Meunier, Robby Findler, Rodrigo Setti, Ryan Culpepper, Sam Caldwell, Sam Tobin-Hochstadt, Sorawee Porncharoenwase, Spencer Florence, Stephen Chang, Tony Garnock-Jones, Vincent St-Amour, WarGrey Gyoudmon Ju, and William J. Bowman.

Feedback Welcome

more →

08 Feb 2016

Racket Web Server Security Vulnerability

posted by Sam Tobin-Hochstadt

We recently discovered a serious security vulnerability in the Racket web server, which can lead to unintended disclosure of files on the machine running the web server. This vulnerability is fixed in Racket version 6.4, just released, and we encourage people to upgrade to that version.

The vulnerability affects web servers that serve static files using the #:extra-files-paths option, including the default value of this option. If you do not use the Racket web serve to serve static files, or you do so via a mechanism that does not use the make-url->path function, then you are likely not vulnerable. Affected web serves will allow specially-crafted URLs to access files outside of the specified paths, potentially exposing any file that the web server process is able to read.

If you cannot immediately upgrade to version 6.4, we have provided a package catalog with updated versions of the “web-server-lib” package for versions of Racket back to 6.0. That catalog is located at


To use it to upgrade your Racket installation, add it as a catalog using raco pkg config. To make this process easier, you can download the Racket script available here. Then run:

$ racket add-catalog.rkt
$ raco pkg update -i web-server-lib

If you need advice on updating Racket installations older than version 6.0, please let us know and we will provide them.

To test that your Racket installation is fixed, you can run the program here. It will print whether your installation is out of date.

more →

08 Feb 2016

Racket v6.4

posted by Ryan Culpepper

Racket version 6.4 is now available from http://racket-lang.org/

  • We fixed a security vulnerability in the web server. The existing web server is vulnerable to a navigation attack if it is also enabled to serve files statically; that is, any file readable by the web server is accessible remotely. For more information, see this post.

  • DrRacket’s scrolling is faster.

  • Incremental garbage-collection mode can eliminate long pauses in a program. For example, incremental mode is useful for avoiding pauses in games and animations.

Programs must specifically request incremental mode with (collect-garbage 'incremental), but libraries such as 2htdp/universe include the request as part of the library’s implementation.

  • The default package catalog is an HTTPS address instead of HTTP, and package operations properly validate server certificates when using HTTPS.

  • Documentation may define their own categories for the manual top-level page by using strings, rather than only symbols that name pre-defined categories.

  • The Racket cheat sheet is included in the main distribution.

  • DrRacket is available in Bulgarian, thanks to Alexander Shopov.

  • The contract Typed Racket generates for the Any type is more permissive, allowing more typed/untyped programs to work without contract errors.

  • Redex supports binding specifications; describe which variables bind in which expressions and your metafunctions and reduction relations automatically become scope-sensitive. Thanks to Paul Stansifer for this improvement.

  • All pict functions accept pict-convertibles. This allows for transparent interoperability between pict and libraries like 2htdp/image.

  • The raco profile and raco contract-profile commands provide easy access to profiling tools, without requiring program modifications.

Feedback Welcome

more →

Made with Frog, a static-blog generator written in Racket.
Source code for this blog.