free counter

Choosing Julia, Matlab, Python or R in economics?

Researchers in economics and finance searching for a modern general purpose program writing language have four choices Julia, MATLAB, Python, and R.

We’ve compared these four languages twice before here on Vox (Danielsson and Fan 2018, Aguirre and Danielsson 2020). Still, as all come in active development, the landscape has changed considerably because the last time, so it’s worthwhile revisiting the question.

Three of the four MATLAB, Python, and R date back several decades, bringing advantages and problems. They’re mature but additionally have problems with incremental changes through the years, to allow them to be archaic, inconsistent and slow. Julia is modern, carrying none of the baggage of another three, but at the expense of less maturity and familiarity. And in addition, it’s been adopted in top quality projects, such as for example Quantitative Economics with Julia, popularised by Thomas Sargent (Perla et al., 2022).

Computation speed

We begin by evaluating computation speed, with all code on the net appendix at

The initial comparison may be the calculation of a GARCH log-likelihood function. It really is iterative and non-vectorisable, with a nontrivial computation time, rendering it a fantastic test for speed.

We use all languages within their standard forms, and for Python, we also think about the just-in-time compiler package Numba, with significantly boosts Python calculations in those specific cases where it could be used. When working with Julia, we use two versions, standard and without bonds checking, @inbounds. We normalise all leads to a pure C implementation to determine a speed baseline.

Figure 1 GARCH log-likelihood speed

Needlessly to say, C may be the fastest, accompanied by Python with Numba, Julia, MATLAB, R and pure Python. When compared to same experiment run in 2020, MATLAB is becoming slower and pure Python faster, while R and Julia have exactly the same speed.

For the second experiment, we go through the loading speed for a big CSV file, both compressed (600 MB) and uncompressed (over 3 GB). The precise data is all stocks in the CRSP database from 1928 until March 2022.

Figure 2 Loading a big data file

Exactly like we within 2020, R may be the fastest for both compressed and uncompressed files, accompanied by Julia, and Python with MATLAB significantly slowest. MATLAB will not support loading compressed files.

Inside our final timing experiment, we utilize the CRSP file loaded above, and calculate the typical deviation of returns for every year and stock (see Figure 3).

Figure 3 Large data set calculation

Julia continues to be the fastest, and is currently relatively faster than in 2020. Python has moved up a location, at the trouble of R. MATLAB stays significantly behind with a worse relative time than in 2020.

These findings come in line with outcomes of Arouba (2018), Coleman et al. (2021) and Markwick (2022).


Programmers increasingly depend on community support within their work. As the Stack Overflow website may be the hottest, other more specific websites may also be beneficial. We go through the community support from several directions, especially the amount of questions on Stack Overflow and the amount of public repositories for every language on GitHub. All languages have a captivating network, helping researchers. Python gets the largest community, profiting from its widespread use outside the kind of scientific computations considered here. R also offers a big community, accompanied by MATLAB and lastly Julia.

Learning and utilizing the languages

The four languages include varying levels of learning materials.

Here, MATLAB gets the advantage. Its documentation is the greatest in class. It really is easily searchable and emphasises practical applications. Rs documentation can be excellent but is more confusing and inconsistent and will be hard to navigate.

Pythons numerical programming documentation is decidedly inferior. It really is more centered on computer science theory and less on applications, rendering it hard to navigate.

Julias documentation may be the worst. Some parts are great, but more often than not would benefit from concentrating on practical uses of code rather than computer science arcana.

MATLAB and R reap the benefits of excellent integrated development environments, the MATLAB desktop and RStudio, while Julia and Python require programmers to employ a general-purpose editor and separately access the language environments.

Having said that, you can develop in a robust browser-based environment, Jupyter, in every four languages. However, Jupyter is most effective for the tiniest projects

Language and syntax

Three of the languages MATLAB, Python and R have problems with being developed over many decades, with language features added incrementally and inconsistently. Furthermore, Python gets the disadvantage of initially being created for other uses, with numerical programming only added later. Consequently, its programming syntax for numerical programming is inferior compared to another three, and inconsistent with Python generally and what one might expect in a numerical program writing language (Driscoll 2019).

Being conceived as today’s numerical program writing language, Julia includes a clean and consistent syntax, so that it gets the fastest programming speed with the fewest errors, as things generally are one might expect.


All languages have the required core functionality for numerical programming, but one always needs libraries for serious use.

Pythons library support for economics and finance applications may be the worst of the four, with two important exceptions machine learning and data pipelines which are best in class.

The libraries given by MATLABs commercial vendor are usually excellent, however they are limited and, due to the commercial nature, you can find hardly any outside libraries available, and the main one we use no more works due to changes to MATLAB core syntax. MATLAB users are, therefore, a lot more influenced by coding up their very own libraries than in other languages.

Julia includes a disadvantage in being truly a recent language, and its own library ecosystem, while growing rapidly, is more immature than that of Python and R.

The library support in R for economic and finance applications is undoubtedly the very best. It advantages from decades useful, and researchers who release computational libraries, overwhelmingly prefer R.

Having said that, three of the languages Python, R and Julia can simply run code in another language. So within exactly the same source file, you can use Python for data handling, R for plotting and Julia for fast computations. We’ve done so in a number of applications, also it works quite nicely.

Backward compatibility

Researchers often be determined by code written years, even decades ago. Revise and resubmit cycles can be extremely long, and the study teams in central banks along with other institutions have to run exactly the same analysis on new data over a long time.

Consequently, backward compatibility, that’s, if the same code will run for a long period as languages and libraries evolve, is of considerable benefit. It really is risky and costly to rewrite existing code every year or two due to language changes.

There exists a considerable difference in backward compatibility in these four languages.

The worst offender is Python, especially the main element libraries NumPy and Pandas. We’ve experienced repeated cases where code recommended at one point is depreciated and can not run a couple of years later. This may result in hard to diagnose and fix bugs. Perhaps Pythons biggest problem is dependency management, that’s, the way to handle different versions of Python and libraries. Due to how intimately specific libraries are linked with particular Python releases, and frequent code breaking changes, you can have to manage multiple Python and library versions simultaneously, a non-trivial undertaking.

MATLAB frequently changes their language, even popular core functions. While MATLAB offers a toolbox allowing programmers to update code as versions change, it really is no replacement for code stability. Due to its commercial it could be impossible to perform multiple versions on a single computer.

Julia promises backward compatibility for core functions. While that guarantee will not extend to all or any libraries, some key libraries make similar commitments, and we expect Julia’s backward compatibility to be excellent. This, however, remains untested. Julia has dependency management facilities that work pretty much but are poorly documented and hard to utilize.

Backward compatibility in R has been excellent, and we routinely run code written about ten years ago or longer without issues. R will not provide facilities for dependency management.

Docker is normally the easiest method to get backwards compatibility also to ensure reproducible results, irrespective of language.

High-performance computing

All languages are fast enough for some applications, while time critical code is frequently written in C or Fortran. Python is undoubtedly the slowest of the four languages, but you can use Numba in specific cases to create it the fastest. Julia is normally the fastest, so for some researchers who need speed and write their very own code, Julia may be the language we’d recommend.

All languages include excellent parallel computing facilities, with Python and especially Julia the very best of the four. You can significantly reap the benefits of utilizing the GPU for computations in special cases. All languages easily support GPU programming.


We can not make any general recommendation regarding the best numerical program writing language. All of them are excellent, and when one is specially familiar with one of these, there’s usually no reason to change.

However, when getting started, or specifically applications, one of these brilliant languages is normally the very best.

The main one hardest to recommend is MATLAB. It’s not only very expensive, it really is slow and contains the worst library support. We are able to only see MATLAB as useful if one has already been focusing on projects that use MATLAB.

Python is the greatest language for data pipelines and machine learning applications however, not otherwise.

R is the greatest overall language. It has undoubtedly the very best library support and, while slow, you can overcome that by embedded C++ code. However, R is archaic and inconsistent, leading to hard to diagnose bugs, as language design decisions made decades ago hamper R today.

Julia is most beneficial from the pure language perspective. It generally does not have any historical baggage, and the language is clean and modern. It really is undoubtedly the fastest of the four. Its weakness is library support and documentation. We recommend Julia for all those writing their very own code to resolve complex, time-consuming problems.


Aguirre, A and Danielsson, J (2020), Which program writing language is most beneficial for economic research: Julia, Matlab, Python or R?,, 20 August.

Arouba, S and J Fernndez-Villaverde (2018), AN ASSESSMENT of Programming Languages in Economics: An Update.

Coleman, C, S Lyon, L Maliar et al (2021), Matlab, Python, Julia: What things to Choose in Economics?, Computational Economics 58: 12631288.

Danielsson, J and J R Fan (2018), Which numerical computing language is most beneficial: Julia, MATLAB, Python or R?,,9 July.

Driscoll, T (2019), Matlab vs. Julia vs. Python.

Markwick, D (2022), Fitting Mixed Effects Models – Python, Julia or R?, juliabloggers.

Perla, J, T Sargent and J Stachurski (2022), Quantitative Economics with Julia.

Read More

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button

Adblock Detected

Please consider supporting us by disabling your ad blocker