Blog

Julia Tutorial

  • (4.0)
  • | 1512 Ratings

Scientific computing is an area which requires the highest performance, so far, slower dynamic languages are being used by domain experts for daily development work. Many believe that there is a need of dynamic language for building applications. The Julia programming language can take the place of a flexible dynamic language, which is perfect for numerical and scientific computing. 

What is Julia language?

Julia is a high-level programming language which was developed by 4 people at Massachusetts Institute of Technology (MIT). It is open source, high-performance, a high-level, dynamic programming language which is used in scientific computing. It is predominantly used for data analysis and statistics computations which is similar to R programming language.

Julia is built primarily for its speed and applications using it have experienced faster running times when compared with Python or R. It provides support in performing difficult tasks such as cloud computing and parallelism which are considered as fundamental to perform big data analytics.

Who uses Julia?

Julia is mainly used by research scientists and engineers, In addition to them, it is also utilized by financial analysts, quants and data scientists. The developers of Julia language made sure that the products developed make julia an easily usable, deployable and scalable.

Installing Julia on Windows

Julia can be installed on various platforms such as Windows, MacOs and Linux as well. 

Features of  julia

The following features make julia a popular programming language:

  • Julia uses dynamic typing, resembles scripting, and has good support for interactive use.
  • Julia supports high-level syntax which makes it  an efficient language for programmers.
  • Julia offers rich language of descriptive data types.
  • Julia supports multiple dispatch which makes it easy to compile object-oriented and functional programming code patterns.
  • As julia is open source, all source code is publicly viewable on GitHub.

Julia Code Example

Here is a Julia benchmark code example for Mandelbrot set:

## mandelbrot set: complex arithmetic and comprehensions ##

function myabs2(z)
    return real(z)*real(z) + imag(z)*imag(z)
End

function mandel(z)
    c=z
    maxiter = 88
    for n = 1:maxiter
          if myabs2(z) > 4
          return n-1
       end
     z=z^2 + c
  end
  return maxiter
end

mandelperf() = [ mandel(complex(r,i)) for i=-1.:.1:1., r=-2.0:.1:0.5 ]
@test sum(mandelperf()) == 14791
@timeit mandelperf() “userfunc_mandelbrot” “Calculation of mandelbrot set”

Julia Packages

These are some of the favourite packages used by julia developers:

  • Interact.jl: Interactive widgets such as dropdowns, sliders and checkboxes to easily implement julia code.
  • Generic Linear Algebra : used to extend linear algebra functionality.
  • Colors.jl: this is a color manipulation utility for Julia.
  • UnicodePlots.jl: scientific plotting based on unicode to work in the terminal.
  • Nemo: computer algebra package.
  • Revise: update function definitions automatically in a running Julia session
  • BenchmarkTools: a benchmarking framework.
  • OhMyREPL.jl: bracket highlighting, syntax highlighting and rainbow brackets.
  • StaticArrays: framework which provides statically sized arrays.

Julia parallelism

Julia is specifically designed for the purpose of distributed computation and parallelism, using two primitives such as remote calls and remote references. Remote references is of two types: future and remote channel.

A future is similar to javascript promise whereas a remote channel can be rewritable and used for interprocess communication, such as Go channel or Unix pipe.

Julia type system

Julia consists of robust type system that is dynamic in nature, it is a traditional runtime type inference but allows for optional type annotations. 

julia> (1+2)::AbstractFloat
   ERROR: TypeError: typeassert: expected AbstractFloat, got Int64
julia> (1+2)::Int
   3

The above program show an assertion of incompatible type, causing an error and a compatible type in the second step.

Comparing Julia and Python

Python is most popular language used widely by most of the developers. Whereas julia is launched very recently in 2012 which is much younger than python. But many developers are likely to use julia as it is catching on quickly, considering the rankings by redmonk.

Advantages of Julia

From the beginning julia was designed for numerical and scientific computation. It's not surprising that Julia has numerous features for such instances of use: 

Faster by default. JIT compilation and JIT type declarations imply it can frequently beat “pure”, Python. With the means of external libraries, optimizations with tools such as Cython, third party JIT compilers python can be made faster, but Julia was designed to be faster right out from the gate. 

A mathematical friendly syntax. The users of computing languages and environments such as Matlab, R, Mathematica, and Octave are the targeted audience for julia. Julia's syntax for mathematics operations looks similar to the way mathematics formulas are written outside the computing world, which makes it look easier for non programmers to pick up on. 

Automated memory management. Like Python, Julia doesn't load the user with the specifics of allocating and freeing memory, and it provides some measure of control over garbage collection. The idea is that if you change to Julia, you do not loses one of Python's common conveniences. 

Advantages of Python

Python is a general purpose computing language that's simple to learn, and which has become a leading language for scientific computing. Some of reasons might still make python a best choice for data science work: 

Still in infant stage. Julia is still in development stage with its current version running on v1.1.0. It is going to get more features added in the future as the developers are continuously trying to improve its performance.

More third-party packages. The broad usage of python’s culture of custom packages remains a biggest interests of the language. Julia’s relative newness  resembles the culture of software surrounding is still small.

Python’s advantage of large community. A language is nowhere without the support of active and large community around it. The community of julia is enthusiastic and gradually growing, but is still a small size of the python community.

Julia Ecosystem

Data visualization and Plotting

Data visualization is one of the important aspect of julia. The plotting software helps to maintain a balance between simplicity and features, speed, and a static and dynamic interface. Some packages maintain a constant display whereas others make real-time updates.

Data visualization and Plotting

The useful packages for data visualization and plotting are:

  • Plots.jl is a visualization interface providing common api across different backends.
  • PlotlyJS.jlis for users who like graphics style API 
  • UnicodePlots.jl is for users who don’t require terminal comfort.

Build, Deploy or Embed Your Code

Julia offers functionality to write UIs, compile code statically and even deploy on a web server. It provides metaprogramming facilities and Lisp-like macros. It also has robust capabilities for managing other processes.

Build, Deploy or Embed Your Code

Interact with your Data

The data ecosystem of julia enables you to quickly load multidimensional datasets, perform joins, aggregations and preprocessing operations simultaneously, and save them to disk in efficient formats. OnlineStats.jl lets you perform digital computations on streaming data.

Interact with your Data

Using ODBC.jl and JDBC.jl drivers, julia can work with almost every database. In addition , it uses Spark.jl, HDFS.jl, and Hive.jl to integrate with the Hadoop ecosystem.

Scalable Machine Learning

Julia offers powerful tools for AI, machine learning and deep learning. With mathematical syntax of julia, it is easy to express algorithms in the way they are presented on paper, support large amounts of data with juliadb and build trainable models using automatic differentiation.

Machine learning and statistics ecosystem of julia include capabilities for decision trees, linear models and clustering. 

Scalable Machine Learning

Julia Training and Certification

Mindmajix offers Julia training program which is targeted at beginners and developers to become productive in Julia. It also enables you to get advanced understanding of julia language and expertise on machine learning and computational artificial intelligence using Julia.

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings.

Ravindra Savaram
About The Author

Ravindra Savaram is a Content Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.


DMCA.com Protection Status

Close
Close