January 2020
Intermediate to advanced
532 pages
13h 31m
English
In Julia, there is no need to specify the type of variables. In fact, to be more precise, variables are not typed. Variables are merely bindings to values, and values are typed. That is what makes Julia programs dynamic. However, such flexibility comes with a cost. Because the compiler must generate code that supports all possible types that may come up during runtime, it is unable to generate optimized code.
Consider a simple function that just returns an array of random numbers:
random_data(n) = isodd(n) ? rand(Int, n) : rand(Float64, n)
If the n argument is odd, then it returns an array of random Int values. Otherwise, it returns an array of random Float64 values.
This innocent function is actually ...
Read now
Unlock full access