JuliaActuary/Learn

using types makes code slower?

Closed this issue · 2 comments

Looking at the stochastic claims example -

Type annotations are optional, but providing them is able to coerce the values to be all plain bits (i.e. simple, non-referenced values like arrays are) when the type is constructed. This makes the whole data be stored in the stack and is an example of data-oriented design. It's much slower (~0.5 million policies per second, ~50x slower)

surely providing the types makes it faster?

It's sort of confusing as written, isn't it? "It's much slower" is supposed to refer to the non-type-annotated code.