Combined, Python and R rule the data world, casting a shadow on similar languages.
But one language has distinguished itself from the pack and has slowly been moving towards the light. That language is Julia. Despite its young age, Julia enthusiasts are already calling it the “future language” of data science and AI. To see if they’re right, let’s look at some metrics of Julia’s adoption, which are taken from Julia’s annual newsletter on growth statistics.
As of January 1, 2022, Julia has been downloaded 35 million times, and it was downloaded three times more often in 2021 than in the last three years combined. The core language and its registered packages have amassed a total of 250k stars on Github, 13 times more than that sum six years ago. Julia’s GitHub repo alone stands firm with 39.1K stars, 4.9K forks, and 3.3K issues.
The number of registered packages for Julia reached over 7,400 in April, ten times more packages than had existed six years ago. As for its rating among all other languages, the May TIOBE index places it at 25th position, which is three places lower than last year when it jumped from 47th position.
Screenshot by the author of the TIOBE Index in May
The actual TIOBE index of Julia is 0.64%, which means that from all programming language-related queries on search engines, Julia’s name popped up 0.64% of the time. In other words, about every 200th programming-related question is about Julia.
These are impressive figures, considering that Julia’s earliest stable release was in 2018. But do these numbers mean Julia will become even half as popular as Python or R in the foreseeable future? Is it worth learning now? Before we answer these questions, let’s take a closer look at the language itself.
What is Julia?
Julia is a scientific computing language that was first announced in 2012. The four founders who wrote it, Jeff Bezanson, Stefan Karpinski, Alan Edelman, and Viral B. Shah, all had different backgrounds but shared an appreciation of the collective power of all other programming languages.
In order for Julia to best the most powerful languages, the founders laid out a specific vision for the language. In a blog post explaining why they created Julia, they state that Julia should be:
- As fast as C
- As dynamic as Ruby
- Homoiconic, or treating code like data
- Matlab-like in math notation
- Lisp-like in macros
- As general as Python
- As statistics-friendly as R
- As natural as Perl for string processing
- As powerful as Matlab for linear algebra
- Hadoop-like in distribution
These out-of-this-world ambitions were, well, ambitious. Yet, when Julia 1.0.0 was released in 2018, they had already delivered on 90% of the promises they had made six years prior.
Julia excels at certain aspects of programming that no ordinary language does. For example, Python sacrifices speed for being flexible and dynamically typed, while languages like C, C++, and Java are strictly static and rigid in order to be fast at runtime. As for Julia, the language reads like English, is entirely dynamic, and is still one of the fastest languages in history.
These benefits have already led to fascinating applications for the language. The Brazilian National Institute for Space Research (INPE) uses Julia to plan space missions, for example, while the Federal Aviation Administration (FAA) is using the language to develop a next-generation collision avoidance system.
Data Teams Using Julia
It’s not just aerospace engineering—pharmaceutical companies are developing with Julia as well. Pfizer accelerated the simulation of treatments for heart failure 175 times using models running in Julia. AstraZeneca uses Bayesian neural networks with the Flux.jl and Turing.jl Julia packages to predict drug toxicity.
Julia is being taught at some of the most prestigious institutions globally, such as MIT, Stanford, Cornell, UC Berkeley, Brown, Tokyo Metropolitan University, and so on. Here are some of the globally-recognized companies developing in Julia.
- Capital One
Companies using Julia today
What Makes Julia Unique?
There are many qualities of Julia that make it a one-of-a-kind language. Here is a list of non-exhaustive features that make learning Julia compelling.
I’ve touched on its astonishing speed quite a lot. But how fast are we really talking?
Researchers in the Apache Point Observatory began imaging every visible object within 35% of the skies in 1998. They called the project Celeste and acquired a dataset of 500 million stars and galaxies. For 16 years, cataloging these images was a tedious and laborious task.
In 2014, a team of scientists and programmers aggregated 178TB of image data and produced point estimates for 188 million stars and galaxies in just 14.6 minutes.
This scientific and programming feat was made possible by running Julia on the Cori supercomputer, achieving a peak performance of 1.54 petaflops (10¹⁵ operations per second) across 1.3 million threads on 9300 nodes. Thus, Julia became the fourth language to ever achieve petaflops performances after C, C++, and Fortran.
Another way Julia shines is its syntax, which represents the language in a way that was once thought impossible. Before Julia was released, scientific computing was mainly done in other dynamically-typed languages like Python or R. Since the computations were done by physicists, biologists, and financial experts who weren’t seasoned developers, these experts preferred simpler syntax even if it came at the cost of losing computation speed.
Julia is dynamically typed as well, making it dead simple to learn and write, but by being a compiled language it manages to be as fast as statically-typed languages like C or Fortran.
3. Multiple Dispatch
Another advantage, even though it is not new to programming, is multiple dispatch. Without getting too technical, multiple dispatch refers to a function’s ability to behave differently based on the types of its arguments. Here is an example of how this can be useful:
function _add_str(str1, str2) str1 * str2 end function _add_int(int1, int2) int1 + int2 end add(item1::String, item2::String) = _add_str(item1, item2) add(item1::Int64, item2::Int64) = _add_int(item1, item2)
[OUT]: add (generic function with 2 methods)
add("Julia ", "is awesome!")
[OUT]: "Julia is awesome!"
If you’ve noticed, I have just implemented the
+ plus operator in Python, which behaves differently as the input types change. The beauty of the above example is that you can enable Julia's multiple dispatch feature on virtually any function you want and make it behave differently under different inputs.
These are some of the wonderful things about Julia. Now, let’s compare it to Python.
Julia vs. Python, a Detailed Comparison
In this section, I will try to outline the differences between Julia and Python. While the comparisons will be mainly between Julia and Python, they apply to R as well since Python outperforms or performs similarly to R in many of these aspects.
Let’s look at the speed difference first, as Julia lovers constantly brag about the speed of their language. We will measure the time it takes to find the derivative of a function in Julia’s
Flux.jl package measured against the
Tensorflow in Python.
We will start with Tensorflow:
import time import tensorflow as tf start = time.time() x = tf.Variable(5.0) with tf.GradientTape() as tape: y = 3 * x ** 3 + 4 * x ** 2 + 6 * x + 5 # dy_dx = 9x^2 + 8x + 6 dy_dx = tape.gradient(y, x) print(time.time() - start)
It takes about 0.003 seconds to find the derivative of
x. Let’s see the same operation in Julia:
Both examples were run on a local machine (AMD Ryzen 9 3900x 12-core processor, NVIDIA RTX 2060 SUPER 8GB VRAM)
The first time we run the gradient, Julia compiles it in ~0.002 seconds, which is already faster than Tensorflow. The next time we run it, the evaluation is ~450 times faster. Speed test — check!
Now, let’s talk about syntax. Many claim that Julia code reads like English more; it is more expressive and cleaner than Python, especially for scientific computing. Let’s see this in action.
The first example is in writing math expressions — you can write polynomials just like in MATLAB:
x = 5 3x^2 + 5x + 4
(x + 5)x
There are also short-circuiting expressions that greatly simplify conditionals, from this:
x = 73; y = 37 if x > y println("$x is higher than $y") end
[OUT]: 73 is higher than 37
To this streamlined example:
x > y && println("$x is higher than $y")
[OUT]: 73 is higher than 37
There are other helpful differences between native Python and native Julia as well. For example, arrays in Julia are, by default, considered vectors and matrices, and any function run on them will be vectorized, eliminating the need for unnecessary loops. Despite that, Python is still one of the most user-friendly programming languages to learn for data science.
3. Popularity and Package Ecosystem
Not everyone is ready to jump on the Julia train, however. I’ve talked about the growth statistics of Julia in the intro. On their own, they look pretty impressive, but when contrasted with Python’s, there’s still quite a long way to go.
Python is on the top of the TIOBE rankings with a 12.74% index as opposed to Julia’s 0.64%. There are entire Python packages like TensorFlow or PyTorch that have much more traction than Julia as a language.
Python’s data science and machine learning ecosystem is more extensive and mature. While Julia has over 7k registered packages, Python has over 110k. These numbers mean that Julia has a long way to becoming the best general-purpose language, even though it might have distinct advantages over native Python in many aspects.
While Python dwarfs it in size, one advantage for Julia programmers is that they have a much bigger opportunity to improve the language and leave their mark on the many growing disciplines within the Julia ecosystem. Besides, to start contributing to Julia, there’s no need to have years of expertise or be a master of multiple languages. The libraries written in Julia are written purely in Julia with no contribution from other languages. Here is an example of the
In comparison, you have to master not only Python but other languages such as C++, C, GO, etc., and how they all interact to even begin understanding the code of critical Python packages.
If you do want to call other languages like Python in Julia, packages like
Pycall make it easy. Here’s the package in action:
using Pkg Pkg.add(PackageSpec(name="PyCall", rev="master")) Pkg.build("PyCall") using PyCall plt = pyimport("matplotlib.pyplot") x = range(0; stop=2*pi, length=1000) y = sin.(3*x + 4*cos.(2*x)); plt.plot(x, y, color="red", linewidth=2.0, linestyle="--") plt.show()
There are similar Julia packages available for calling other languages, like
MATLAB.jl, and more.
4. Learning Resources
Unfortunately, while Python and R have a wealth of beginner-friendly learning materials, there’s a dearth of similar resources for learning Julia. The lack of free and paid guides, courses, and books on Julia is one of the reasons why it is still not massively adopted, as developers hate learning about a new language from reading the docs.
As the number of educational resources on a given topic is usually related to its search demand, we can look to Google Trends for data on this:
This graph shows that the popularity of Python is significantly higher than Julia’s.
There is also much bigger community support for Python and R than Julia. We can confirm this by looking at the number of tagged questions on StackOverflow for each language:
Python is definitively ahead of both languages, but the accessibility of training materials and community support for Julia is growing along with its adoption.
Is Julia Worth Learning?
So, time for the million-dollar question — is Julia worth learning?
Weighing the pros and cons of the language, the answer would lean towards a “Yes!”. It would be just a matter of when.
Most data scientists would say that you shouldn’t learn Julia in the early stages of your data science & machine learning journey. Almost 100% of all data roles list Python or R as requirements, and choosing to learn Julia over them at the beginning of your career could be a serious mistake. These days, the required skills and tools for a data job are already so vast that it would take quite a time investment to make yourself an asset in a role. Distracting yourself with Julia could keep you away from a paid job and slow down your career.
A great time to start learning Julia is when you feel like you have mastered R or Python and can solve business problems with their libraries. Julia would be a great addition to your toolbox at that stage because you would be well-equipped to utilize all the advantages and powers the language can bring.
However, some experts have a completely radical take on learning Julia. As Ari Joury claims in their post, Julia could be your golden ticket to the future if you learn it early and learn it well. The author cites the example of AI itself since it was a very niche field 30–40 years ago but the people who adopted it in the ‘90s are now highly in demand.
Time will tell whether the same will hold for Julia, as Julia could be the one thing you can put on your CV to really stand out from Pythonistas. The decision is yours.