Search code examples
schemerackettyped

Advantages of "typed Racket" over Racket


What are the main advantages one can expect from using "#lang typed/racket" over "#lang racket"? I could not find it in the references https://docs.racket-lang.org/ts-reference/index.html . Are the advantages just as for any other statically typed programming language https://en.wikipedia.org/wiki/Type_system#STATIC ? Is it reasonable to expect improvement in speed of compiled programs? Is safety of programs also improved? Thanks for your insight.


Solution

  • In the Typed Racket Guide

    7 Optimization in Typed Racket

    Typed Racket provides a type-driven optimizer that rewrites well-typed programs to potentially make them faster. It should in no way make your programs slower or unsafe.

    Thus the type hinting can make your programs faster, but it guarantees the programs wont be slower than #lang racket as well.

    Note that this is true when you compile it with raco make or use DrRacket to make an executable. Running the code in the IDE might be slower because of the extra work the compiler does to achieve this.