Frequently Asked Questions - racket/racket GitHub Wiki

Other FAQ’s

Racket Frequently Asked Questions


Does Racket have a compiler?

Racket has a compiler. Racket currently has two backends; a bytecode compiler for Racket BC, and a nanopass compiler that compiles to machine code for Racket CS.

Running racket <your-file.rkt> by default compiles your code and then executes the compiled code. By running a command like raco make <your-file.rkt>, your program is compiled in advance, so that subsequent racket <your-file.rkt> can execute the compiled code right away.

https://docs.racket-lang.org/guide/performance.html

See also Fast Racket

What is 'BC' in Racket(BC)?

The 'BC' means "Before Chez [Scheme]" , this was formerly the standard version of Racket.

Racket also comes in the 'CS' variant (Chez Scheme). This is now the 'standard' Racket. (October 2021)

For more information see Racket Virtual Machine Implementations in the Racket Guide.

How fast is Racket?

See Fast Racket.

Can you Hot-Load or hot-swap code without having to restart long running processes?

While the core functionality is provided by dynamic-rerequire you can use the racket-reloadable library to add this functionality to your own applications.

Why is the Racket REPL different to Common Lisp?

See the DrScheme repl isn’t the one in Emacs

Why Hygienic Macros?

Hygienic Macros were developed to address the problem of Identifier Capture in symbol-based macro systems. Racket has advanced macro functionality in the form of syntax-parse, and supporting tooling like the Macro Stepper to help you write and debug macros.

(If you need to break hygiene you can)

For more background see

William D. Clinger and Mitchell Wand. 2020. Hygienic macro technology. Proc. ACM Program. Lang. 4, HOPL, Article 80 (June 2020), 110 pages. DOI:https://doi.org/10.1145/3386330

Where is the GUI builder?

Racket has a gui builder: MrEd-Designer by @Metaxal -> https://github.com/Metaxal/MrEd-Designer

see https://github.com/Metaxal/MrEd-Designer/wiki for some screenshots

It is free to use and has a GPLv2 licence.

Can I run Racket on Android?

Can I integrate Racket with other programming languages?

There are lots of options;

What is the difference between pict, metapict, draw, and 2htdp/image?

Draw is the underlying toolkit used by both pict and 2htdp/image.

The pict library is one of the standard Racket functional picture libraries (the other being 2htdp/image). This library was originally designed for use with Slideshow, and is re-provided by the slideshow language. - https://docs.racket-lang.org/pict/index.html

The metapict library extends pict with a bunch of extra functionality. In particular MetaPict provides a notation for constructing nice curves through a given set of points. The curves can be drawn, filled, intersected etc. MetaPict uses the same approach similar as MetaPost and TikZ. https://docs.racket-lang.org/metapict/index.html

The 2htdp/image package provides a number of basic image construction functions, along with combinators for building more complex images out of existing images. Basic images include various polygons, ellipses and circles, and text, as well as bitmaps. Existing images can be rotated, scaled, flipped, and overlaid on top of each other. - https://docs.racket-lang.org/teachpack/2htdpimage.html

The racket/draw library provides a drawing API that is based on the PostScript drawing model. It supports line drawing, shape filling, bitmap copying, alpha blending, and affine transformations (i.e., scale, rotation, and translation). - https://docs.racket-lang.org/draw/overview.html

The toplevel is hopeless

If you hear the phrase "The toplevel is hopeless", the speaker is refering to a number of issues with the toplevel (often the repl). There are several issues, but boil down to a clash of expections of program behaviour in the repl vs inside a module.

A series of posts and discussions on the topic can be found here:

https://gist.github.com/samth/3083053

How do I display images outside of DrRacket?

If you use DrRacket images are displayed inline, but many other editors and terminal emulators lack this capability.

In general you can use the show-pict function to open a window and display the image.

#lang racket
(require pict)
...
(show-pict your-pict)

See show-pict

Note: If you are using a different image library convert your image with pict-convert.


Timezone Lookup (an adventure in program optimization)

Alex Harsányi 12:03 AM A while ago I wrote a blog post about optimizing a program that ran in 8 seconds on average to one that ran in 33 milliseconds on average -- there is a summary of the techniques used at the beginning of the post, which you may find useful: https://alex-hhh.github.io/2019/08/timezone-lookup.html (Copied from Slack)