Racket Blog: Racket Blogurn:http-blog-racket-lang-org:-index-html2024-02-08T23:51:41ZRacket v8.12urn:http-blog-racket-lang-org:-2024-02-racket-v8-12-html2024-02-08T23:51:41Z2024-02-08T23:51:41ZThe Unknown Author
<p><em>posted by Stephen De Gabrielle</em></p>
<hr />
<h1 id="racket-v812-is-now-available">Racket v8.12 is now available</h1>
<div class="figure"><img src="/img/posts/2024-02-08-racket-release-v8.12/cat8.12.png" alt="8.12cat|277x123" />
<p class="caption">8.12cat|277x123</p></div>
<p>We are pleased to announce Racket v8.12 is now available from <a href="https://download.racket-lang.org">https://download.racket-lang.org/</a>.</p>
<h2 id="as-of-this-release">As of this release:</h2>
<ul>
<li>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 <a href="https://www.deinprogramm.de/sdp/">DeinProgramm - Schreibe Dein Programm!</a> )</li>
<li>The release fixes a problem with the binding structure of the <code>for/fold</code> 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 <a href="https://docs.racket-lang.org/reference/for.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._for%2Ffold%29%29">3.18 Iterations and Comprehensions: for, for/list, …</a> )</li>
<li>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 <a href="https://docs.racket-lang.org/reference/file-ports.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._open-input-file%29%29">13.1.5 File Ports</a> )</li>
<li>Match includes <code>hash</code> and <code>hash*</code> patterns. (see <a href="https://docs.racket-lang.org/reference/match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29">9 Pattern Matching</a> )</li>
<li>The <code>vector-set/copy</code> function allows creation of a new vector that differs at only one index. This change also adds <code>vector-append</code> and <code>vector-copy</code> primitives. (see <a href="https://docs.racket-lang.org/reference/vectors.html#%28def._%28%28lib._racket%2Fvector..rkt%29._vector-set%2Fcopy%29%29">4.12 Vectors</a> )</li>
<li>The <code>pregexp-quote</code> function brings the functionality of <code>regexp-quote</code> to pregexps. (see <a href="https://docs.racket-lang.org/reference/regexp.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._pregexp-quote%29%29">4.8 Regular Expressions</a> )</li>
<li>The C FFI convention-based converter supports <code>PascalCase</code> and <code>camelCase</code> in addition to an underscore-based convention. (see <a href="https://docs.racket-lang.org/foreign/Defining_Bindings.html#%28form._%28%28lib._ffi%2Funsafe%2Fdefine%2Fconventions..rkt%29._convention~3ahyphen-~3ecamel.Case%29%29">5.6 Defining Bindings</a> )</li>
<li>The <code>racket/case</code> library allows <code>case</code>-like forms that use different equality comparisons, such as <code>eq?</code> and <code>equal-always?</code>. (see <a href="https://docs.racket-lang.org/reference/case.html#%28form._%28%28lib._racket%2Fcase..rkt%29._case%2Fequal%29%29">3.13 Dispatch: case</a>)</li>
<li>Scribble rendering to HTML adds linking and information buttons when hovering over heading titles.</li></ul>
<div class="figure"><img src="/img/posts/2024-02-08-racket-release-v8.12/doclinkscrble.png" alt="image|690x196" />
<p class="caption">image|690x196</p></div>
<div class="figure"><img src="/img/posts/2024-02-08-racket-release-v8.12/doclink.png" alt="image|690x98" />
<p class="caption">image|690x98</p></div>
<ul>
<li>The <code>interval-map</code> data structure supports iterator functions in the style of <code>gen:ordered-dict</code>. (see <a href="https://docs.racket-lang.org/data/Orders_and_Ordered_Dictionaries.html#%28def._%28%28lib._data%2Forder..rkt%29._gen~3aordered-dict%29%29">3 Orders and Ordered Dictionaries</a> )</li></ul>
<p>This release also includes many other documentation improvements, optimizations, and bug fixes!</p>
<h2 id="thank-you">Thank you</h2>
<p>Thank you to the people who contributed to this release:</p>
<p>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</p>
<h2 id="feedback-welcome">Feedback Welcome</h2>
<p>Questions and discussion welcome at the Racket community <a href="https://racket.discourse.group/invites/VxkBcXY7yL">Discourse</a> or <a href="https://discord.gg/6Zq8sH5">Discord</a></p>
<h2 id="please-share">Please share</h2>
<p>If you can - please help get the word out to users and platform specific repo packagers</p>
<pre><code>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</code></pre>
<hr />Racket v8.11.1urn:http-blog-racket-lang-org:-2023-11-racket-v8-11-1-html2023-11-30T06:29:35Z2023-11-30T06:29:35ZThe Unknown Author
<hr />
<p>Racket version 8.11.1 is now available from <a href="https://racket-lang.org/">https://racket-lang.org/</a></p>
<p>This bug-fix release repairs a problem with building from source when using the “builtpkgs” source distribution.</p>
<p>Feedback Welcome</p>
<hr />Racket v8.11urn:http-blog-racket-lang-org:-2023-11-racket-v8-11-html2023-11-14T22:30:14Z2023-11-14T22:30:14ZThe Unknown Author
<hr />
<p>Racket version 8.11 is now available from <a href="https://download.racket-lang.org">https://download.racket-lang.org/</a>.</p>
<p>As of this release:</p>
<ul>
<li>
<p>Match clauses can include a #:do option to allow evaluation of code and bindings before a following #:when clause. See <a href="https://docs.racket-lang.org/reference/match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29"><code>match</code></a>.</p></li>
<li>
<p>JSON Serialization supports indentation with an #:indent option to <code>write-json</code>. See <a href="https://docs.racket-lang.org/json/index.html#%28def._%28%28lib._json%2Fmain..rkt%29._write-json%29%29"><code>write-json</code></a>.</p></li>
<li>
<p>An <code>initiate-sequence</code> function simplifies the creation of sequences. See <a href="https://docs.racket-lang.org/reference/sequences.html#%28def._%28%28lib._racket%2Fsequence..rkt%29._initiate-sequence%29%29"><code>initiate-sequence</code></a>.</p></li>
<li>
<p>The <code>:do-in</code> form allows an inner definition sequence. See <a href="https://docs.racket-lang.org/reference/for.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~3ado-in%29%29"><code>:do-in</code></a>.</p></li>
<li>
<p>The <code>redex-define</code> form allows pattern-matching in PLT Redex using a <code>define</code>-like syntax. See <a href="https://docs.racket-lang.org/redex/reference.html#%28form._%28%28lib._redex%2Freduction-semantics..rkt%29._redex-define%29%29"><code>redex-define</code></a>.</p></li>
<li>
<p>Racket and Chez Scheme use Robert L. Smith’s “Algorithm 116” for division of complex numbers. See <em>Robert L. Smith. 1962. Algorithm 116: Complex division. Commun. ACM 5, 8 (Aug. 1962), 435. <a href="https://dl.acm.org/doi/10.1145/368637.368661">https://dl.acm.org/doi/10.1145/368637.368661</a></em>.</p></li>
<li>
<p>DrRacket has indentation guides that provide visual cues indicating how code is indented and grouped, accessible by using (<menu-key>-shift-i). See <a href="https://docs.racket-lang.org/framework/Text.html#%28def._%28%28lib._framework%2Fmain..rkt%29._text~3aindent-guides~3c~25~3e%29%29"> <code>text:indent-guides<%></code></a>.</p></li>
<li>
<p>“Comment-out” menu items can be specific to the #lang used by the current file. See <a href="https://docs.racket-lang.org/tools/lang-languages-customization.html#(idx._(gentag._13._(lib._scribblings%2Ftools%2Ftools..scrbl)))">Comments</a>.</p></li>
<li>
<p>Unused identifiers have a tooltip indicating that they have no bound occurrences.</p></li>
<li>
<p>Quickscript includes a new form of scripting in the form of “hook” functions that can be attached to existing events. See <a href="https://docs.racket-lang.org/quickscript/index.html#%28part._.Hooks%29">Hooks</a>.</p></li>
<li>
<p>Plots include <code>plot-inset</code> and <code>plot-legend-padding</code> parameters to control the amount of space left unused around the plot edge and plot legend. See <a href="https://docs.racket-lang.org/plot/params.html#%28def._%28%28lib._plot%2Fmain..rkt%29._plot-inset%29%29"><code>plot-inset</code></a>.</p></li>
<li>
<p>There are many other documentation improvements, optimizations, and bug fixes!</p></li></ul>
<h2 id="thank-you">Thank You</h2>
<p>Thank you to the people who contributed to this release:</p>
<p>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</p>
<h2 id="feedback-welcome">Feedback Welcome</h2>
<!-- more-->Racket v8.10urn:http-blog-racket-lang-org:-2023-08-racket-v8-10-html2023-08-16T06:27:18Z2023-08-16T06:27:18ZThe Unknown Author
<p>Racket version 8.10 is now available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a></p>
<h2 id="as-of-this-release">As of this release:</h2>
<ul>
<li>
<p>syntax/parse no longer always compiles its patterns; this release includes an interpreter which is used to reduce code size</p></li>
<li>
<p>Racket includes primitives <code>[im]mutable-string?</code>, <code>[im]mutable-bytes?</code>, <code>[im]mutable-vector?</code>, <code>[im]mutable-box?</code>, and <code>[im]mutable-hash?</code> (cf. <a href="https://docs.racket-lang.org/reference/booleans.html#%28mod-path._racket%2Fmutability%29">https://docs.racket-lang.org/reference/booleans.html#%28mod-path._racket%2Fmutability%29</a>)</p></li>
<li>
<p>Redex adds judgment-form->rule-names (cf. <a href="https://docs.racket-lang.org/redex/reference.html#%28def._%28%28lib._redex%2Freduction-semantics..rkt%29._judgment-form-~3erule-names%29%29">https://docs.racket-lang.org/redex/reference.html#%28def._%28%28lib._redex%2Freduction-semantics..rkt%29._judgment-form-~3erule-names%29%29</a>)</p></li>
<li>
<p>Fasl and compiled code allow fxvectors and flvectors</p></li>
<li>
<p>DrRacket allows #lang-specific customization of the definition navigation popdown (cf. <a href="https://docs.racket-lang.org/tools/drracket_language.html#%28idx._%28gentag._55._%28lib._scribblings%2Ftools%2Ftools..scrbl%29%29%29">https://docs.racket-lang.org/tools/drracket_language.html#%28idx._%28gentag.<em>55.</em>%28lib._scribblings%2Ftools%2Ftools..scrbl%29%29%29</a>)</p></li>
<li>
<p>Racket and DrRacket include Finnish internationalization</p></li>
<li>
<p>Check Syntax binding arrows are drawn for names bound with <code>define-local-member-name</code></p></li>
<li>
<p>Many other improvements and bug fixes are included, including to the scribble and plot packages</p></li></ul>
<h2 id="thank-you">Thank you</h2>
<p>Thank you to the people who contributed to this release:</p>
<p>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</p>
<p>Feedback Welcome</p>Racket v8.9urn:http-blog-racket-lang-org:-2023-05-racket-v8-9-html2023-05-12T04:14:40Z2023-05-12T04:14:40ZThe Unknown Author
<p>Racket version 8.9 is now available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a></p>
<h2 id="as-of-this-release">As of this release:</h2>
<ul>
<li>
<p>The HtDP student languages come with checked signatures. Programmers can express signatures in a formal notation, and these signatures are checked at run-time (in a performance-neutral manner). The addition of this formal language associates meaning with several names that had no meaning before. — This feature is experimental, and we may amend or retract it later. (cf. <a href="https://docs.racket-lang.org/htdp-langs/beginner-abbr.html?q=signatures#%28part._beginner-abbr-signatures%29">https://docs.racket-lang.org/htdp-langs/beginner-abbr.html?q=signatures#%28part._beginner-abbr-signatures%29</a>)</p></li>
<li>
<p>Switching into and out of dark mode is handled better on Mac OS and Linux.</p></li>
<li>
<p>Racket uses Unicode 15.0 for character and string operations.</p></li>
<li>
<p>The <code>racket/hash-code</code> library provides support for combining hash codes. (cf. <a href="https://docs.racket-lang.org/reference/Equality.html#%28mod-path._racket%2Fhash-code%29">https://docs.racket-lang.org/reference/Equality.html#%28mod-path._racket%2Fhash-code%29</a>)</p></li>
<li>
<p>A language module can have a <code>configure-expand</code> submodule that is dynamically required to configure a parameterization before expansion of another module. (cf. <a href="https://docs.racket-lang.org/reference/running-sa.html#%28part._configure-expand%29">https://docs.racket-lang.org/reference/running-sa.html#%28part._configure-expand%29</a>)</p></li>
<li>
<p><code>stream-cons</code> supports multiple values. (cf. <a href="https://docs.racket-lang.org/reference/streams.html#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29">https://docs.racket-lang.org/reference/streams.html#%28form._%28%28lib._racket%2Fstream..rkt%29._stream-cons%29%29</a>)</p></li>
<li>
<p><code>unit/c</code> subcontracts may depend on bindings from any imported or exported signature. Additionally, bindings’ contracts are enforced within subcontracts, and violations blame the contract itself (like <code>->i</code>). (cf. <a href="https://docs.racket-lang.org/reference/unitcontracts.html#%28form._%28%28lib._racket%2Funit..rkt%29._unit%2Fc%29%29">https://docs.racket-lang.org/reference/unitcontracts.html#%28form._%28%28lib._racket%2Funit..rkt%29._unit%2Fc%29%29</a>)</p></li>
<li>
<p><code>racket/class</code> provides the <code>dynamic-instantiate</code> procedure for instantiating a class with a dynamic list of by-name initialization arguments. (cf. <a href="https://docs.racket-lang.org/reference/objcreation.html#%28def._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._dynamic-instantiate%29%29">https://docs.racket-lang.org/reference/objcreation.html#%28def._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._dynamic-instantiate%29%29</a>)</p></li>
<li>
<p>TCP output block buffering implies TCP_NODELAY. (cf. <a href="https://docs.racket-lang.org/reference/tcp.html#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29">https://docs.racket-lang.org/reference/tcp.html#%28def._%28%28lib._racket%2Ftcp..rkt%29._tcp-connect%29%29</a>)</p></li>
<li>
<p>Submodules and Check Syntax require arrows work better together.</p></li>
<li>
<p>Typed Racket’s shallow check generation is improved.</p></li>
<li>
<p>Many other improvements and bug fixes are included!</p></li></ul>
<h2 id="thank-you">Thank you</h2>
<p>Thank you to the people who contributed to this release:</p>
<p>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.</p>
<h2 id="feedback-welcome">Feedback Welcome</h2>Racket v8.8urn:http-blog-racket-lang-org:-2023-02-racket-v8-8-html2023-02-08T06:22:24Z2023-02-08T06:22:24ZThe Unknown Author
<p>Racket version 8.8 is now available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a></p>
<p>As of this release:</p>
<ul>
<li>
<p>The dependent contract form, <code>->i</code>, supports a #:param element that specifies dependencies for parameter values that are set during the dynamic extent of the function call. (See: <a href="https://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3ei%29%29">https://docs.racket-lang.org/reference/function-contracts.html#%28form._%28%28lib.<em>racket%2Fcontract%2Fbase..rkt%29.</em>-~3ei%29%29</a> )</p></li>
<li>
<p>The <code>copy-file</code> library function supports permission-management arguments. (See: <a href="https://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._copy-file%29%29">https://docs.racket-lang.org/reference/Filesystem.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._copy-file%29%29</a> )</p></li>
<li>
<p>Pressing <SHIFT>-return in DrRacket’s interactions window makes it easier to edit and enter expressions without sending them to be evaluated.</p></li>
<li>
<p>The numeric comparison operators (=, etc.) require at least two arguments in the “How To Design Programs” teaching languages.</p></li>
<li>
<p>Redex has improved typesetting when customized renders are used in certain multi-line situations.</p></li>
<li>
<p>We have fixed many bugs, and written lots of documentation.</p></li></ul>
<p>The following people contributed to this release:</p>
<p>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</p>
<p>Official installers for Racket on many platforms are available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a>.</p>
<p>If you are new to Racket try our <a href="https://docs.racket-lang.org/getting-started/index.html">Getting started guide</a>.</p>
<p>Questions and feedback about the release are welcome on <a href="https://racket.discourse.group/">Discourse</a>.</p>Shallow and Optional Typed Racketurn:http-blog-racket-lang-org:-2022-11-shallow-typed-racket-html2022-11-21T07:43:38Z2022-11-21T07:43:38ZThe Unknown Author
<p>With the <a href="https://blog.racket-lang.org/2022/11/racket-v8-7.html">Racket 8.7</a>
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 (<span style="font-style: italic">Deep</span> 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.</p>
<p>Shallow Typed Racket and Optional Typed Racket use the same static types and typechecker as
normal (Deep) Typed Racket.</p>
<h1>1
<tt> </tt><a name="(part._.Background__.Typed--.Untyped_.Interaction)"></a>Background: Typed–Untyped Interaction</h1>
<p>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 <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29">require</a></span> form,
and a typed module can import from an untyped one by using a <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29">require/typed</a></span>
form:</p>
<p>For example, if an untyped module provides a struct and a function:</p>
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a><span class="hspace"> </span><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/index.html"><span class="RktSym">racket</span></a></td></tr>
<tr>
<td><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="RktCmt">distance.rkt</span></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29">provide</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-out%29%29">struct-out</a></span><span class="hspace"> </span><span class="RktSym">pt</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktSym">distance</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._struct%29%29">struct</a></span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktCmt">; </span><span class="RktSym">distance</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym">real</span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">distance</span><span class="hspace"> </span><span class="RktSym">p1</span><span class="hspace"> </span><span class="RktSym">p2</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._sqrt%29%29">sqrt</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29">+</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">sqr</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._-%29%29"><span class="nobreak">-</span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt-x</span><span class="hspace"> </span><span class="RktSym">p2</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt-x</span><span class="hspace"> </span><span class="RktSym">p1</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">sqr</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._-%29%29"><span class="nobreak">-</span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt-y</span><span class="hspace"> </span><span class="RktSym">p2</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt-y</span><span class="hspace"> </span><span class="RktSym">p1</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></div>
<p>then a typed module can import the untyped bindings:</p>
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a><span class="hspace"> </span><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/index.html"><span class="RktSym">typed/racket</span></a></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29">require/typed</a></span><span class="hspace"> </span><span class="RktVal">"distance.rkt"</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">#:struct</span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">distance</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym">distance</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktVal">7</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></div>
<p>So far so good.
One program combines untyped and typed code.</p>
<p>Now, what if the declared types are wrong?</p>
<p>The module below gives a wrong type to the distance function.
This type expects an integer result instead of a real number:</p>
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a><span class="hspace"> </span><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/index.html"><span class="RktSym">typed/racket</span></a></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29">require/typed</a></span><span class="hspace"> </span><span class="RktVal">"distance.rkt"</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">#:struct</span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">distance</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29">Integer</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym">distance</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pt</span><span class="hspace"> </span><span class="RktVal">7</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></div>
<p>Even with the wrong type, the program still typechecks (!)
because Typed Racket does not analyze untyped code.
It assumes the <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._require%2Ftyped%29%29">require/typed</a></span> types are correct and moves on.</p>
<p>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.</p>
<p>If we want to catch the error, then Typed Racket needs to enforce types at run-time
when typed and untyped code interact.</p>
<h1>2
<tt> </tt><a name="(part._.Enforcing_.Type_.Boundaries)"></a>Enforcing Type Boundaries</h1>
<p>By default, Typed Racket compiles types to higher-order contracts.
The function type <span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="stt"> </span><span class="RktSym">pt</span><span class="stt"> </span><span class="RktSym">pt</span><span class="stt"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29">Integer</a></span><span class="RktPn">)</span>, 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.</p>
<p>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 <span style="font-style: italic">Deep</span> strategy.</p>
<p>Two promising alternatives are <span style="font-style: italic">Shallow</span> and <span style="font-style: italic">Optional</span> types,
neither of which use higher-order contracts.</p>
<p>Shallow types use lightweight assertions called <span style="font-style: italic">shape checks</span> 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.</p>
<p>Optional types use no checks.
They are completely unreliable for reasoning about typed-untyped interactions.
But, they also have zero cost.</p>
<h1>3
<tt> </tt><a name="(part._.How_to_.Select_an_.Enforcement_.Strategy)"></a>How to Select an Enforcement Strategy</h1>
<p>The <a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a> of a Typed Racket module decides how its types
behave at run-time.
To change strategies, change the language.</p>
<ul>
<li>
<p>Deep types:
<a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/index.html"><span class="RktSym">typed/racket</span></a>, <a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/index.html"><span class="RktSym">typed/racket/base</span></a>,
<a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Fdeep%29"><span class="RktSym">typed/racket/deep</span></a>, or <a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Fbase%2Fdeep%29"><span class="RktSym">typed/racket/base/deep</span></a>.</p></li>
<li>
<p>Shallow types:
<a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Fshallow%29"><span class="RktSym">typed/racket/shallow</span></a> or <a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Fbase%2Fshallow%29"><span class="RktSym">typed/racket/base/shallow</span></a>.</p></li>
<li>
<p>Optional types:
<a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Foptional%29"><span class="RktSym">typed/racket/optional</span></a> or <a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Fbase%2Foptional%29"><span class="RktSym">typed/racket/base/optional</span></a>.</p></li></ul>
<p>For a complete list of forms that change depending on the <a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a>, see
<a class="Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28part._.Forms_that_.Depend_on_the_.Behavior_of_.Types%29">Forms that Depend on the Behavior of Types</a>
in the Typed Racket Reference.</p>
<h1>4
<tt> </tt><a name="(part._.Example__.Fewer_.Run-time_.Checks)"></a>Example: Fewer Run-time Checks</h1>
<p>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:
<span class="RktSym">list-first</span> returns the first element of a list
and <span class="RktSym">vec-length</span> counts the number of elements in a vector.</p>
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym">list-first</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Listof%29%29">Listof</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">list-first</span><span class="hspace"> </span><span class="RktSym">l</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29">car</a></span><span class="hspace"> </span><span class="RktSym">l</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym">vec-length</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Vectorof%29%29">Vectorof</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Real%29%29">Real</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Index%29%29">Index</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">vec-length</span><span class="hspace"> </span><span class="RktSym">v</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector-length%29%29">vector-length</a></span><span class="hspace"> </span><span class="RktSym">v</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></div>
<p>When these functions get called from untyped code, they have very different
costs depending on the behavior of types:</p>
<ul>
<li>
<p>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 <a class="techoutside Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/chaperones.html#%28tech._chaperone%29"><span class="techinside">chaperone</span></a> to guard against future writes.</p></li>
<li>
<p>Shallow types check the shape of the incoming data structures using
<span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29">list?</a></span> and <span class="RktSym"><a class="RktValLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29">vector?</a></span>.
Elements of these structures get checked only when they are used by typed code.</p></li>
<li>
<p>Optional types check nothing at all.</p></li></ul>
<p><a data-pltdoc="x" href="#%28part._sec~3afurther-reading%29">Further Reading</a> has links to larger examples where the costs of Deep types
are huge compared to Shallow and Optional.</p>
<h1>5
<tt> </tt><a name="(part._.Example__.Weaker_.Types__.Simpler_.Behavior)"></a>Example: Weaker Types, Simpler Behavior</h1>
<p>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.</p>
<p>But for some programs, the Deep types are too cautious.
They reject a program that could run safely.</p>
<p>One restrictive type in the Deep world is <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Procedure%29%29">Procedure</a></span>, 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:</p>
<p></p>
<div class="SIntrapara">
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a><span class="hspace"> </span><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/index.html"><span class="RktSym">typed/racket</span></a><span class="hspace"> </span><span class="RktCmt">;</span><span class="RktCmt"> </span><span class="RktCmt">or #lang typed/racket/deep</span></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Procedure%29%29">Procedure</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktSym">f</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._cast%29%29">cast</a></span><span class="hspace"> </span><span class="RktSym">f</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">hello</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></div></div>
<div class="SIntrapara">
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><span class="RktPn">(</span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktSym">identity</span><span class="RktPn">)</span></td></tr>
<tr>
<td>
<p><span class="RktErr">g4: arity mismatch;</span></p></td></tr>
<tr>
<td>
<p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">the expected number of arguments does not match the given</span></p></td></tr>
<tr>
<td>
<p><span class="RktErr">number</span></p></td></tr>
<tr>
<td>
<p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">given: 1</span></p></td></tr></tbody></table></div></div>
<p>Shallow types do allow calls to a <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Procedure%29%29">Procedure</a></span>, after a cast:</p>
<p></p>
<div class="SIntrapara">
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a><span class="hspace"> </span><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Fshallow%29"><span class="RktSym">typed/racket/shallow</span></a></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Procedure%29%29">Procedure</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktSym">f</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._cast%29%29">cast</a></span><span class="hspace"> </span><span class="RktSym">f</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">hello</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></div></div>
<div class="SIntrapara">
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><span class="RktPn">(</span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktSym">identity</span><span class="RktPn">)</span></td></tr>
<tr>
<td>
<p><span class="RktOut">- : Symbol</span></p></td></tr>
<tr>
<td>
<p><span class="RktRes">'hello</span></p></td></tr></tbody></table></div></div>
<p>Optional types also allow calls to a <span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Procedure%29%29">Procedure</a></span>:</p>
<p></p>
<div class="SIntrapara">
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"><span class="RktMod">#lang</span></a><span class="hspace"> </span><a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html#%28mod-path._typed%2Fracket%2Foptional%29"><span class="RktSym">typed/racket/optional</span></a></td></tr>
<tr>
<td><span class="hspace"> </span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29">:</a></span><span class="hspace"> </span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Procedure%29%29">Procedure</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._define%29%29">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktSym">f</span><span class="RktPn">)</span></td></tr>
<tr>
<td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._cast%29%29">cast</a></span><span class="hspace"> </span><span class="RktSym">f</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._-~3e%29%29"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="hspace"> </span><span class="RktSym"><a class="RktStxLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Symbol%29%29">Symbol</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">hello</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></tbody></table></div></div>
<div class="SIntrapara">
<div class="SCodeFlow">
<table cellpadding="0" cellspacing="0" class="RktBlk">
<tbody>
<tr>
<td><span class="RktPn">(</span><span class="RktSym">call-proc</span><span class="hspace"> </span><span class="RktSym">identity</span><span class="RktPn">)</span></td></tr>
<tr>
<td>
<p><span class="RktOut">- : Symbol</span></p></td></tr>
<tr>
<td>
<p><span class="RktRes">'hello</span></p></td></tr></tbody></table></div></div>
<h1>6
<tt> </tt><a name="(part._.Four-.Way_.Interactions)"></a>Four-Way Interactions</h1>
<p>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.</p>
<p>Types in this four-way world need to be enforced at run-time depending on how
they were defined:</p>
<ul>
<li>
<p>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.</p></li>
<li>
<p>Shallow types guard the boundaries to Optional and untyped code with shape checks.</p></li>
<li>
<p>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.</p></li></ul>
<p>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.</p>
<h1>7
<tt> </tt><a name="(part._.Reflections_on_.Deep__.Shallow__and_.Optional)"></a>Reflections on Deep, Shallow, and Optional</h1>
<p>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
<a class="Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-guide/typed-untyped-interaction.html#%28part._.When_to_.Use_.Deep__.Shallow__or_.Optional_%29">When to Use Deep, Shallow, or Optional?</a>
from the Typed Racket Guide:</p>
<ul>
<li>
<p>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.</p></li>
<li>
<p>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.</p></li>
<li>
<p>Optional types use types for static analysis and nothing more.
Use them when you do not want types enforced at run-time.</p></li></ul>
<p>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.</p>
<h1>8
<tt> </tt><a name="(part._sec~3afurther-reading)"></a>Further Reading</h1>
<ul>
<li>
<p><a class="Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-guide/typed-untyped-interaction.html">Typed-Untyped Interaction</a>
in the Typed Racket Guide</p></li>
<li>
<p><a class="Sq" data-pltdoc="x" href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html">Deep, Shallow, and Optional Semantics</a>
in the Typed Racket Reference</p></li>
<li>
<p>For the theoretical and practical motivation:
<br />
Ben Greenman.
<span style="font-style: italic">Deep and Shallow Types for Gradual Languages</span>.
PLDI 2022.
<br />
Paper at <a href="https://www2.ccs.neu.edu/racket/pubs/g-pldi-2022.pdf"><span class="url">https://www2.ccs.neu.edu/racket/pubs/g-pldi-2022.pdf</span></a>
<br />
Slides at <a href="https://cs.brown.edu/people/bgreenma/publications/apples-to-apples/g-pldi-2022-slides.pdf"><span class="url">https://cs.brown.edu/people/bgreenma/publications/apples-to-apples/g-pldi-2022-slides.pdf</span></a></p></li>
<li>
<p>Shallow Typed Racket is based on the Transient semantics from Reticulated Python:
<br />
Michael M. Vitousek, Cameron Swords, and Jeremy G. Siek.
<span style="font-style: italic">Big Types in Little Runtime: Open-World Soundness and Collaborative Blame for Gradual Type Systems</span>.
POPL 2017.
<br />
Paper at <a href="https://dl.acm.org/doi/10.1145/3009837.3009849"><span class="url">https://dl.acm.org/doi/10.1145/3009837.3009849</span></a></p></li>
<li>
<p>Vitousek’s dissertation has much more to say about Reticulated and
Transient:
<br />
Michael M. Vitousek.
<span style="font-style: italic">Gradual Typing for Python, Unguarded</span>.
PhD thesis, Indiana University, 2019.
<a href="https://hdl.handle.net/2022/23172"><span class="url">https://hdl.handle.net/2022/23172</span></a></p></li>
<li>
<p>Greenman’s dissertation says more about combining Deep and Shallow in
Typed Racket:
<br />
Ben Greenman.
<span style="font-style: italic">Deep and Shallow Types</span>.
PhD thesis, Northeastern University, 2020.
<a href="http://hdl.handle.net/2047/D20398329"><span class="url">http://hdl.handle.net/2047/D20398329</span></a></p></li></ul>Racket v8.7urn:http-blog-racket-lang-org:-2022-11-racket-v8-7-html2022-11-14T22:31:18Z2022-11-14T22:31:18ZThe Unknown Author
<p>Racket version 8.7 is now available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a></p>
<p>As of this release:</p>
<ul>
<li>
<p>Typed Racket offers Shallow and Optional modes for its gradual types. These modes lower the cost of interacting with untyped code, but provide less protection against buggy interactions. (see <a href="https://docs.racket-lang.org/ts-reference/behavior-of-types.html">https://docs.racket-lang.org/ts-reference/behavior-of-types.html</a> )</p></li>
<li>
<p>Racket uses Unicode 14.0 for character and string operations, and includes grapheme operations. DrRacket supports emojis. (see <a href="https://docs.racket-lang.org/gui/editor-overview.html#%28part._graphemes%29">https://docs.racket-lang.org/gui/editor-overview.html#%28part._graphemes%29</a> )</p></li>
<li>
<p>Racket supports RV64G (RISC-V).</p></li>
<li>
<p>Programmers can disable definition shadowing using <code>(#%declare #:require=define)</code>. (see <a href="https://docs.racket-lang.org/reference/module.html#%28form._%28%28quote._~23~25kernel%29._~23~25declare%29%29">https://docs.racket-lang.org/reference/module.html#%28form.<em>%28%28quote.</em>~23~25kernel%29._~23~25declare%29%29</a> )</p></li>
<li>
<p>The module dependency graphs available using raco dependencies-graph and DrRacket’s Module browser are faster and have new package filtering support. (see <a href="https://docs.racket-lang.org/drracket/module-browser.html#%28idx._%28gentag._39._%28lib._scribblings%2Fdrracket%2Fdrracket..scrbl%29%29%29">https://docs.racket-lang.org/drracket/module-browser.html#%28idx._%28gentag.<em>39.</em>%28lib._scribblings%2Fdrracket%2Fdrracket..scrbl%29%29%29</a> )</p></li>
<li>
<p>DrRacket is more responsive when killing programs that produce a lot of output.</p></li>
<li>
<p>Plot 3D allows negative altitude values (e.g., looking at the plot from “below”). (see <a href="https://docs.racket-lang.org/plot/plotting.html#%28def._%28%28lib._plot%2Fmain..rkt%29._plot3d%29%29">https://docs.racket-lang.org/plot/plotting.html#%28def._%28%28lib._plot%2Fmain..rkt%29._plot3d%29%29</a> )</p></li>
<li>
<p>The <code>scriblib/bibtex</code> and <code>scriblib/autobib</code> libraries support DOIs. (see <a href="https://docs.racket-lang.org/scriblib/autobib.html#%28def._%28%28lib._scriblib%2Fautobib..rkt%29._make-bib%29%29">https://docs.racket-lang.org/scriblib/autobib.html#%28def._%28%28lib._scriblib%2Fautobib..rkt%29._make-bib%29%29</a> )</p></li>
<li>
<p>There are many other repairs and improvements!</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Adit Cahya Ramadhan, Alex Harsányi, Bart van Strien, Ben Greenman, Bob Burger, Bogdan Popa, Cameron Moy, cheeze2000, D. Ben Knoble, Dan Anderson, Fred Fu, Geoffrey Knauth, Gustavo Massaccesi, J. Ryan Stinnett, Jack Firth, Jason Hemann, Jimmy McNutt, John Clements, Lîm Tsú-thuàn, M. Taimoor Zaeem, Mao Yifu, Matthew Flatt, Matthias Felleisen, Mike Sperber, Noah Ma, Oliver Flatt, Paulo Matos, Philip McGrath, Reuben Thomas, Robby Findler, Ryan Culpepper, Sam Phillips, Sam Tobin-Hochstadt, Samuel Bronson, Shu-Hung You, Sorawee Porncharoenwase, Sorin Muntean, Stephen Chang, William J. Bowman, and Winston Weinert</p>
<p>Official installers for Racket on many platforms are available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a>.</p>
<p>If you are new to Racket try our <a href="https://docs.racket-lang.org/getting-started/index.html">Getting started guide</a>.</p>
<p>Questions and feedback about the release are welcome on <a href="https://racket.discourse.group/">Discourse</a>.</p>Racket v8.6urn:http-blog-racket-lang-org:-2022-08-racket-v8-6-html2022-08-11T00:23:08Z2022-08-11T00:23:08ZThe Unknown Author
<p>Racket version 8.6 is now available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a></p>
<p>As of this release:</p>
<ul>
<li>
<p>Racket has an “equal-always?” primitive that equates values that will stay the same even if mutated. See <a href="https://docs.racket-lang.org/reference/Equality.html#%28def._%28%28quote._~23~25kernel%29._equal-always~3f%29%29">https://docs.racket-lang.org/reference/Equality.html#%28def.<em>%28%28quote.</em>~23~25kernel%29._equal-always~3f%29%29</a></p></li>
<li>
<p>This release uses a new build system, Zuo, which is implemented as a little language, in accordance with the ideas of Language Oriented Programming (LOP). The implementation has a single C file (plus libraries implemented in Zuo), so it compiles easily. The <code>zuo/build</code> library is modeled on <code>make</code> and Shake for tracking dependencies and build steps. See <a href="https://docs.racket-lang.org/zuo/index.html">https://docs.racket-lang.org/zuo/index.html</a> and https://racket.discourse.group/t/new-build-system-pushed-to-git-repo/873</p></li>
<li>
<p>Racket supports stencil vectors, which associate a virtual bitmask with a vector, enabling certain mask-equipped update operations. See <a href="https://docs.racket-lang.org/reference/stencil_vectors.html">https://docs.racket-lang.org/reference/stencil_vectors.html</a></p></li>
<li>
<p>Racket supports Arm64 machines running Windows.</p></li>
<li>
<p>Redex has support for simultaneous substitutions. See <a href="https://docs.racket-lang.org/redex/reference.html#%28form._%28%28lib._redex%2Freduction-semantics..rkt%29._substitute%29%29">https://docs.racket-lang.org/redex/reference.html#%28form._%28%28lib._redex%2Freduction-semantics..rkt%29._substitute%29%29</a></p></li>
<li>
<p>The Web Server provides control over the maximum number of concurrent connections via its “safety limits” construct. See <a href="https://docs.racket-lang.org/web-server-internal/dispatch-server-unit.html#%28part._safety-limits%29">https://docs.racket-lang.org/web-server-internal/dispatch-server-unit.html#%28part._safety-limits%29</a></p></li>
<li>
<p>The Web Server has improved logging performance and improved request parsing performance, reducing tail latencies.</p></li>
<li>
<p>The Web Server supports logging response status code via web-server/dispatchers/dispatch-logresp. See <a href="https://docs.racket-lang.org/web-server-internal/dispatch-logresp.html">https://docs.racket-lang.org/web-server-internal/dispatch-logresp.html</a></p></li>
<li>
<p>The <code>db</code> library supports custom types for PostgreSQL connections; see <code>pg-custom-type</code> for details. See <a href="https://docs.racket-lang.org/db/util.html#%28def._%28%28lib._db%2Futil%2Fpostgresql..rkt%29._pg-custom-type%29%29">https://docs.racket-lang.org/db/util.html#%28def._%28%28lib._db%2Futil%2Fpostgresql..rkt%29._pg-custom-type%29%29</a></p></li>
<li>
<p>The release includes many other repairs and changes!</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Alex Knauth, Alexander Shopov, Alexis King, Amirouche Amazigh BOUBEKKI, Andy Keep, Ashish SHUKLA, Bob Burger, Bogdan Popa, Cameron Moy, Chung-chieh Shan, David K. Storrs, FrankHB, Fred Fu, Gustavo Massaccesi, helado de brownie, J. Ryan Stinnett, Jack Firth, Jamie Taylor, Jason Hemann, Jens Axel Søgaard, Jimmy McNutt, Joel Dueck, John Clements, José Manuel Calderón Trilla, Kevin Tew, Laurent Orseau, Matt Audesse, Matthew Flatt, Matthias Felleisen, Mike Sperber, naveen srinivasan, Niklas Larsson, Noah Ma, Oscar Waddell, Pavel Panchekha, Phil Nguyen, Philip McGrath, Philippe Meunier, rgkirch, Robby Findler, Robert Postill, Ryan Culpepper, Sam Tobin-Hochstadt, Sergiu Ivanov, Sorawee Porncharoenwase, Stephen De Gabrielle, Vincent Lee, wackbyte, and Zibing Zhang</p>
<p>Link to package regressions issue for the 8.6 release: <a href="https://github.com/racket/racket/issues/4366">https://github.com/racket/racket/issues/4366</a></p>
<p>Official installers for Racket on many platforms are available from <a href="https://download.racket-lang.org/">https://download.racket-lang.org/</a>.</p>
<p>If you are new to Racket try our <a href="https://docs.racket-lang.org/getting-started/index.html">Getting started guide</a>.</p>
<p>Questions and feedback about the release are welcome on <a href="https://racket.discourse.group/">Discourse</a>.</p>Racket v8.5urn:http-blog-racket-lang-org:-2022-04-racket-v8-5-html2022-04-30T21:29:29Z2022-04-30T21:29:29ZThe Unknown Author
<p>Racket version 8.5 is now available from <a href="https://download.racket-lang.org">https://download.racket-lang.org</a>.</p>
<p>As of this release:</p>
<ul>
<li>
<p>Racket’s new <code>-y</code> flag automatically keeps compiled files up to date, reducing subsequent load times.</p></li>
<li>
<p>Error-message realms allow Racket-hosted languages to adapt and rewrite error messages to make sense in a particular context.</p></li>
<li>
<p>Nonprivileged users can control package installation scope using an “other-version” directory in the addon-dir.</p></li>
<li>
<p>Racket CS runs on platforms where native-code generation is not currently supported (e.g., s390x or ppc64). See “README.txt” in the source distribution for more information on the —enable-pb flag to configure.</p></li>
<li>
<p>DrRacket’s new ‘Reopen Closed Tab’ file menu item will open previously closed tabs.</p></li>
<li>
<p>Typed Racket has support for the <code>xml</code> library; use <code>typed/xml</code>.</p></li>
<li>
<p>Rackunit reports source locations for failed test cases in the Typed Racket language.</p></li>
<li>
<p>Plot has violin plots and improved box-and-whisker plots.</p></li>
<li>
<p>Boxes are supported alongside lists, vectors etc. in place-channel messages.</p></li>
<li>
<p>Those who manually configure Racket CS to use Zlib compression for compiled code should be aware of CVE–2018–25032; the next release and the current snapshot builds use a newer, safer version of zlib.</p></li>
<li>
<p>The release includes many other repairs and changes!</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Alex Harsányi, Alexander Shopov, Alexis King, Andrew Mauer-Oats, Ben Greenman, Benedek Szilvasy, Bert De Ketelaere, Bogdan Popa, Cameron Moy, Chung-chieh Shan, Fred Fu, Gustavo Massaccesi, J. Ryan Stinnett, Jamie Taylor, Joel Dueck, John Clements, Joseph Griego, Khadija Sidhpuri, Laurent Orseau, Maciej Barć, Matthew Flatt, Matthias Felleisen, Mike Sperber, Noah Ma, Philip McGrath, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Sorawee Porncharoenwase, Stephen De Gabrielle, Tim Jervis, and Trevor Paley</p>
<p>Link to package regressions issue for the 8.5 release: <a href="https://github.com/racket/racket/issues/4202">https://github.com/racket/racket/issues/4202</a></p>Racket v8.4urn:http-blog-racket-lang-org:-2022-02-racket-v8-4-html2022-02-09T18:48:20Z2022-02-09T18:48:20ZThe Unknown Author
<p><em>posted by John Clements</em></p>
<p>Racket version 8.4 is now available from <a href="https://download.racket-lang.org">https://download.racket-lang.org</a>.</p>
<ul>
<li>
<p>Command-line Racket provides a new expression editor by default for its read-eval-print loop (REPL). The new REPL is based on the Chez Scheme expression editor, but extended to use the same language-sensitive syntax coloring and indentation tools as DrRacket.</p></li>
<li>
<p>Typed Racket adds a kind system, preventing programmers from writing nonsensical type expressions. It checks whether type constructors are correctly applied to arguments, and separates type constructors from polymorphic types. The <code>:kind</code> form enables checking the kind of a type expression at the REPL. The new system also correctly rejects some ill-formed recursive types.</p></li>
<li>
<p>Racket has a <code>file-or-directory-stat</code> for unified information about file-system objects.</p></li>
<li>
<p>DrRacket shows the region affected by an <code>#;</code> S-expression comment by fading the commented-out region.</p></li>
<li>
<p>Racket on Chez has faster multiplication and division for some numbers.</p></li>
<li>
<p>Web server: The files dispatcher supports all standard caching-related HTTP response headers (e.g., Cache-Control).</p></li>
<li>
<p>Web server: A new dispatcher captures the common pattern of processing HTTP requests and responses in a layered fashion.</p></li>
<li>
<p>The Web Server supports use of the Cache-Control header, and includes a new wrapping dispatcher.</p></li>
<li>
<p>Expander: add “portal” syntax to support new forms of syntax object binding.</p></li>
<li>
<p>Documentation search is improved.</p></li>
<li>
<p>Some hash operations support an optional <code>try-order?</code> argument.</p></li>
<li>
<p>The plot-metrics interface has documentation.</p></li>
<li>
<p>Fonts support OpenType feature settings.</p></li>
<li>
<p>The Gui library has improved support for Wayland.</p></li>
<li>
<p>The computation of quadratic roots is further improved.</p></li>
<li>
<p>The <code>set/c</code> contract adds support for random generation.</p></li>
<li>
<p>DrRacket’s interactions window supports #lang-specific coloring and indentation.</p></li>
<li>
<p>DrRacket’s parenthesis-based keyboard shortcuts change based on the parentheses that each different #lang uses.</p></li>
<li>
<p>The release includes many other bug repairs and other improvements!</p></li></ul>
<p>Transition/Update notes:</p>
<ul>
<li>
<p>To turn off expeditor and make Racket’s REPL go back to the old editline/readline-based editor, use the command</p>
<p>,input readline</p></li></ul>
<p> and then restart Racket. Get back to the new expression editor with</p>
<pre><code>,input expeditor</code></pre>
<p> To toggle color mode for the new expression editor, use one of the following, which does not require restarting Racket:</p>
<pre><code>,color #false
,color #true</code></pre>
<ul>
<li>
<p>Support for comment fading in DrRacket requires an increment to the “WXME” format version so files with non-text content written by DrRacket v8.4 will open only in v8.4 and later. This does not affect files that consist only of unicode text.</p></li>
<li>
<p>The addition of the kind system to Typed Racket means that certain mild abuses of the type system no longer type check, most notably the ‘application’ of a polymorphic type.</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Alex Harsányi, Alex Knauth, Alexander Shopov, Alexis King, Andrew Mauer-Oats, Andy Keep, Ayman Osman, Ben Greenman, Bob Burger, Bogdan Popa, Cameron Moy, D. Ben Knoble, Fred Fu, Greg Hendershott, Gustavo Massaccesi, Jamie Taylor, Jarhmander, Jesse Alama, Joel Dueck, John Clements, Jordan Johnson, Laurent Orseau, Leif Andersen, Marc Burns, Matthew Flatt, Matthias Felleisen, Mike Engelhart, Mike Sperber, Noah Ma, Oscar Waddell, Pavel Panchekha, Philip McGrath, rgkirch, Robby Findler, Sam Tobin-Hochstadt, Sergiu Ivanov, Sorawee Porncharoenwase, Stefan Schwarzer, Stephen De Gabrielle, Tony Garnock-Jones, Viko Riféo, and Zachary Mao</p>
<p>Link to package regressions issue for the 8.4 release: <a href="https://github.com/racket/racket/issues/4125">https://github.com/racket/racket/issues/4125</a></p>
<p>Feedback welcome.</p>Racket v8.3urn:http-blog-racket-lang-org:-2021-11-racket-v8-3-html2021-11-06T19:52:29Z2021-11-06T19:52:29ZThe Unknown Author
<p><em>posted by John Clements</em></p>
<p>Racket version 8.3 is now available from <a href="https://download.racket-lang.org">https://download.racket-lang.org</a>.</p>
<ul>
<li>
<p>Racket removes syntax arming and disarming in favor of a simpler system of protected syntax operations, along with other updates to the syntax system.</p></li>
<li>
<p>DrRacket has improved support for custom #lang languages.</p></li>
<li>
<p>Typed Racket improves precision for type-checking of non-polymorphic structures, existential types, and certain binding forms.</p></li>
<li>
<p>Scribble HTML output gains a button to show / hide the table of contents on mobile platforms.</p></li>
<li>
<p>Redex’s stepper’s GUI shows IO-judgment form rule names.</p></li>
<li>
<p>Many bug fixes!</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Adam Zaiter, Alex Knauth, Alexis King, Ayman Osman, Ben Greenman, Bob Burger, Bogdan Popa, Brian Adkins, Cameron Moy, Carl Eastlund, Dan Holtby, Dominik Pantůček, Eli Barzilay, Ethan Leba, Fred Fu, Greg Hendershott, Gustavo Massaccesi, J. Ryan Stinnett, Jason Hemann, Jay McCarthy, Jesse Alama, Joel Dueck, John Clements, Jonathan Simpson, Kartik Sabharwal, Laurent Orseau, Lehua Ding, Maciej Barć, Marc Burns, Matthew Flatt, Matthias Felleisen, Michael Ballantyne, Mike Sperber, Noah Ma, Paulo Matos, Pavel Panchekha, Philip McGrath, Robby Findler, Ryan Culpepper, Ryan Sundberg, Sage Gerard, Sam Tobin-Hochstadt, Shu-Hung You, Sorawee Porncharoenwase, Stefan Schwarzer, Stephen De Gabrielle, Vincent St-Amour, William J. Bowman, minor-change, and yjqww6</p>
<p>Feedback Welcome</p>Racket v8.2urn:http-blog-racket-lang-org:-2021-07-racket-v8-2-html2021-07-18T21:07:00Z2021-07-18T21:07:00ZThe Unknown Author
<p><em>posted by John Clements</em></p>
<p>Racket version 8.2 is now available from <a href="https://download.racket-lang.org">https://download.racket-lang.org</a>.</p>
<ul>
<li>
<p>Racket CS improved the performance of large-integer arithmetic.</p></li>
<li>
<p>Racket has improved support for layered and tethered installation.</p></li>
<li>
<p>Racket CS supports nonatomic allocation via ffi/unsafe.</p></li>
<li>
<p>Cross-compilation works fully with the <code>raco cross</code> tool, which is distributed separately as the “raco-cross” package.</p></li>
<li>
<p>DrRacket has performance improvements when editing files with picts containing large bitmaps.</p></li>
<li>
<p>Typed Racket more consistently refines field types of non-polymorphic structs.</p></li>
<li>
<p>Printing of values is unified across the teaching language implementations and the stepper.</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Alex Harsányi, Alex Knauth, Amirouche, Andrew Mauer-Oats, Bob Burger, Bogdan Popa, Cameron Moy, Crystal Jacobs, Dale Vaillancourt, Diego A. Mundo, Fred Fu, Greg Hendershott, Gustavo Massaccesi, Jack Firth, Jamie Taylor, Jarhmander, Jason Hemann, Jay McCarthy, Jeffrey D. Swan, Jens Axel Søgaard, Jesse Alama, John Clements, Laurent Orseau, Lazerbeak12345, Matthew Flatt, Matthias Felleisen, Mike Sperber, Nada Amin, Noah Ma, Oscar Waddell, Paulo Matos, Pavel Panchekha, Philip McGrath, Ray Racine, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Shu-Hung You, Sorawee Porncharoenwase, Stephen Chang, Thorsten Blum, Tony Garnock-Jones, WarGrey Gyoudmon Ju, William J. Bowman, Yu Fang, and minor-change.</p>
<p>Feedback Welcome</p>Racket v8.1urn:http-blog-racket-lang-org:-2021-05-racket-v8-1-html2021-05-05T01:28:50Z2021-05-05T01:28:50ZThe Unknown Author
<p><em>posted by John Clements</em></p>
<p>Racket version 8.1 is now available from <a href="https://racket-lang.org/">https://racket-lang.org/</a>.</p>
<ul>
<li>
<p>DrRacket tabs can be dragged, and have new close buttons.</p></li>
<li>
<p>Racket CS supports cross-compilation using <code>raco exe</code>.</p></li>
<li>
<p>Racket CS supports Android on 32-bit and 64-bit ARM processors.</p></li>
<li>
<p>The database library supports running queries in OS threads.</p></li>
<li>
<p>Check-Syntax arrows correctly identify the definition site of identifiers with contracts.</p></li>
<li>
<p>Racket CS performance has improved for structure predicates and accessors</p></li>
<li>
<p>Racket CS is faster at multiplying extremely large numbers and dividing large integers.</p></li>
<li>
<p>Racket CS allows callbacks to raise exceptions if they are annotated with <code>#:callback-exns?</code>.</p></li>
<li>
<p>New ephemeron hash tables simplify the implementation of tables where keys can refer to values.</p></li>
<li>
<p>Typed Racket supports for/foldr.</p></li>
<li>
<p>The stepper works for #lang htdp/*sl.</p></li>
<li>
<p>Struct signatures work for the ASL teaching language.</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Alex Harsányi, Alex Knauth, Alexander Shopov, Alexis King, Andrew Mauer-Oats, Anish Athalye, Ben Greenman, Bert De Ketelaere, Bob Burger, Bogdan Popa, Brian Adkins, Cameron Moy, David Van Horn, Dexter Lagan, Dominik Pantůček, Fred Fu, Greg Hendershott, Gustavo Massaccesi, Hazel Levine, Ismael Luceno, Jack Firth, Jarhmander, John Clements, Jörgen Brandt, Laurent Orseau, Lazerbeak12345, Matthew Flatt, Matthias Felleisen, Micah Cantor, Mike Sperber, Noah Ma, Patrick McCarty, Paulo Matos, Pavel Panchekha, Philip McGrath, Philippe Meunier, R. Kent Dybvig, Robby Findler, Ryan Culpepper, Ryan Kramer, Sam Tobin-Hochstadt, Sergiu Ivanov, Shu-Hung You, Sorawee Porncharoenwase, Stephen De Gabrielle, William J. Bowman, bmitc, xxyzz, yjqww6, and ymdarake.</p>
<p>Feedback Welcome!</p>Racket v8.0urn:http-blog-racket-lang-org:-2021-02-racket-v8-0-html2021-02-14T01:29:25Z2021-02-14T01:29:25ZThe Unknown Author
<p><em>posted by John Clements</em></p>
<p>Racket version 8.0 is now available from <a href="https://racket-lang.org/">https://racket-lang.org/</a>.</p>
<p><strong>* Racket 8.0 is here!</strong>*</p>
<p>Racket 8.0 marks the first release where Racket CS is the default implementation. Creating, polishing, and adopting Racket CS has been a 4-year effort involving the entire Racket community. At this point, Racket CS is faster, easier to maintain and develop, and compatible with existing Racket programs. Racket CS will continue to improve, but at this point it is ready to be the primary variant of Racket for all Racketeers. More details about the current state of Racket CS are available in the recent <a href="https://blog.racket-lang.org/2021/01/racket-status.html">blog post</a>.</p>
<p>Other notable changes:</p>
<ul>
<li>
<p>Racket CS has better parallel garbage collection, a 10%–30% reduction in the size of generated code, and various targeted optimizations.</p></li>
<li>
<p>A rewrite of the test-engine package allows the <code>#lang</code> versions of teaching languages to produce linked test-failure messages.</p></li>
<li>
<p>The release comes with a new mark-up DSL for composing text to appear in the REPL (simple-tree-text-markup).</p></li>
<li>
<p>Redex has an added <code>define-overriding-judgment</code> form and improved error source location reporting.</p></li>
<li>
<p>Windows scrolling speed reflects the system preference.</p></li>
<li>
<p>The db package uses the utf8mb4 charset for MySQL connections.</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Alex Harsányi, Alex Knauth, Alexander Shopov, Alexis King, Bert De Ketelaere, Bogdan Popa, Cameron Moy, David Van Horn, Davis Silverman, Dominik Pantůček, Florian Weimer, Fred Fu, Gustavo Massaccesi, Jack Firth, James Wilcox, Joel Dueck, John Clements, Jonathan Chan, Lîm Tsú-thuàn, Mark, Matthew Flatt, Matthias Felleisen, Michael Ballantyne, Mike Sperber, Paulo Matos, Pavel Panchekha, Peter Zhong, Phil Nguyen, Philip McGrath, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Sergiu Ivanov, Shu-Hung You, Sorawee Porncharoenwase, Stefan Schwarzer, Stephen Chang, Stephen De Gabrielle, Walter H. Yang, WarGrey Gyoudmon Ju, kurinoku, xxyzz, and yjqww6</p>Racket Compiler and Runtime Status: January 2021urn:http-blog-racket-lang-org:-2021-01-racket-status-html2021-01-24T08:00:00Z2021-01-24T08:00:00ZThe Unknown Author
<p><span style="font-style: italic">posted by Matthew Flatt</span></p>
<p>With the upcoming version 8.0 release, Racket on Chez Scheme (Racket
CS) will become the default implementation of Racket. This report discusses the
implications of that change, continuing a series that was originally
about Racket CS; the most recent previous report was
<a href="http://blog.racket-lang.org/2020/02/racket-on-chez-status.html">the February 2020 report</a>. The original
<a href="http://blog.racket-lang.org/2018/01/racket-on-chez-status.html">January 2018 report</a> explains the motivation
behind throwing out around 200k lines of C code to replace it with around
150k lines of Scheme and Racket code.</p>
<h1><a name="(part._.Switching_to_.Racket_.C.S)"></a>Switching to Racket CS</h1>
<p>For most users, the differences between Racket CS and Racket BC
(“before Chez”) may be too small to notice. The installer and
executables will be larger, because they contain machine code instead
of bytecode, and some programs may run a little faster. Otherwise,
Racket programs are supposed to run the same.</p>
<p>To test this, we’ve built and tested every package available from
<a href="https://pkgs.racket-lang.org">the package server</a> on
Racket CS over the past several months and compared the
<a href="https://github.com/racket/racket/issues/3457">results</a>
with those from Racket BC version 7.9. Out of more than 1800 packages,
currently only 12 now fail to compile, and 5 others fail some of their
tests. The new build failures, as well as 2 of the 5 new test
failures, are the result of changes at the C API level. Several
packages already have pull requests to fix them, and we hope others
will be fixed soon, too. The remaining 3 test failures are differences
in thread scheduling that provoked existing bugs in the packages.</p>
<p>Although Racket CS will be the default for v8.0, Racket BC will
remain available through a “More Installers” link on the download
page for the foreseeable future. So, Racket users will still have the
option of falling back to the old runtime system and compiler if
something goes wrong, or if they need a package that does not yet work
on Racket CS.</p>
<h1><a name="(part._.Progress_in_the_.Past_.Year)"></a>Progress in the Past Year</h1>
<p>During 2020, Racket CS became a little faster and a little smaller,
and many corners of the implementation were repaired or made more
compatible with the BC implementation. The planned changes that were
on the <a href="http://blog.racket-lang.org/2020/02/racket-on-chez-status.html">previous report’s roadmap</a> all happened!
In addition, we introduced an AArch64 backend and ported to run
natively on M1 Macs. Finally, we made the Chez Scheme garbage
collector run in parallel, which brought the performance of
places-based parallelism in Racket CS about on par with BC.</p>
<p>Building Racket CS no longer involves first building Racket BC as a
way to bootstrap Chez Scheme. Instead, Chez Scheme bootstraps itself
on any supported platform using a new portable bytecode (pb) backend.
Bootfiles for pb mode are checked into a separate Git repository that
is used in a submodule-like way, but bootfiles can always be built
from source by using an existing Racket build; the bootstrap
implementation is now detangled so that much older Racket versions in
the v7 series can work for bootstrapping.</p>
<h1><a name="(part._.Benchmark_.Performance)"></a>Benchmark Performance</h1>
<p>For traditional Scheme benchmarks, not much has changed in the
results. A plot is practically indistinguishable from the one in the
<a href="http://blog.racket-lang.org/2020/02/racket-on-chez-status.html">previous report</a>.</p>
<p>For the shootout benchmarks, which measure more Racket-specific
functionality and libraries, there’s some improvement, especially
toward the end of the table. (Shorter is better.) The light-blue line
shows the results from the previous report (which corresponds to
version 7.6), so a shorter “CS” bar means improvement there. The
improvements mostly reflect unboxed floating-point arithmetic.</p>
<blockquote class="SCentered">
<p><img src="/img/posts/2021-01-24-racket-status/pict.svg" style="vertical-align: -0.0px; margin: -3px -3px -3px -3px;" type="image/svg+xml" /></p></blockquote>
<p>Below is another set of microbenchmarks from the
<span class="stt">racket-benchmarks</span> package, comparing Racket CS to BC. Some points
to note:</p>
<ul>
<li>
<p>CS is usually faster than BC. (Shorter is better.)</p></li>
<li>
<p>The fastest relative CS runs are much faster than the fastest
relative BC runs; that is, the shortest blue bars are much
shorter than the shortest red bars. Although it’s difficult to
extract from these plots, the difference is really that CS
performs more consistently, so it’s slowest relative runs are
not as slow as the slowest relative BC runs.</p></li>
<li>
<p>These benchmarks mostly compare subsystems that are implemented
in C for BC to subsystems implemented in Scheme and Racket for
CS. That’s the key and motivating point —
<wbr /> the maintenance
advantage, more than the performance advantage.</p></li></ul>
<blockquote class="SCentered">
<p><img src="/img/posts/2021-01-24-racket-status/pict_2.svg" style="vertical-align: 0px; margin: -3px -3px -3px -3px;" type="image/svg+xml" /></p></blockquote>
<p>For the rest of this report, the plots will show CS slower or bigger,
but gradually approaching BC performance. You should not read that as
“CS is slower than BC.” This report is about the parts of the
implementation where we spent time last year, and we don’t dwell on
parts where no improvement was needed.</p>
<p><span class="Smaller"><span style="font-style: italic"><span style="font-weight: bold">About the measurements:</span> Benchmarks are in the
<a href="https://github.com/racket/racket/tree/master/pkgs/racket-benchmarks/tests/racket/benchmarks"><span class="stt">"racket-benchmark"</span></a>
package in the <span class="stt">"shootout"</span>, <span class="stt">"control"</span>,
<span class="stt">"hash"</span>, and <span class="stt">"chaperone"</span> directories. We dropped some
of the <span class="stt">"control"</span> benchmarks because they take to long to run
on BC, which means that the plots here understate how much more
consistently CS performs compared to BC.</span></span></p>
<h1><a name="(part._.Startup_and_.Memory_.Use)"></a>Startup and Memory Use</h1>
<p>Load times improved for Racket CS:</p>
<blockquote class="SCentered">
<p><img src="/img/posts/2021-01-24-racket-status/pict_3.svg" style="vertical-align: -0.0px; margin: -3px -3px -3px -3px;" type="image/svg+xml" /></p></blockquote>
<p>That’s mostly due to reduced code size:</p>
<blockquote class="SCentered">
<p><img src="/img/posts/2021-01-24-racket-status/pict_4.svg" style="vertical-align: -0.0px; margin: -3px -3px -3px -3px;" type="image/svg+xml" /></p></blockquote>
<p>On a different scale and measuring peak memory use instead of final
memory use for DrRacket start up and exit:</p>
<blockquote class="SCentered">
<p><img src="/img/posts/2021-01-24-racket-status/pict_5.svg" style="vertical-align: -0.0px; margin: -3px -3px -3px -3px;" type="image/svg+xml" /></p></blockquote>
<p>The large drop in peak memory use for DrRacket CS is due to
garbage-collection improvements for old generations in large heaps,
where old-generation objects tend to be marked in place instead of
copied.</p>
<p><span class="Smaller"><span style="font-style: italic"><span style="font-weight: bold">About the measurements:</span> These results were gathered by running <span class="stt">racket</span> with the
arguments <span class="stt">-l racket</span> or <span class="stt">-l
drracket</span>. The command further included <span class="stt">-W "debug@GC" -e</span><span class="stt">
</span><span class="stt"></span><span class="stt">’</span><span class="stt">(collect-garbage)</span><span class="stt">’</span><span class="stt"> -e </span><span class="stt">’</span><span class="stt">(collect-garbage)</span><span class="stt">’</span><span class="stt"></span>, and reported sizes are
based on the logged memory use before the second collection. For the
“BC” line, the reported memory use includes the first number that is
printed by logging in square brackets, which is the memory occupied by
code outside of the garbage collector’s directly managed space.
Baseline memory use was measured by setting the
<span class="stt">PLT_GCS_ON_EXIT</span> environment variable and running with
<span class="stt">-n</span>, which is has the same effect as <span class="stt">-e
'(collect-garbage)' -e '(collect-garbage)'</span>. DrRacket was initialized
with <a class="RktModLink Sq" data-pltdoc="x" href="https://docs.racket-lang.org/reference/index.html"><span class="RktSym">racket/base</span></a> as the default language; also,
background expansion was disabled, because measuring memory use is
tricky on Racket BC.</span></span></p>
<h1><a name="(part._.Build_.Times)"></a>Build Times</h1>
<p>Compile times improved for Racket CS:</p>
<blockquote class="SCentered">
<p><img src="/img/posts/2021-01-24-racket-status/pict_6.svg" style="vertical-align: -0.0px; margin: -3px -3px -3px -3px;" type="image/svg+xml" /></p></blockquote>
<p>This improvement, combined with others, makes the CS distribution now
build a little faster from source than a BC build, and it uses about
20% less memory than the BC build. The following two
plots use the same scale, where the foreground blue or red line shows
memory use (vertical) plotted over time (horizontal) as recorded on
each major collection (see
<a href="https://build-plot-cs.racket-lang.org/about.html">this
page</a> for a detailed description):</p>
<p></p>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td valign="top">
<p><span style="color: blue"><span style="font-weight: bold">Racket CS</span></span></p></td>
<td valign="top">
<p><span class="hspace"> </span></p></td>
<td align="right">
<p><img src="/img/posts/2021-01-24-racket-status/build-cs.svg" alt="" height="300.0pt" width="400.0pt" /></p></td></tr>
<tr>
<td valign="top">
<p><span class="Smaller"></span></p></td>
<td valign="top">
<p><span class="hspace"> </span></p></td>
<td align="right">
<p><span class="Smaller"></span></p></td></tr>
<tr>
<td valign="top">
<p><span style="color: red"><span style="font-weight: bold">Racket BC</span></span></p></td>
<td valign="top">
<p><span class="hspace"> </span></p></td>
<td align="right">
<p><img src="/img/posts/2021-01-24-racket-status/build-r.svg" alt="" height="300.0pt" width="400.0pt" /></p></td></tr></tbody></table>
<p>A shorter build time in less space represents a big milestone for
Racket CS. Even though most Racket users start with a pre-built
distribution, build time measures end-to-end performance across many
parts of the implementation, and build performance correlates well
with end-to-end performance in many Racket applications.</p>
<p>The build plots above are for a sequential (i.e., single-threaded)
build. More typically, Racket is built on machines with more CPUs, and
build times easily benefit from process-like parallelism. Over the
past year, garbage-collector improvements for parallel collection have
made build times with place-based parallelism dramatically shorter on
a machine with 4 hyperthreaded cores (although build dependencies
ultimately limit parallelism). Since parallel collection debuted in
Racket CS v7.9 but has improved since, we show v7.9 as an intermediate
point:</p>
<blockquote class="SCentered">
<p><img src="/img/posts/2021-01-24-racket-status/pict_7.svg" style="vertical-align: -0.0px; margin: -3px -3px -3px -3px;" type="image/svg+xml" /></p></blockquote>
<p>As the plot shows, as of the previous report (before parallel garbage
collection), trying to build with multiple places was
counterproductive. The speedup from places-based parallelism in v8.0
is finally close to BC’s speedup, which is about the same as using
process-based parallelism (but with the advantage of staying within a
single Racket process). The parallelism available from BC remains a
little higher, because its implementation of places uses completely
separate allocation heaps, while parallelism in CS use a single heap.</p>
<p><span class="Smaller"><span style="font-style: italic"><span style="font-weight: bold">About the measurements:</span> The compile-time results were gathered by using <span class="stt">time</span> in
a shell a few times and taking the median. The build plots were
generated using the <span class="stt">"plt-build-plot"</span> package, which drives a
build from source and plots the results. The parallelism results were
generated by starting with an in-place installation, using <span class="stt">raco</span><span class="stt">
</span><span class="stt">setup </span><span class="stt">–</span><span class="stt">fast-clean</span> and <span class="stt">rm doc/docindex.sqlite</span> to start from a
clean state, and getting elapsed real time with <span class="stt">time racro setup</span><span class="stt">
</span><span class="stt"></span><span class="stt">–</span><span class="stt">jobs 8</span>, and dividing by elapsed time from build plots (which is not
exactly the same build job, but is close).</span></span></p>
<h1><a name="(part._.Reflection_and_.Outlook)"></a>Reflection and Outlook</h1>
<p>We tried to declare success and move on <a href="http://blog.racket-lang.org/2020/02/racket-on-chez-status.html">a year
ago</a>, but that didn’t work. This time really is different, because
Racket CS is ready to be the default Racket implementation. Time will
tell whether that difference is enough to allow a different focus in
the coming year. Given how much the CS compilation strategy
(ahead-of-time) differs from the BC strategy (bytecode compilation
plus a JIT), it’s not clear that the compile time, load time, and
memory footprint differences between BC and CS can be reduced further.</p>
<p>In terms of maintainability, one possible direction for improvement is
to shift even more Racket support into the Chez Scheme layer.
Gustavo’s decision to implement type reconstruction as a Chez Scheme
pass was good call. Contributor <span class="stt">yjqww6</span>’s implementation of
Racket-style lifting as a Chez Scheme pass was a clear improvement for
Racket CS, because it eliminated a larger pass on the “schemify”
side and implemented at a better layer of abstraction with less
interference on local optimizations. Similarly, extending Chez
Scheme’s support for weak hash tables, which was not difficult, allowed us
to discard a complex and slower implementation in the “rumble”
Racket-adapter layer. More direct support for left-to-right evaluation
guarantees and cross-linklet inlining could further reduce the
schemify layer, and maybe one day eliminate it.</p>
<p>We’ve mostly kept BC and CS in sync, so far, but moving forward,
Racket BC will not necessarily get new functionality that is added to
CS. After all, the point of CS is to eventually shed technical debt in
BC. This divergence has already started: Racket CS fully supports M1
Macs, but Racket BC runs only in interpreted mode or as x86_64 (i.e.,
we did not add an AArch64 JIT to Racket BC).</p>
<p><span style="font-style: italic">Thanks to Sam, Ryan, Robby, Matthias, and John for improving
this report. Special thanks to Sam, Paulo, and Robby for moving CS
testing forward. Many contributors helped track down and repair CS
bugs, and besides others mentioned, thanks to Shu-Hung, Sorawee, and
Bogdan for tackling some substantial repairs.</span></p>Racket v7.9urn:http-blog-racket-lang-org:-2020-11-racket-v7-9-html2020-11-02T21:37:40Z2020-11-02T21:37:40ZThe Unknown Author
<p>Racket version 7.9 is now available from <a href="https://racket-lang.org">https://racket-lang.org/</a></p>
<ul>
<li>
<p>Racket CS may become the default Racket implementation in the next release. If, between this release and the next, no bugs are discovered in Racket CS that are more serious than those typically discovered in Racket BC, then Racket CS will become the default for the next release. (Serious Racket CS bugs were found since the v7.8 release, but they’re ever fewer and farther between.)</p></li>
<li>
<p>Various improvements to Check Syntax arrows and renaming, thanks to Sorawee Porncharoenwase.</p></li>
<li>
<p>Full support for struct type properties in Typed Racket, developed by Fred Fu.</p></li>
<li>
<p>Racket CS now supports parallel garbage collection, along with improvements for place-local-allocation and incremental promotion.</p></li>
<li>
<p>Unix platforms now use the XDG filesystem conventions for the locations of per-user configuration and library files by default, but legacy paths are still used where they exist already.</p></li>
<li>
<p>Scribble improvements by Sorawee Porncharoenwase, William Bowman, and Shu-Hung You.</p></li>
<li>
<p>Improvements to the plot library from Alex Harsányi and Bert De Ketelaere.</p></li>
<li>
<p>The <code>datum</code> form from <code>syntax/datum</code> works with syntax pattern variables and <code>syntax-parse</code> attributes.</p></li>
<li>
<p>Unicode input works with recent versions of libedit in addition to libreadline. On Mac OS, a compatible version of libedit is included with Racket.</p></li></ul>
<p>The following people contributed to this release:</p>
<p>5pyd3r, A. Green, Adam Michael, Alex Bartholomew, Alex Harsányi, Alex Knauth, Alexander B. McLin, Alexander Shopov, Alexis King, Andrew Mauer-Oats, Andy Keep, Ayman Osman, Barak A. Pearlmutter, Ben Greenman, Bert De Ketelaere, Bob Burger, Bodie Solomon, Bogdan Popa, Bruce Mitchener, Chris Frisz, Christian Häggström, Cullen Jennings, Daniel Brunner, DeathKing, Dionna Amalie Glaze, Dominik Pantůček, Evan Minsk, Fred Fu, Gavin Whelan, Graham Watt, Griffin Byatt, Gustavo Massaccesi, Göran Weinholt, Jack Firth, Jamie Taylor, Jason Felice, Jason Hemann, Jasper Pilgrim, Jay McCarthy, Jesse Alama, Jin-Ho King, John Clements, Jon Zeppieri, Juan Francisco Cantero Hurtado, Jéssica Milaré, Jörgen Brandt, Laurent Orseau, Leo Uino, Matthew D. Miller, Matthew Flatt, Matthias Felleisen, Michael Lenaghan, Mike Sperber, Mohamed Akram, Neal Alexander, Nick Fitzgerald, Oscar Waddell, Paulo Matos, Pavel Panchekha, Peter Klein, Philip McGrath, Quentin Dufour, R. Kent Dybvig, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Shu-Hung You, Sorawee Porncharoenwase, Stephen Chang, Stephen De Gabrielle, Steven Watson, Taekyung, Ted Lemon, Thorsten Blum, Virgil Hou, William J. Bowman, combinatorylogic, deeglaze, evdubs, john, tokomikea, xxyzz, yjqww6, 陈梓 立, and 靈</p>(chaperone (tenth RacketCon))urn:http-blog-racket-lang-org:-2020-10-tenth-racketcon-html2020-10-06T15:13:00Z2020-10-06T15:13:00ZThe Unknown Author
<p><em>posted by Matthew Flatt</em></p>
<p><a href="https://con.racket-lang.org/">RacketCon</a> is next week!</p>
<p>Naturally, RacketCon is virtual this year. So, the bad news is that we don’t get to be in the same room. The good news is that no one has to travel across the country or around the world to attend. RacketCon is open to all with no registration required.</p>
<p>Even in virtual mode, we don’t have to completely give up on social events. Instead of our typical brewpub gathering, we’ll have a BYOB virtual Biergarten via <a href="https://gather.town/app/POxm4HbriLKltrzP/racketlang">Gather</a> on Friday, October 16 at 6:00pm UTC. That’s 2:00pm Eastern and only noon in the Mountain time zone where I’ll be — but, hey, it’s Friday.</p>
<p>Talks start on Saturday at 2:00pm UTC, which is 10:00am Eastern and 7:00am Pacific. (Note that the <a href="https://con.racket-lang.org/">schedule on the RacketCon page</a> will adapt to your local timezone.) Kathi Fisler is our keynote speaker, and we’ll also hear talk from Chris Webber, Konrad Hinsen, Brian Adkins, Sage Gerard, Pierce Darragh, Gustavo Massaccesi. In each case, there will be a pre-recorded talk video followed by a live Q&A with the speakers and further Q&A in the chat channels.</p>
<p>On Sunday, Sam Tobin-Hochstadt will talk about the State of Racket, followed by the Racket Town Hall. Then it’s more talks from Jesse Alama, Peter Zhong, Panicz Godek, Stephen De Gabrielle, and Ben Greenman, and finally an AMA with Matthias Felleisen.</p>
<p>The talks are scheduled with a lot of time in between, so hop back over to <a href="https://gather.town/app/POxm4HbriLKltrzP/racketlang">Gather</a> during those breaks to chat more with other Racketeers.</p>Racket v7.8urn:http-blog-racket-lang-org:-2020-08-racket-v7-8-html2020-08-03T15:13:00Z2020-08-03T15:13:00ZThe Unknown Author
<p>Racket version 7.8 is now available from <a href="https://racket-lang.org">https://racket-lang.org/</a></p>
<ul>
<li>
<p>Racket CS may become the default Racket implementation in the next release. With the improvements in this release, Racket CS provides all of the functionality of Racket BC (the current default implementation). If, between this release and the next, no bugs are discovered in Racket CS that are more serious than those typically discovered in Racket BC, then Racket CS will become the default for the next release.</p></li>
<li>
<p>Racket CS supports AArch32 and AArch64, including places and futures. The implementation should be considered experimental in this initial release.</p></li>
<li>
<p>Racket CS supports an “incremental” garbage-collection mode that can eliminate long GC pauses for some applications, such as animations and interactive games.</p></li>
<li>
<p>Racket CS unboxes local floating-point arithmetic (like Racket BC).</p></li>
<li>
<p>DrRacket’s spell check features lower overhead and has fewer bugs.</p></li>
<li>
<p>Web Server performance under high concurrency is <a href="https://github.com/racket/web-server/pull/94/">better by up to an order of magnitude</a>. The Web Server is also more resistant to clients attempting to use unconstrained resources.</p></li>
<li>
<p>The math library includes the Kronecker product.</p></li>
<li>
<p>Windows supports finer granularity for <code>sleep</code> when sleeping for short periods of time, improving performance in animation.</p></li>
<li>
<p>The new prop:struct-field-info property provides static information about field names.</p></li>
<li>
<p>Debugging context in Racket CS is limited to 64,000 frames (approximately the same as Racket BC). This reduces the time taken to handle out-of-memory failures.</p></li>
<li>
<p>In <code>plot</code>, the legend font and the plot font can be controlled independently, and error-bars have an <code>#:invert?</code> option.</p></li>
<li>
<p>The plot and math libraries have new maintainers: Alex Harsányi for plot and Pavel Pancheka and Jens Axel Søgaard for math.</p></li></ul>
<p>The following people contributed to this release:</p>
<p>Alex Harsányi, Alex Knauth, Alexander Shopov, Alexis King, Andrew Kent, Andrew Mauer-Oats, Atharva Raykar, Ben Greenman, Benjamin Yeung, Bert De Ketelaere, Bogdan Popa, David Christiansen, David Florness, Diego Crespo, Dionna Amalie Glaze, Fred Fu, Gary Baumgartner, Georges Dupéron, Gustavo Massaccesi, Jack Firth, Jay McCarthy, Jens Axel Søgaard, Jesse Alama, John Clements, Laurent Orseau, Leif Andersen, Luka Hadži-Đokić, Marc, Matthew Butterick, Matthew Flatt, Matthew Parris, Matthew Turland, Matthias Felleisen, Michael Ballantyne, Mike Sperber, Noah W M, Paulo Matos, Pavel Panchekha, Philip McGrath, Raphael Das Gupta, Reuben Thomas, Ricardo Herdt, Robby Findler, Ryan Culpepper, Sam Tobin-Hochstadt, Sancho McCann, Sorawee Porncharoenwase, Spencer Florence, Stephen De Gabrielle, Syntacticlosure, Tim Brown, Yury Bulka, frogbird, kryptine, rsiddharth</p>Racket Survey 2020urn:http-blog-racket-lang-org:-2020-06-racket-survey-2020-html2020-06-23T18:34:02Z2020-06-23T18:34:02ZThe Unknown Author
<p><em>posted by Stephen De Gabrielle and Sam Tobin-Hochstadt</em></p>
<p>We’re taking a <a href="https://forms.gle/XeHdgv8R7o2VjBbF9">survey</a>! We want to better understand the Racket community, from people who have been contributing for decades to those who have just joined us, and from seasoned programmers to those just starting out.</p>
<p>One of our goals is to help bring in new contributors and make it easier to become a part of the community.</p>
<p>Fill out the survey here: <a href="https://forms.gle/XeHdgv8R7o2VjBbF9">https://forms.gle/XeHdgv8R7o2VjBbF9</a></p>
<!-- more-->
<p>Completing the survey should take 10–15 minutes, and is anonymous (unless you decide to include your name). The survey will be open until July 31 and we will report on the results sometime after that.</p>
<p>Please help us spread the word by sharing the survey link on your social network feeds, at conferences, around your office, and in other communities.</p>
<p>If you have any questions, please let us know at <a href="mailto:survey@racket-lang.org">survey@racket-lang.org</a>.</p>