Pular para o conteúdo principal
InicioBlogJulia

Progressing from MATLAB to Julia

A guide for MATLAB programmers interested in transitioning to the Julia programming language
31 de out. de 2022  · 11 min leer

In the highly disruptive world of data science, nothing lasts forever. Every time new tools and software pop up, they have the potential to challenge the technology status quo. This dynamic is particularly visible in the programming language landscape. There is a good number of programming languages well-suited for data science. While the data space is currently dominated by a handful of very popular programming languages, other new, allegedly more powerful languages are gaining momentum. One of the most promising examples is Julia. 

Released for the first time in 2012, Julia can be considered a data science rising star. Despite its relative newness, Julia has already impressed the world of numerical computing with its high performance and unbeatable computing speed. Over the years, Julia has grown in maturity, and today it is commonly labeled as one of the “future languages” of data science and artificial intelligence. 

There are many compelling reasons to start learning Julia. However, the transition pathway may differ depending on the programming languages you are familiar with. While most articles and courses focus on how to transition from MATLAB to any of the two most popular languages for data science, Python and R, it is also important to provide resources for users from other programming languages interested in progressing to Julia. 

The goal of this article is to introduce Julia to MATLAB programmers. We will study the differences and similarities between the two languages and provide some tips to migrate from MATLAB to Julia for data analysis and visualization. Let’s get started!

What is MATLAB used for?

MATLAB is a programming language specifically designed for numerical computing. Since its launch in 1984, MATLAB (an abbreviation of "MATrix LABoratory"), has been widely adopted in academia and scientific research. Despite being relatively old, it’s still an extremely popular programming language. In October 2022, it ranked 14th position in both the PYPL Index and TIOBE Index

MATLAB language excels in high-level computational tasks, including advanced mathematical and statistical operations. The language also includes plotting and algorithm implementation capabilities, making it a perfect candidate for data science.

However, MATLAB also comes with an important caveat: it is a proprietary tool. This means that, unless your affiliated institution grants you access, as is often the case in academic settings, you may have to pay a large amount to get a license. Plus, since users don’t have access to its source code, it can get hard to understand how some of MATLAB’s capabilities work. 

These factors can make MATLAB less attractive compared to other programming languages that you can use for free.

What is Julia used for?

Behind any innovation is the desire to improve or outperform the dominating technologies of the time. This was the driving force behind Julia, which draws inspiration from some of the most powerful programming languages. As Jeff Bezanson, Stefan Karpinski, Alan Edelman, and Viral B. Shah, the founders of the language, stated in a post explaining why they created Julia:

“We want a language that's open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that's homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.”

Because of its unique features, resulting from this cherry-picking process that brings together the best of the best programming languages, Julia is rapidly gaining momentum. 

Since its first release in 2021, Julia has been downloaded over 40 million times, and the Julia community has registered over 8,000 Julia packages for community use. These include various mathematical libraries, data manipulation tools, and packages for general-purpose computing. 

As for its popularity among all other languages, Julia ranks in 25th and 27th position in the October 2022 PYPL Index and TIOBE Index, respectively.

Julia is a general-purpose programming language, meaning that it can be used in many software development tasks, such as web development and game development, but it is particularly well-suited for machine learning and statistical computation. Indeed, Julia enthusiasts like to label it the inheritor of Python and R for data science. 

That being said, Julia has a long way to go before it becomes the default language of data science. Those just starting on their journey will still likely want to learn Python and R first. However, as a compliment to existing programming skills, Julia could be an excellent choice. You can find out more about what Julia is used for in a separate blog post. 

What MATLAB Users Should Know About Julia

There are compelling reasons to embrace Julia. In this section, we will look closely at the main features that make Julia such a powerful language and an ideal candidate for MATLAB users to transition to Julia.

MATLAB vs Julia Speed

Julia was designed with technical and scientific users in mind. To solve business problems and support decision-making, data professionals often have to deal with large datasets and complex techniques, including machine learning algorithms and artificial neural networks. 

These activities not only require important computing resources, they also require a programming language that can run code on a computer very quickly, so data professionals don’t have to wait for long to get their results. 

However, choosing the right programming language can be difficult. Most programming languages face the trade-off between performance and code readability. 

Traditionally, programming languages with high performance have been trickier to use, and vice versa. For example, popular “high-level” languages, such as MATLAB, and Python, sacrifice speed for being flexible and highly readable, while languages like C, C++, and Fortran, are known to be very fast, but they have a very complex syntax. 

This means that developers need more time and often more programming experience to write code with these kinds of languages.

Here is where Julia enters the scene. Julia has been designed to be relatively easy and quick to write programs in, but also to run code and perform calculations very quickly. With its C-like performance, Julia is already one of the fastest languages in history. When comparing the performance of the two languages, MATLAB is significantly slower than Julia. 

To illustrate Julia’s unbeatable performance, in the following table, you can find a benchmark on how Julia and MATLAB perform when running a for loop to create a matrix from a given vector. More details about the benchmark test can be found in the following article.

N

Julia (single thread)

Julia (multi-thread)

MATLAB (single thread)

MATLAB (multi-tread)

1000

0.035s

0.007s

0.067s

0.0367s

2000

0.126s

0.031s

0.255s

0.034s

3000

0.289s

0.062s

0.543s

0.073s

4000

0.554s

0.116s

0.965s

0.123s

5000

0.831s

0.215s

1.510s

0.189s

6000

1.108s

0.274s

2.161s

0.268s

7000

1.489s

0.304s

2.936s

0.364s

8000

1.948s

0.402s

3.830s

0.478s

9000

2.460s

0.505s

4.847s

0.610s

10000

3.039s

0.616s

5.977s

0.753s

MATLAB vs Julia Syntax 

As mentioned in the previous section, Julia has ended the debate between performance and readability. The language’s syntax reads like English and is dynamically typed, making it as simple to learn and write as MATLAB or Python, but by being a compiled language, it manages to be as fast as statically-typed languages like C or Fortran.

But there’s more. If you are considering moving from MATLAB to Julia, here’s the good news: the two languages are pretty similar, syntactically speaking. This fact comes with no surprise: in the end, MATLAB has been one of the main sources of inspiration for the founders of Julia. 

Here are some examples of basics operations in MATLAB and Julia:

For loops

% for loop in MATLAB
for i = 1:N
  % do something
end
# for loop in Julia
for i in 1:N
  # do something
end

If / else statements

% if/else in MATLAB
if i <= N
  % do something
else
  % do something else
end
# if/else in Julia
if i <= N
  # do something
else
  # do something else
end

UDF functions

% function in MATLAB
function out  = f(x)
  out = x^2
end
# function in Julia
function f(x)
  return x^2
end

Despite the similarities, it’s worth noting that Julia is not a MATLAB clone. There are still major syntactic and functional differences. In the next section, we cover some of the similarities and differences between MATLAB and Julia. 

Julia vs MATLAB: A Comparison

Below you can find a table of differences between Julia and MATLAB:

 

Julia

MATLAB

Purpose

It’s a language focused on computational science, data analysis, and Artificial Intelligence 

Its a language and scientific platform used for data analysis and mathematical computing

Type of Language

It’s a high-level, general-purpose, compiled, and dynamic language

It’s a high-level, domain-specific, interpreted, and dynamic language

Open Source?

Yes

No

Release Date

2012

1984

Written in

C, C++, and Julia itself

C, C++, Java, and MATLAB itself

Who it’s Used By

Mostly data scientists and other data professionals

Engineers, scientists, scholars, and data professionals worldwide

Ecosystem

+8,000 registered packages

Mostly built-in and custom libraries 

Ease of Learning

Julia is a simple language with an English-like syntax.

MATLAB is an easy-to-learn language.

File extension

The file saved is with the extension ‘datacamp.jl’.

The file saved is with the extension ‘datacamp.m’.

Advantages

  • A high-performance language without sacrificing code. readability.
  • Ease of use.
  • A Mature language with many available resources. 
  • Ease of use.

Disadvantages

  • As a young language, Julia still has a limited community of users and limited learning resources.
  • MATLAB is proprietary. Licenses can be costly.
  • As an interpreted language, it’s slower than compiled ones.

Trends

25th and 27th position in the PYPL Index and TIOBE Index, respectively (October 2022)

14th position in both the PYPL Index and TIOBE Index (October 2022)

Progressing From MATLAB to Julia 

