How to replace MATLAB

Ran out of MATLAB licenses at work? Memory issues? Too damn expensive? Fear not – below, I’ve provided a set of simple steps that you can take to replace MATLAB! All you need to do is open up the terminal and type the following (and for all those Fedora users out there, use yum instead of apt):

On Linux

Step 1: sudo apt-get install python
Step 2: sudo apt-get install python-pip
Step 3: pip install numpy
Step 4: pip install matplotlib
Step 5: python
Step 6: $$ profit $$

On OS X

Step 1: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Step 2: brew install python
Step 3: pip install numpy
Step 4: pip install matplotlib
Step 5: python
Step 6: $$ profit $$

In all seriousness…

I’ve come to love Python as a programming platform, which I really just started using about six months ago. While it may not be the best language for deploying production systems (Java/C++ is better for that), it’s quick, has an amazing set of packages which greatly extend its functionality, and best of all, is free. Want to do fast matrix arithmetic and more advanced computation? Use NumPy and SciPy. Want to experiment with algorithms in machine learning and computational statistics? Use scikit-learn or Vowpal Wabbit. Want to quickly create a robust web appliation? Use Flask. The possibilities are endless.

Admittedly, I had strong initial resistance to Python programming. Prior to becoming a Python addict, I essentially used only C/C++ and MATLAB (and sometimes still do today for my small side projects). For low-level tasks, C was a great language to use, while MATLAB provided me with a lot of high-level functionality. Occasionally, when I needed to throw together a quick demo for non-techies, I’d use Java for its easy GUI capabilities.

The beauty of Python is that it provides me with all three. Many Python libraries are coded in C/C++, and then “ported” to Python using bindings. This allows you to have speed and efficiency in a native high-level interpreter such as Python. In fact, NumPy’s array indexing conventions are so similar to MATLAB’s (see this page for details) that I was able to smoothly make the transition between MATLAB and numpy in something like half a day. Tkinter is also a great interface for creating and modifying windows, and, in my opinion, is easier to use than Swing.

Python does have its disadvantages as well. It’s lack of static typing means that you can potentially have lots of long bug chains within your code. Creating a 1-element Python tuple can be confusing – I still sometimes try to instantiate one without the trailing comma. It’s also absolutely terrible for long-term code maintenance, which is why most established companies and large open source projects use either Java/Scala or C++.

All-in-all, I think its advantages are too considerable to ignore. The next time you’re thinking about doing a small side project, take a step back and consider Python.