Thursday, March 10, 2016

Python > Matlab?

I find myself substituting Python (+Numpy+SciPy+SymPy) for applications, where I would have whipped out some quick Matlab/Octave code in the past. By no means do I consider myself a skilled python programmer, but almost everything I used to do in Octave/Matlab, I can do in python; and very often I can do it better.

As an analogy, Matlab is like an applicant who has a very high score on the quantitative section of the SAT; while Python is like an applicant who is nearly as good on quant, but also has excellent verbal, and writing skills.

Here are a set of articles that echo a similar sentiment:

1. Why use Python for Scientific Computing (Cyrille Rossant)
  • free and open-source
  • better and complete language
  • rich library set
  • plays nice with other languages and OS
2. Keep Calm and Code in Python (Lorena Barba)
  • great teaching language
  • very easy to get useful work done
  • good string manipulation
  • demand for python programmers
There are a lot of other links to python evangelists in the links above.

Personally, what I really like about python is:
  • the arbitrary constraint of requiring files and global functions to be "atomic"
  • I find visualization using matplotlib (with seaborn or ggplot) to be better and more configurable
  • same with 3D visualization using MayaVi2 for instance or arbitrary graphics
  • I just love jupyter notebooks. They help me keep code with documentation (which might include LaTeX markup). It has become my default mode of preparing new lectures.
  • python clearly has momentum

What are possible downsides of moving from Matlab to Python?
  • if you've used Matlab for a long time, you have to unlearn a few things
  • installation, while much simpler these days, can be intimidating for some
  • the python world currently is stuck between v2.x and v3.x
  • for a subset of tasks (especially linear algebra) I find Matlab more intuitive. For instance, 1d arrays are either column or row vectors; in numpy the distinction is fuzzy.
  • operator overloading: multiply matrix and vector in Matlab is just A*x; in python you have to say,x)

No comments: