简体   繁体   中英

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.

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.

Some of the libraries claim to be much fasted in Typed Racket.

From the Racket documentation:

7 Matrices and Linear Algebra

Performance Warning: Matrix values are arrays, as exported by math/array. The same performance warning applies: operations are currently 25-50 times slower in untyped Racket than in Typed Racket, due to the overhead of checking higher-order contracts. We are working on it.

https://docs.racket-lang.org/math/matrices.html?q=matrix

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM