There are hundreds if not thousands of programming languages out there – but what’s the best programming language for Finance specifically?
Chances are, you’re thinking of one / some of these:
- Python,
- R,
- MATLAB,
- C,
- Java,
- STATA,
- SAS
- SPSS
- JavaScript
Hopefully, you’re not thinking of Excel.
You might well be thinking of VBA though, and that’s okay. Personally, I see VBA as a legacy language so I won’t be considering it in this post.
First things first. JavaScript is a great language in general – but not so great as far as data analytics and financial analysis goes. Unless you’re thinking of building fancy dashboards to visualise your analytics, we can safely rule it out.
STATA’s hardly a programming language, although it is powerful as an off-the-shelf statistical package, no doubt.
Both SAS and SPSS are reasonably widely used as of today, within Finance. But they are decreasing in popularity in general. And I’d contend that they’re being used widely today only because of perceived “switching costs”.
Nevertheless, I’ll consider these “languages” too. Hopefully by the end, you’ll know what the best programming language for Finance is. Spoiler alert – it’s not just one.
On simplicity and intuitiveness
Rather than talking about which languages are simpler and which one’s are harder, I thought it’d be a good idea to compare them by their code.
Here’s what it takes to print the words “Hello World!” in each of these languages:
C++
// Hello World in C++ (pre-ISO)
#include <iostream.h>
main()
{
cout << "Hello World!" << endl;
return 0;
}
Java
// Hello World in Java
class HelloWorld {
static public void main( String args[] ) {
System.out.println( "Hello World!" );
}
}
SAS
/* Hello world in SAS */
* Writes as output title;
TITLE "Hello World!";
* writes to the log;
data _null_;
PUT "Hello world!";
run;
STATA
/* Hello world in Stata */ .program hello 1. display "Hello, World!" 2. end .hello
SPSS
* SPSS Syntax * "Hello World" title in the Output Window of SPSS via SPSS Syntax. TITLE 'Hello World'.
MATLAB
% Hello World in MATLAB.
disp('Hello World');
R
# Hello World in R
cat("Hello world\n")
Python
# Hello world in Python 3
print("Hello World")
I think it’s fair to say that Python’s by far the easiest.
No semicolons, colons, periods, nested brackets, or any other complex syntax.

And this holds pretty much across the board – not just for printing “Hello World!”. Python’s syntax is widely regarded as one of the easiest out there. It’s one of the reasons most people will recommend Python as the first language you should learn.
Winner: Python
“Hello World!” comparisons across hundreds of languages is provided courtesy of The Hello World Collection.
On power and performance
There’s a whole Quora Q&A response on this topic. And essentially, there’s no right answer here. Because it boils down to what you want to do with the language.
Generally speaking, C++ and Java are probably the most powerful amongst the languages we’re looking at in this post.
But that’s purely in terms of computational power. And it’s not without caveats.
I’d argue you don’t need the power of C++ / Java to work on (reasonably standard) Finance tasks like these:
- Creating factor mimicking portfolios,
- Running Fama MacBeth regressions,
- Conducting rolling regressions,
- Implementing Principle Component Analysis (PCA),
- Running ‘machine learning’ algorithms.
- Evaluating backtests on trading strategies.
You’d be fine with MATLAB, Python, and R for sure. STATA would also work, but it struggles to deal with “Big Data”. In my experience, it struggled to work with a couple million observations. That’s “peanuts” for Python, MATLAB, or R. And this was with a University license, not a student / home license, meaning it’s almost certainly one of the more ‘powerful’ versions of STATA.
By ‘struggle’, I mean sometimes it won’t even load in the data, let alone allow you to conduct some sort of analysis. And other times, while it may load the data, it’s just painfully slow.
But between MATLAB, Python, and R, I’d have to (a little grudgingly) give the award to MATLAB. It’s faster than Python and R in many ways.
This YouTube video by “pseudorandomcoder” shows a simple but clear comparison between MATLAB and Python’s performance on some computations. He’s also got a couple of other videos on the same topic which I recommend watching.
A word of caution though – he refers to NumPy as “num-pee” (so wrong), and refuses to pronounce it correctly.
Disappointing, pseudorandomcoder, disappointing.
Winner: It depends, but it’s probably MATLAB.
On support quality
MATLAB has a pretty well documented support system. Most if not all the documentation is written by their employees, and is really good quality.
STATA’s support is reminiscent of the 1990s in that a large part of their support is in an “email format”. See this for an example. So you literally end up reading email threads with the greetings and email etiquette distracting you from finding the solution.
Now, they moved to a forum based structure back in 2014, but there’s a lot of legacy support answers still floating around the internet in email formats. But perhaps more importantly, in my opinion, the open source support on StackOverflow is way better, much friendlier, and more open – than the support on STATA’s forum, statalist.
As far as open source documentation goes though, R probably has the lead. Their packages (rightly) require reasonably high standards of documentation. From my experience, external packages on R tend to be less ‘buggy’, too.
Python’s documentation for the major packages (e.g. pandas, numpy, etc) is impeccably detailed. The same can’t be said for other packages however. I’m personally guilty of this too, to be honest. As of August 2019, I have 2 open source contributions including:
- getFamaFrenchFactors (it gets Fama French factors from the Kenneth French library, cleans it, and returns it as a pandas dataframe).
- CRSPcleaner (it takes in a CRSP database as a .csv file, cleans it, and returns it as a pandas dataframe).
Both of these packages don’t have the best documentation by any means. For a start, I should really spell out what I mean by “cleans it” in more detail.
Contrast that with R’s documentation, which requires a LaTex based PDF document with detailed information on the use cases for each package with plenty of examples.
Winners: MATLAB, R (Open Source)
On value for money
MATLAB
At the time of writing, MATLAB charges between £29 and £1,800 depending on who’s buying, and for how long. Specifically, they charge…
| Standard | Education | Home | Student | |
|---|---|---|---|---|
| Perpetual license | £1,800 | £425 | £105 | £29 - £59 |
| Annual license | £720 | £212 |
R
While R is free for individuals, their enterprise version starts at $21,220 per year at the time of writing.

