3 ms·
This is what I'm curious about ... what is an example of one of these carefully selected features for technical computing at the language level that is distinct
by BruceM 14y ago
This is what I'm curious about ... what is an example of one of these carefully selected features for technical computing at the language level that is distinct from the other (dynamic) languages?
Clearly, a lot of work has gone into the library side of things, but I'm curious what is special about the language level for technical computing.
- StefanKarpinski 14y agoThe type system is actually one of the key features for this. Systems like NumPy are essentially a way of grafting a type system onto Python arrays. Julia's design allows Array to be be a completely generic parametric type, but when specialized as Array{Float64} or Array{Int64} it is memory-compatible with C, Fortran and NumPy. As a result, Arrays can be shared between Julia, C, Fortran and NumPy without any data copying. Another feature that's very useful for technical computing is the ability to easily create user-defined numeric types with storage and performance that's just as good as Julia's built in types (which are actually also just defined in Julia). They can also easily be made to interact completely transparently with other numeric types. A very simple example can be found here: https://github.com/JuliaLang/julia/blob/master/examples/modint.jl https://github.com/JuliaLang/julia/blob/master/examples/modi... These 13 lines of code define a modular integer type that has the same storage and speed as regular integers, but with modular behavior, and interoperates with normal integers (i.e. `1 + ModInt{11}(1234)` works). Because of generic programming, you get matrices of ModInts for free, again with performance like plain old integers but different behavior. The same applies to defining new representations of things like matrices or dicts.
- ViralBShah 14y agoThe language is carefully constrained so that type inference can work in the majority of the cases, allowing efficient code generation. The details are in our julia design paper here. http://arxiv.org/abs/1209.5145 http://arxiv.org/abs/1209.5145 Also, a number of other language features include: `ccall` to make it easy to call C and Fortran libraries, multiple dispatch which is already discussed here, real metaprogramming capabilities which have traditionally been considered optional in this class of languages, keyword arguments (coming soon), coroutines (julia Tasks) which integrate nicely with the asynchronous networking runtime so that it is easy to overlap computation and communication, immutable types, and I am sure this is not exhaustive.