What is MATLAB?

MATLAB is a high-level programming language used most commonly in technical computing, such as for numerical computation or algorithm implementation. Developed originally by mathematician Cleve Moler in the 1970s, MATLAB was officially released in 1984 and has since grown into one of the most popular languages for scientists and engineers. It is also frequently used in the finance industry, a popular destination for young engineers looking for a job.

Why is MATLAB useful?

Most importantly, MATLAB is based on LAPACK, a linear algebra software library originally written for the scientific programming language FORTRAN. As a consequence, MATLAB offers powerful out-of-the-box functionality for operations on systems of linear equations (i.e. matrices) that would be way more difficult to implement in a language like C or Java.

I would even say that programming in MATLAB will generally take less time than in most traditional languages, which is why it is often used to prototype new ideas. Good MATLAB code is relatively concise. You won't see as many loops or if statements than in other languages, for instance, and variable declarations can be neglected in the majority of cases (memory pre-allocation is important, however). This not only reduces programming time but makes the code easier to read, too.

Furthermore, you do not have to compile MATLAB code before you can run it. Much like in Java and Python, MATLAB programmes can be run immediately and you can even test code snippets directly in the IDE's command window. That is possible because the compilation and interpretation tasks are done in the background when you run your software. This can be a big time saver for large projects where each recompilation would take several minutes or even hours to complete, but it comes with the obvious disadvantage that interpreted code is usually not as fast as compiled code.

What are MATLAB's disadvantages?

First of all, it is often said that software written MATLAB is slow. That statement is simply not universally true. With its new just-in-time (JIT) compiler, which pre-compiles certain parts of your code before actually running it, MATLAB performance has improved a lot over recent years, resulting in run times that are perfectly acceptable for almost all applications. However, it is true that for certain high-performance tasks where every microsecond (or even picosecond!) counts, as in high-frequency trading, it is recommended to run compiled software. Still, most firms prefer to test their ideas in MATLAB (or R or Python) due to the aforementioned time savings during development before porting the software to C.

Second, MATLAB was designed specifically for numeric tasks. Unlike C, Java or Python, it is no general-purpose programming language. Therefore, MATLAB should only be used when actually doing maths or when working with data. The interfacing with other applications or the operating system, for example, should be left to another language that is better equipped for that particular task.

Finally, compared to the open-source languages R and Python, an obvious disadvantage of MATLAB is that it is relatively expensive. Lower pricing for academic institutions and individual programmers is available, but when you need to purchase many of MATLAB's toolboxes the total can still be significant.

MATLAB in Finance

Taking these positives and negatives into account, it may become clear why MATLAB is widely used in the finance industry today. Financial markets deliver a constant stream of data that can be analysed in MATLAB more quickly than in many other languages. Learning MATLAB is definitely easier than learning C. (It will still take a lot of hands-on programming experience to discover the language's intricacies that ultimately result in elegant and efficient code, of course.) The available finance and trading toolboxes allow for an easy integration of MATLAB into a bank's or hedge fund's workflow without the need of extensive interface development.

Future posts will explain the MATLAB programming language in more detail and also highlight how to apply MATLAB to the world of finance.