In their defence… at least their pricing structure is clear and simple. Which is something I can’t really say for STATA.
STATA
Here’s their pricing structure for businesses.

And for the Perpetual license..
It seems like even their copywriter lost the plot after a while. The best they could come up with was “Faster & for the largest datasets”. Pay another $300 per year to get your programmes to run “Even faster”.
SPSS
Then there’s SPSS’ annual licensing fees for their 4 variants…

SAS
SAS didn’t show any clear-cut pricing plans, suggesting that it’ll quite a fair bit.
Python
Finally, there’s Python.
The cost? £0.
Regardless of whether you’re going for a single user, business, enterprise, you name it.
It’s free.
Winner: Python
On workflow management
This is a tricky one.
Most languages require using some sort of “tools” or “packages”. For instance, if you want to run time series or cross sectional regressions on STATA, you’ll need the xtreg package as far as I’m aware.
And every time you want to use it, you need to “import” it in some way (again, as far as I’m aware – I don’t tend to work with STATA).
For R, you’ll need to import their “libraries”.
And for Python, you’ll need to import a boat load of packages.
Sometimes, this can get a little bit painful to be honest. For example, you’ll need to import NumPy even if all you want to do is calculate the square root of a number.
MATLAB doesn’t really have this problem, since a lot of the mathematical and statistical functions are built in. So you can just get on with coding, instead of importing things every time you want to get some work done.
It also allows you to “package” your code into functions, so you can then reuse existing code instead of having to start from scratch every time.
For instance, you could write a programme that sorts portfolios on size, book-to-market, or other firm attributes, and save that as a “module” / “function” / “package” (not sure what the MATLAB specific term for this is) Then the next time you want to sort firms into portfolios, you can just call that “function” / “module” / “package”, and that’s that. You won’t need to code that aspect ever again.
This functionality is also available in Python and R. The beauty of these two languages however, is that you can share your “package” with the world. That way, other people can benefit from your code, too.
I think it’s possible to do this with MATLAB, but not in the same clean way as Python / R. And that’s mainly because MATLAB is not an open source language.
Winner: It really depends.
Verdict: Best programming language for Finance
Here’s what the scores look like:
- Simplicity and intuitiveness: Python
- Power and performance: MATLAB
- Support quality: MATLAB and R
- Value for money: Python
- Workflow management: it depends.
In my personal (and proudly biased) opinion, the best programming language for Finance, overall, would have to be Python.
R would be second best, and MATLAB would be third.
At the end of the day, it really boils down to your personal preferences, and any constraints from your organisation. For instance, if you’re working with / in a company that predominantly develops in MATLAB, you might have a tough time getting “buy in” to switch to Python.
On the bright side, the transferability is pretty high across these 3 languages. That means if you master one of them, you’ll find switching to another one fairly straightforward.
What I certainly would NOT recommend is trying to learn all 3 simultaneously. Choose one, and run with that.
And if you’re choosing to work with Python, check out my post on Python Tips to help you code better, faster, and more easily.
Feature image by Chris Ried on Unsplash

Leave a Reply