My First Impression of Julia

Subscribe to my newsletter and never miss my upcoming articles

Some days ago I came across a programming language that I had no idea about before. It was announced in 2012 and since the community has grown, with over 13,000,000 downloads as of March 2020 (and is used at more than 1,500 universities)[1]. The language has a very pretty name and it’s Julia. It is a high-level, high-performance, dynamic programming language actually designed to address the requirements of high-performance numerical and scientific computing while also being useful for general-purpose programming. Julia 1.0 was released in 2015 and it made its place in the ML and Data Science world in such short time. In the time of this writing the latest version of Julia is 1.4.2.

Paradigm

Julia is a multi-paradigm programming language with Multiple Dispatch as its core. It is also Homo iconic, meaning a program written in it can be manipulated as data using the language, and thus the program's internal representation can be inferred just by reading the program itself. Thus it has powerful Metaprogramming capabilities. It combines features of imperative, functional, and object-oriented programming. Julia provides ease and expressiveness for high-level numerical computing, in the same way as languages such as R, MATLAB, and Python, but also supports general programming. To achieve this, Julia builds upon the lineage of mathematical programming languages, but also borrows much from popular dynamic languages, including Lisp, Perl, Python, Lua, and Ruby. Julia is garbage-collected, uses eager evaluation, and includes efficient libraries for floating point calculation, linear algebra, random number generation, and regular expression matching. It supports concurrent, (composable) parallel and distributed computing. A just-in-time compiler that is referred to as "just-ahead-of-time" in the Julia community is used.

Language Features

According to the official website[2], the main features of the language are:

  • Multiple dispatch: providing ability to define function behavior across many combinations of argument types

  • Dynamic type system: types for documentation, optimization, and dispatch

  • Good performance, approaching that of statically-typed languages like C

  • A built-in package manager

  • Lisp-like macros and other metaprogramming facilities

  • Call Python functions: use the PyCall package

  • Call C functions directly: no wrappers or special APIs

  • Powerful shell-like abilities to manage other processes

  • Designed for parallel and distributed computing

  • Co-routines: lightweight green threading

  • User-defined types are as fast and compact as built-ins

  • Automatic generation of efficient, specialized code for different argument types

  • Elegant and extensible conversions and promotions for numeric and other types

  • Efficient support for Unicode, including but not limited to UTF-8

Type System

Describing Julia in the lingo of type systems, it is: dynamic, nominative and parametric. Generic types can be parameterized, and the hierarchical relationships between types are explicitly declared, rather than implied by compatible structure. One particularly distinctive feature of Julia's type system is that concrete types may not subtype each other: all concrete types are final and may only have abstract types as their supertypes. While this might at first seem unduly restrictive, it has many beneficial consequences with surprisingly few drawbacks. It turns out that being able to inherit behavior is much more important than being able to inherit structure, and inheriting both causes significant difficulties in traditional object-oriented languages.

It has an automatic generation of efficient, specialized code for different argument types. In Julia, the types are run-time objects, and can also be used to convey information to the compiler. Due to the run-time type inference and a strong focus on performance from the inception of the project, Julia’s computational efficiency exceeds that of other dynamic languages. This language solves the two language problem by combining the ease of use of Python and R with the speed of C++.

Julia's type system is designed to be powerful and expressive, yet clear, intuitive and unobtrusive. Many Julia programmers may never feel the need to write code that explicitly uses types. Some kinds of programming, however, become clearer, simpler, faster and more robust with declared types.

Syntax and Package System

Among the languages that inspired Julia is Ruby, so it should come as no surprise that Julia adopted one of Ruby's more iconic features: the do...end block. As is the case with many other features that Julia has adopted, its implementation of do...end is simpler and more flexible than Ruby's. Julia is as easy to learn and use as Python.

Julia has a built-in package manager and includes a default registry system. Packages are most often distributed as source code hosted on GitHub, though alternatives can also be used just as well. Packages can also be installed as binaries, using artifacts. Julia's package manager is used to query and compile packages, as well as managing environments. Federated package registries are supported, allowing registries other than the official to be added locally.

Parallel Computing

Julia has a high-level syntax which makes it easy and accessible language for the programmers from any background. The Julia programs are able to compile efficient native code for multiple platforms via LLVM. It can be said that this language is built for parallelism due to its primitives for parallel computing. The parallelism is divided into three main categories — Julia Co-routines (green threading), multi-threading and multi-core or distributed processing. With scientific computing in mind, this language natively implements interfaces to distribute a process across multiple cores or machines.

Efficiency

This language can be said as the fastest high-performance open source computing language for data, analytics, algorithmic trading, machine learning, artificial intelligence, and other scientific and numeric computing applications. While popular languages like Python can be slower being an interpreted language, Julia has been designed for high-performance functions by the developers. The applications in Julia can be easily compiled to efficient native code. If you call a function in Julia it consumes a little time in the first run but when the same function has been called repeatedly, it shows a much faster outcome than other languages.

My Thoughts on Julia

I have only scratched the surface of the programming language. Surely one weekend is not enough to get a total feel of the capabilities of any language. But with the small amount of study and research I have found some very good features and reviews of Julia. It is a modern programming language designed with performance and ease of use in mind. The Ruby-like syntax is really helpful for developers to quickly pick up the language but the type system can be hard to grasp at first. If you are familiar with Lisp or even Golang you will find it relatively easy to understand and reason about. Functional programming knowledge is another good thing to have while learning Julia. The official documentation page is very descriptive and will provide you with an in-depth idea about the syntax and language features and uses. The package manager is pretty good and Julia already has more than 3000 packages available and the number is growing everyday.

Though the main power of Julia lies in Scientific Computation it is also a great choice for data analytics, machine learning, artificial intelligence, deep learning, computer vision etc. And one can also use it as a general purpose language.

I really like to learn about new and emerging technologies and try to adopt them early if I can. Many big organizations are already using Julia for building their ML or AI solutions and many universities are using it for their research work worldwide. A data scientist can highly benefit in the near future by adopting Julia now. It may not be as popular as any main stream languages today but in a few years it may become a main stream language itself.

Finally I would like to add this. If you want to bet on some tech for the future of data analytics and machine learning then Julia might be the right one.

Reference

  1. en.wikipedia.org/wiki/Julia_(programming_la..

  2. docs.julialang.org/en/v1

Simeon Ajayi's photo

Good

Bolaji Ayodeji's photo

This is a great read, thanks for sharing!

Shah Nawaz Shuvo's photo

You are most welcome.

Sébastien Portebois's photo

If you like to learn more about it, Jean Yang hosted a live chat with Jeff Bezanson (co creator of Julia) a few days ago: twitch.tv/videos/710412046

Shah Nawaz Shuvo's photo

Thank you very much for the info.