05 Nov 2024

Racket v8.15

posted by Stephen De Gabrielle


We are pleased to announce Racket v8.15 is now available from https://download.racket-lang.org/.

As of this release:

  • Documentation search results are ordered, with visual cues indicating what their source is (core, main-distribution, etc.). These results are also grouped by language family (Racket, Rhombus, etc.). Search e.g. second to see an example.

  • DrRacket offers to restore previously open files when starting, which can be made the default.

DrRacket restore open files dialog

  • In DrRacket, Images in editing panels can be saved by right-clicking, including those generated by the functional picture libraries pict and 2htdp/image.

DrRacket save image in context menu

Thank you

The following people contributed to this release:

Alec Mills, Alex Knauth, Alexander Shopov, Ashlynn Anderson, Ashton Wiersdorf, Ben Greenman, Benjamin Yeung, Bob Burger, Bogdan Popa, Breck Yunits, Carl Gay, Claes Wallin (韋嘉誠), CooperCorad, Crystal Jacobs, D. Ben Knoble, Dexter Santucci, Eduardo Cavazos, Emil Szpakowski, evelynmitchell, Greg Hendershott, Gunnar Ahlberg, Gwen Weinholt, Idiomdrottning, Ikko Eltociear Ashimine, Jacqueline Firth, Jarhmander, Jay McCarthy, Jens Axel Søgaard, Jimmy McNutt, jinser, Jinser Kafka, John Clements, lukejianu, Marc Nieper-Wißkirchen, Matej Fandl, Matthew Flatt, Matthias Felleisen, Michael Ballantyne, Mike Sperber, olopierpa, Paul Morris, Phil Nguyen, Philip McGrath, Robby Findler, Ronald Garcia, Ryan Culpepper, Sam Phillips, Sam Tobin-Hochstadt, Siddhartha Kasivajhula, Sorawee Porncharoenwase, Stephen De Gabrielle, Syntacticlosure, Taylor Allred, Tomas Fabrizio Orsi, Wing Hei Chan, and Yafei Yang.

Racket is a community developed open source project and we welcome new contributors. See racket/README.md to learn how you can be a part of this amazing project.

Feedback Welcome

Questions and discussion welcome at the Racket community Discourse announcement(join) or on the Racket Discord.

Please share

If you can - please help get the word out to users and platform specific repo packagers

Racket - the Language-Oriented Programming Language - version 8.15 is now available from https://download.racket-lang.org

See https://blog.racket-lang.org/2024/08/racket-v8-15.html for the release announcement and highlights.
more →

20 Aug 2024

Racket v8.14

posted by Stephen De Gabrielle


We are pleased to announce Racket v8.14 is now available from https://download.racket-lang.org/.