Ready to get started? Here are some steps to help when progressing from MATLAB to Julia:

Learn the Basics of Julia  

The best way to learn a new programming language is by writing code. There are many resources out there for getting started with Julia, but we highly recommend you check our Introduction to Julia Course

Developed for newcomers to Julia and, more broadly, beginners in data science, the course starts with the very fundamentals of the language and moves progressively towards more detailed elements. By the end of the course, you'll be familiar with coding in Julia, understanding the basics, including data types and structures, the functions and packages, and how to use DataFrames to work with tabular data.

You can also find our Julia tutorial for beginners, as well as our handy Julia cheat sheet

Use Julia in Your Data Projects

A great way to consolidate your knowledge and get essential hands-on experience with Julia is by using the language to work on your favorite data projects. Using Julia in your own projects will help you discover the full potential of Julia and help you build an outstanding data science portfolio. 

Use Julia In Your Professional Projects

Once you are familiar with Julia, it’s time to leverage it in your daily activities. Julia’s combination of high performance and readability can make it a game-changer when working in a professional setting. From pharmaceutical modeling to planning space missions, professionals in all kinds of industries are using Julia programming today. It is a powerful tool to take your applications and data science tasks to the next level. 

Look for Your Next Job With Julia

Now is a great time to learn Julia. As Ari Joury claims in her post, Julia could be your golden ticket to the future if you start learning it before it becomes the new normal in data science. More and more companies worldwide are adopting Julia for their data projects, meaning that they will do whatever they can to attract the (still) few experienced Julia programmers. Once you’ve developed your skills sufficiently, you can start looking for roles that require both Julia and MATLAB knowledge. 

Discover your next career move using Julia with DataCamp’s data jobs platform

Conclusion

Julia is one of the rising stars of the data space. Over the ten years since its first release, the language has gained maturity and today presents exceptional features that few languages can exhibit. 

While MATLAB is still in good shape, no programming language is safe in the rapidly evolving data science landscape. What is popular today can become irrelevant tomorrow, surpassed by more modern and powerful tools. 

In recent years, Julia’s main downside was its youth. However, today it is one of the most exciting new languages in the data science industry. Is Julia worth learning, then? And is it possible to progress from MATLAB to Julia? The answer to both of these questions is a resounding yes.

Learn Julia Today

Gain a thorough introduction to Julia programming

Get Started Now!

MATLAB to Julia FAQs

What is MATLAB?

MATLAB is a high-level programming language specifically designed for numerical computing.

What is Julia?

Julia is a high-level, compiled programming language. Its features are well-suited for numerical analysis and computational science.

When was Julia released?

The first version of Julia was released in 2012.

What is Julia's main strength?

Julia is a unique language because it combines high performance with high code readability.

Should I transition from MATLAB to Julia?

There are several reasons you might want to, such as Julia's speed, open-source nature, and rapidly developing ecosystem. A great way to get started is our Introduction to Julia Course.

Temas
Relacionado

blog

An Introduction to Machine Learning with Julia

Explore why Julia is suitable for machine learning, and get an introduction to the features and packages that can help you get started.
Joleen Bothma's photo

Joleen Bothma

12 min

DataFramed 111- Zacharias Voulgaris 1.png

podcast

The Rise of the Julia Programming Language

Zacharias Voulgaris, PhD joins the show to talk about his experience with the Julia programming language and his perspective on the future of Julia’s widespread adoption.
Richie Cotton's photo

Richie Cotton

43 min

cheat-sheet

Julia Basics Cheat Sheet

Learn all the fundamentals of Julia in this comprehensive cheat sheet.
Richie Cotton's photo

Richie Cotton

10 min

tutorial

Julia Programming Tutorial For Beginners

A comprehensive introductory tutorial that will help you master the fundamentals of Julia. Learn about operators, conditional statements, working with DataFrames, and more.
Bekhruz Tuychiev's photo

Bekhruz Tuychiev

20 min

code-along

Julia for Absolute Beginners

Learn to perform simple data analysis and data visualization tasks in Julia
John Verzani's photo

John Verzani

code-along

Exploratory Data Analysis in Julia for Absolute Beginners

Get started with Data Analysis in Julia - Hosted by Richie Cotton
Richie Cotton's photo

Richie Cotton

See MoreSee More