Julia - shivamvats/notes GitHub Wiki

Features

  1. Julia is a procedural and functional language. It is not an object oriented language.
  2. Julia optimizes functions. For speed, always encapsulate operations in a function.
  3. For loops are as fast as vectorization.
  4. Julia supports native parallelization.
  5. It is very good at linear algebra.
  6. Can call C functions using ccall and Python functions using PyCall.
  7. 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.
  8. 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.
  9. Differences from other languages

Syntax

  1. 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).
  2. Elementwise Operation: For every operator like ^, there is a corresponding operator .^ that performs the operation element-wise on the given array.
  3. Typeclasses: Julia implements type-classes with parametric methods:
    function identical_types{T<:Number}(x::T, y::T)
    ...
    end
    
    The constraint on T restricts what kind of parameters the function can take.

Notes

  1. Hit ] to enter pkg mode.
  2. Hit ] and then dev path_to_package to install a local package.