As of this release:

  • 64-bit ARM Windows is one of the standard pre-built downloads.

  • The compiler/demod language integrates demodularization into the program rather than an external tool. Using the language approach cooperates with other Racket tools and allows demodularization to be used on libraries. Additionally, demodularization handles submodules and can prune definitions, significantly shrinking the size of some programs. (#lang compiler/demod)

  • The contract-in form enables contracts to be specified in an importing module. (8.6 Attaching Contracts to Values)

  • The #%declare form supports the #:flatten-requires and #:unlimited-compile keywords (#%declare)

  • Identifiers such as case-λ, match-λ and λ are equivalent to their Latin-alphabet equivalents (case-lambda, match-lambda, and lambda) in more contexts, including uses of match.

  • The hash-filter function allows the use of a predicate to select a sub-table of a hash table. (hash-filter)

  • The module browser can perform filtering on submodules.

  • The raco test command-line form respects the current-test-invocation-directory parameter, and shows well-formed module paths in its output. (current-test-invocation-directory)

  • Racket CS allows the use of in-memory boot files.

  • The raco/testing collection brings together a variety of testing- related functions and forms. (raco/testing)

  • This release also includes many bug-fixes and documentation updates!

  • NOTE: This release (and version 8.13) have a known build problem that affects the builtpkgs source bundle on Windows. In order to avoid this problem, use a pre-built bundle or build using a source bundle other than the “builtpkgs” one. Nightly builds do not suffer from this problem.

Thank you

The following people contributed to this release:

Alex Knauth, Alexander Shopov, Ben Greenman, Bert De Ketelaere, Bob Burger, Bogdan Popa, Cadence Ember, Carl Gay, D. Ben Knoble, Gregory Rosenblatt, Gustavo Massaccesi, John Clements, John Sullivan, Jordan Johnson, luistung, Matthew Flatt, Matthias Felleisen, Noah Ma, Philip McGrath, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Sergey Fedorov, Sorawee Porncharoenwase, Wing Hei Chan, and ZhangHao.

Racket is a community developed open source project and we welcome new contributors. See racket/README.md to learn how you can be a part of this amazing project.

Feedback Welcome

Questions and discussion welcome at the Racket community Discourse or Discord

Please share

If you can - please help get the word out to users and platform specific repo packagers

Racket - the Language-Oriented Programming Language - version 8.14 is now available from https://download.racket-lang.org

See https://blog.racket-lang.org/2024/08/racket-v8-14.html for the release announcement and highlights.
more →

16 May 2024

Racket v8.13

posted by Stephen De Gabrielle


We are pleased to announce Racket v8.13 is now available from https://download.racket-lang.org/.

As of this release:

  • The racket/treelist and racket/mutable-treelist libraries provide list-like containers that support many operations in effectively constant time, including appending and extracting sub-lists without mutating the given list. Treelists are implemented as RRB Vectors, invented by Stucki, Riompf, Ureche, and Bagwell. (see 4.16 Treelists and RRB vector: a practical general purpose immutable sequence, ICFP 2015)

  • The hash-filter-keys and hash-filter-values functions allow users to filter hashes using a predicate on either keys or values. (see 4.15 Hash Tables: hash-filter-keys, hash-filter-values)

  • The vector-extend and vector*-extend functions provide a way to pre-populate the prefix of a newly allocated vector using the elements of an existing vector. (see 4.12 Vectors: vector-extend)

  • Command-line raco setup, package update, and package installation use terminal control (when available) to show what they are working on more compactly and with a progress bar.

  • Racket v8.13 uses Unicode 15.1 for character and string operations.

  • Machine-specific cross-module optimization allows improved support for static generation of foreign-function bindings.

  • The scribble/acmart language uses v2.01, which avoids errors concerning the hyperref package in some latex installations.

Thank you

The following people contributed to this release:

Alec Mills, Ben Greenman, Bob Burger, Bogdan Popa, dr-neptune, Fred Fu, Gustavo Massaccesi, Jason Hemann, Jay McCarthy, John Clements, Jordan Johnson, Justin Dhillon, Mao Yifu, Matias Eyzaguirre, Matthew Flatt, Matthias Felleisen, Mike Sperber, olopierpa, Oscar Waddell, Pavel Panchekha, Philip McGrath, Robby Findler, Sam Phillips, Sam Tobin-Hochstadt, Siddhartha Kasivajhula, Sorawee Porncharoenwase, Stephen De Gabrielle, Tim Standen, William E. Byrd, and Wing Hei Chan.

Racket is a community developed open source project and we welcome new contributors. See racket/README.md to learn how you can be a part of this amazing project.

Feedback Welcome

Questions and discussion welcome at the Racket community Discourse or Discord

Please share

If you can - please help get the word out to users and platform specific repo packagers

Racket - the Language-Oriented Programming Language - version 8.13 is now available from https://download.racket-lang.org

See https://blog.racket-lang.org/2024/05/racket-v8-13.html for the release announcement and highlights.
more →

08 Feb 2024

Racket v8.12

posted by Stephen De Gabrielle


8.12cat|277x123

8.12cat|277x123

We are pleased to announce Racket v8.12 is now available from https://download.racket-lang.org/.

As of this release:

  • The “Die Macht der Abstraktion” language levels are no longer present, replaced by the “Schreibe dein Programm” language levels which have been available for several years. (see DeinProgramm - Schreibe Dein Programm! )
  • The release fixes a problem with the binding structure of the for/fold form in the rare situation when an iteration clause identifier shadowed an accumulator identifier. This change may break code that depends on the old binding structure. (see 3.18 Iterations and Comprehensions: for, for/list, … )
  • Racket automatically sets the close-on-exec flag when opening a file, on systems where this is available. This change lowers the cost of avoiding problems that can occur when file descriptors become accidentally shared between processes. (see 13.1.5 File Ports )
  • Match includes hash and hash* patterns. (see 9 Pattern Matching )
  • The vector-set/copy function allows creation of a new vector that differs at only one index. This change also adds vector-append and vector-copy primitives. (see 4.12 Vectors )
  • The pregexp-quote function brings the functionality of regexp-quote to pregexps. (see 4.8 Regular Expressions )
  • The C FFI convention-based converter supports PascalCase and camelCase in addition to an underscore-based convention. (see 5.6 Defining Bindings )
  • The racket/case library allows case-like forms that use different equality comparisons, such as eq? and equal-always?. (see 3.13 Dispatch: case)
  • Scribble rendering to HTML adds linking and information buttons when hovering over heading titles.
image|690x196

image|690x196

image|690x98

image|690x98

This release also includes many other documentation improvements, optimizations, and bug fixes!

Thank you

Thank you to the people who contributed to this release:

Alex Harsányi, Alex Knauth, Alex Muscar, Alexis King, Ben Greenman, Bert De Ketelaere, Bob Burger, Bogdan Popa, Chris Payne, Fred Fu, J. Ryan Stinnett, Jamie Taylor, Jared Forsyth, Jarhmander, Jens Axel Søgaard, Joel Dueck, John Clements, Jordan Johnson, Ken Harris, Laurent Orseau, Mao Yifu, Marc Nieper-Wißkirchen, Matteo d’Addio, Matthew Flatt, Matthias Felleisen, Micah Cantor, Mike Sperber, naveen srinivasan, Oscar Waddell, Philip McGrath, Philippe Meunier, Robby Findler, Rocketnia, Sam Phillips, Sam Tobin-Hochstadt, Sarthak Shah, Shu-Hung You, Sorawee Porncharoenwase, Stephen De Gabrielle, Tom Price, ur4t, Wing Hei Chan, and ZhangHao

Feedback Welcome

Questions and discussion welcome at the Racket community Discourse or Discord

Please share

If you can - please help get the word out to users and platform specific repo packagers

Racket - the Language-Oriented Programming Language - version 8.12 is now available from https://download.racket-lang.org

See https://racket.discourse.group/t/racket-v8-12-is-now-available/2709 for the release announcement and highlights.

Thank you to the many people who contributed to this release!

Feedback Welcome

more →

29 Nov 2023

Racket v8.11.1


Racket version 8.11.1 is now available from https://racket-lang.org/

This bug-fix release repairs a problem with building from source when using the “builtpkgs” source distribution.

Feedback Welcome


more →

14 Nov 2023

Racket v8.11


Racket version 8.11 is now available from https://download.racket-lang.org/.

As of this release:

  • Match clauses can include a #:do option to allow evaluation of code and bindings before a following #:when clause. See match.

  • JSON Serialization supports indentation with an #:indent option to write-json. See write-json.

  • An initiate-sequence function simplifies the creation of sequences. See initiate-sequence.

  • The :do-in form allows an inner definition sequence. See :do-in.

  • The redex-define form allows pattern-matching in PLT Redex using a define-like syntax. See redex-define.

  • Racket and Chez Scheme use Robert L. Smith’s “Algorithm 116” for division of complex numbers. See Robert L. Smith. 1962. Algorithm 116: Complex division. Commun. ACM 5, 8 (Aug. 1962), 435. https://dl.acm.org/doi/10.1145/368637.368661.

  • DrRacket has indentation guides that provide visual cues indicating how code is indented and grouped, accessible by using (<menu-key>-shift-i). See text:indent-guides<%>.

  • “Comment-out” menu items can be specific to the #lang used by the current file. See Comments.

  • Unused identifiers have a tooltip indicating that they have no bound occurrences.

  • Quickscript includes a new form of scripting in the form of “hook” functions that can be attached to existing events. See Hooks.

  • Plots include plot-inset and plot-legend-padding parameters to control the amount of space left unused around the plot edge and plot legend. See plot-inset.

  • There are many other documentation improvements, optimizations, and bug fixes!

Thank You

Thank you to the people who contributed to this release:

Alex Harsányi, Ben Greenman, Bogdan Popa, Cameron Moy, Camille d’Alméras, D. Ben Knoble, Efraim Flashner, Eric S. Raymond, Fred Fu, Greg Hendershott, Gustavo Massaccesi, Jay McCarthy, jim, Joel Dueck, John Clements, Jon Eskin, Laurent Orseau, Lucas Sta Maria, mAdkins, Mark Hedlund, Matteo d’Addio, Matthew Flatt, Matthias Felleisen, Mike Sperber, Noah Ma, Oscar Waddell, Philip McGrath, Qifan Wang, Robby Findler, Ross Angle, Ryan Culpepper, Sam Tobin-Hochstadt, shenleban tongying, Shu-Hung You, Sorawee Porncharoenwase, Stephen De Gabrielle, Wing Hei Chan, xxyzz, and ZhangHao

Feedback Welcome

more →

15 Aug 2023

Racket v8.10

Racket version 8.10 is now available from https://download.racket-lang.org/

As of this release:

Thank you

Thank you to the people who contributed to this release:

Adrien Ludwig, Alex Harsányi, Alex Knauth, Alexis King, Ben Greenman, Cameron Moy, D. Ben Knoble, Greg Hendershott, Gustavo Massaccesi, Jay McCarthy, Joel Dueck, John Clements, Jordan Johnson, Kamil Laskowski, Laurent Orseau, Liam Avella-Pisera, Matthew Flatt, Matthias Felleisen, Mike Sperber, Oscar Waddell, Pavel Panchekha, Philip McGrath, reflektoin, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Shu-Hung You, Stefan Schwarzer, Stephen De Gabrielle, and Yongming Shen

Feedback Welcome

more →

11 May 2023

Racket v8.9

Racket version 8.9 is now available from https://download.racket-lang.org/

As of this release:

Thank you

Thank you to the people who contributed to this release:

Alex Harsányi, Alex Knauth, Alexis King, Ben Greenman, Bert De Ketelaere, Bob Burger, Bogdan Popa, Cadence Ember, D. Ben Knoble, Denis Hirn, dr-neptune, Eli Barzilay, Fred Fu, Gustavo Massaccesi, J. Ryan Stinnett, Jack Firth, Jamie Taylor, Jesse Alama, Jin-Ho King, John Clements, Lazerbeak12345, Mark Hedlund, Masaya Tojo, Matthew Flatt, Matthias Felleisen, Mike Sperber, Philip McGrath, Robby Findler, Ryan Culpepper, Sam Phillips, Sam Tobin-Hochstadt, sarna, Shu-Hung You, Sorawee Porncharoenwase, Stephen De Gabrielle, sxzzsf, Tom Price, Yukai Chou, and Zach O’Brien.

Feedback Welcome

more →

07 Feb 2023

Racket v8.8

Racket version 8.8 is now available from https://download.racket-lang.org/

As of this release:

The following people contributed to this release:

Alex Knauth, Alexander Shopov, Andreas Schwab, Ben Greenman, Bert De Ketelaere, Bob Burger, Bogdan Popa, Cameron Moy, Chung-chieh Shan, D. Ben Knoble, Dan Anderson, David Van Horn, Geoffrey Knauth, Gustavo Massaccesi, Jamie Taylor, Jason Hemann, Jens Axel Søgaard, Jesse Alama, jestarray, Johann Rudloff, Johannes Maier, John Clements, Jon Zeppieri, Lazerbeak12345, Lîm Tsú-thuàn, Matthew Flatt, Matthias Felleisen, Mike Sperber, Niklas Larsson, Noah Ma, Pavel Panchekha, Philip McGrath, Philippe Meunier, R. Kent Dybvig, reflektoin, Robby Findler, Sam Tobin-Hochstadt, Shu-Hung You, Sorawee Porncharoenwase, and Stephen De Gabrielle

Official installers for Racket on many platforms are available from https://download.racket-lang.org/.

If you are new to Racket try our Getting started guide.

Questions and feedback about the release are welcome on Discourse.

more →

20 Nov 2022

Shallow and Optional Typed Racket

With the Racket 8.7 release, Typed Racket includes two languages that weaken the run-time behavior of types: Shallow Typed Racket and Optional Typed Racket. Whereas normal Typed Racket types (Deep types) enforce guarantees that any module can depend on, Shallow types enforce only local invariants in typed code, and Optional types enforce nothing. In return, Shallow and Optional types add less overhead to gradual interactions. Code often runs faster and simpler than with Deep types.

Shallow Typed Racket and Optional Typed Racket use the same static types and typechecker as normal (Deep) Typed Racket.

1  Background: Typed–Untyped Interaction

A key feature of Typed Racket is that it allows typed code to interact with untyped code. An untyped module can import from a typed one with a normal require form, and a typed module can import from an untyped one by using a require/typed form:

For example, if an untyped module provides a struct and a function:

#lang racket
; distance.rkt
 
(provide (struct-out pt)
         distance)
 
(struct pt (x y))
 
; distance : pt pt -> real
(define (distance p1 p2)
  (sqrt (+ (sqr (- (pt-x p2) (pt-x p1)))
           (sqr (- (pt-y p2) (pt-y p1))))))

then a typed module can import the untyped bindings:

#lang typed/racket
 
(require/typed "distance.rkt"
  [#:struct pt ([x : Real] [y : Real])]
  [distance (-> pt pt Real)])
 
(distance (pt 3 5) (pt 7 0))

So far so good. One program combines untyped and typed code.

Now, what if the declared types are wrong?

The module below gives a wrong type to the distance function. This type expects an integer result instead of a real number:

#lang typed/racket
 
(require/typed "distance.rkt"
  [#:struct pt ([x : Real] [y : Real])]
  [distance (-> pt pt Integer)])
 
(distance (pt 3 5) (pt 7 0))

Even with the wrong type, the program still typechecks (!) because Typed Racket does not analyze untyped code. It assumes the require/typed types are correct and moves on.

But this program does have a type error. At run-time, the call to distance returns a float instead of an integer, contradicting the static type.

If we want to catch the error, then Typed Racket needs to enforce types at run-time when typed and untyped code interact.

2  Enforcing Type Boundaries

By default, Typed Racket compiles types to higher-order contracts. The function type (-> pt pt Integer), for example, compiles to a function contract that will raise an exception if gets attached to a function that eventually returns a non-integer result.

Contracts enforce types with strong guarantees and offer useful debugging information if an error occurs. But they can also be expensive, especially when large, mutable, or higher-order values frequently cross boundaries. These high costs inspired a long search for cheaper ways to enforce types than the standard Deep strategy.

Two promising alternatives are Shallow and Optional types, neither of which use higher-order contracts.

Shallow types use lightweight assertions called shape checks to provide a basic soundness guarantee. Instead of putting heavy contracts at module boundaries, Shallow Typed Racket rewrites typed code to incrementally check the shape of values.

Optional types use no checks. They are completely unreliable for reasoning about typed-untyped interactions. But, they also have zero cost.

3  How to Select an Enforcement Strategy

The #lang of a Typed Racket module decides how its types behave at run-time. To change strategies, change the language.

For a complete list of forms that change depending on the #lang, see Forms that Depend on the Behavior of Types in the Typed Racket Reference.

4  Example: Fewer Run-time Checks

Deep types can be significantly more expensive than Shallow and Optional. For example, the two functions below expect a data structure and access part of the data: list-first returns the first element of a list and vec-length counts the number of elements in a vector.

(: list-first (-> (Listof Real) Real))
(define (list-first l)
  (car l))
 
(: vec-length (-> (Vectorof Real) Index))
(define (vec-length v)
  (vector-length v))

When these functions get called from untyped code, they have very different costs depending on the behavior of types:

  • Deep types check all incoming data structures exhaustively. Lists undergo a full traversal that validates every list element, including unused ones. Vectors get wrapped in a chaperone to guard against future writes.

  • Shallow types check the shape of the incoming data structures using list? and vector?. Elements of these structures get checked only when they are used by typed code.

  • Optional types check nothing at all.

Further Reading has links to larger examples where the costs of Deep types are huge compared to Shallow and Optional.

5  Example: Weaker Types, Simpler Behavior

Shallow and Optional types raise fewer run-time errors than Deep. In many cases, the lack of an error means that a bug goes undetected. Deep finds the bug and the other two miss it because they skipped a run-time check.

But for some programs, the Deep types are too cautious. They reject a program that could run safely.

One restrictive type in the Deep world is Procedure, the type that describes any function. Because this type says nothing about argument and return types, Deep Typed Racket never allows calls to a procedure, even after a cast:

#lang typed/racket ; or #lang typed/racket/deep
 
(: call-proc (-> Procedure Symbol))
(define (call-proc f)
  ((cast f (-> Symbol Symbol)) 'hello))
(call-proc identity)

g4: arity mismatch;

 the expected number of arguments does not match the given

number

  given: 1

Shallow types do allow calls to a Procedure, after a cast:

#lang typed/racket/shallow
 
(: call-proc (-> Procedure Symbol))
(define (call-proc f)
  ((cast f (-> Symbol Symbol)) 'hello))
(call-proc identity)

- : Symbol

'hello

Optional types also allow calls to a Procedure:

#lang typed/racket/optional
 
(: call-proc (-> Procedure Symbol))
(define (call-proc f)
  ((cast f (-> Symbol Symbol)) 'hello))
(call-proc identity)

- : Symbol

'hello

6  Four-Way Interactions

Typed–untyped interactions are much more exciting now that “typed code” can be Deep, Shallow, or Optional. These three styles of typed code can all interact with untyped code (of course), and they can also interact with one another.

Types in this four-way world need to be enforced at run-time depending on how they were defined:

  • Deep types get enforced with contracts at all boundaries to non-Deep code. This means that Deep–Shallow and Deep–Optional interactions can be expensive.

  • Shallow types guard the boundaries to Optional and untyped code with shape checks.

  • Optional types never enforce themselves. But a Deep-typed or Shallow-typed client of Optional code will insert run-time checks as a consequence of their strategies.

These checks between Deep, Shallow, and Optional may come as a surprise, especially because all typed code gets validated by the same static type checker. But the checks are necessary because run-time interactions can mix untyped values into some of these typed modules. If an Optional module were to import an untyped function and send it to Deep-typed code without a contract wrapper, it could break the Deep type guarantees.

7  Reflections on Deep, Shallow, and Optional

Deep types, Shallow types, and Optional types have complementary strengths. When and where does each one work best? Here are a few suggestions, based on When to Use Deep, Shallow, or Optional? from the Typed Racket Guide:

  • Deep types make the most of static checking and optimizations. Use them for self-sufficient groups of typed modules. Avoid them at high-traffic boundaries to untyped or to non-Deep code.

  • Shallow types provide a weak but useful soundness guarantee at low cost. Use them in typed modules that frequently communicate with the untyped world. Avoid them, however, in large typed modules because every expression in typed code potentially needs a Shallow shape check.

  • Optional types use types for static analysis and nothing more. Use them when you do not want types enforced at run-time.

We are very excited to have these languages in the Typed Racket family. Learning more about where they fit in practical applications and about how developers tend to use them will be part of the adventure.

8  Further Reading

more →

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