Julia - shivamvats/notes GitHub Wiki
Features
- Julia is a procedural and functional language. It is not an object oriented language.
- Julia optimizes functions. For speed, always encapsulate operations in a function.
- For loops are as fast as vectorization.
- Julia supports native parallelization.
- It is very good at linear algebra.
- Can call
C
functions usingccall
andPython
functions usingPyCall
. - Multiple Dispatch: Julia supports multiple dispatch. Effectively this means that I can overload functions (something I can't do in Python). Note, that statically types languages like C++ can support function overloading without multiple dispatch if the object type is known at compile time. That is, even though I can overload functions in C++, the function to be called is determined at compile time. If I want the function to be selected based on the run-time type of the arguments (definition of dynamic dispatch), for example, child class passed as base class pointer, only single dispatch is supported. This is implemented using
virtual
methods of a class, where the method to be called is chosen based on the run-time type of the class. - This allows us to write
specialized
versions of the same function based on the type of the arguments and a catch-all fallback definition. This is similar to what Haskell does. - Differences from other languages
Syntax
- Macros: Invoked as
@name(arg1, arg1)
or@name arg1 arg2
.@name (arg1, arg2)
is interpreted as having only a single argument, which is the tuple(arg1, arg2)
. - Elementwise Operation: For every operator like
^
, there is a corresponding operator.^
that performs the operation element-wise on the given array. - Typeclasses: Julia implements type-classes with parametric methods:
The constraint onfunction identical_types{T<:Number}(x::T, y::T) ... end
T
restricts what kind of parameters the function can take.
Notes
- Hit
]
to enterpkg
mode. - Hit
]
and thendev path_to_package
to install a local package.