top | item 25602858

(no title)

scottlocklin | 5 years ago

It's a regression as far as code readability goes for fairly straightforward reasons: almost everything in Matlab is a matrix. Matrices are not first class citizens in Python, and it matters. I use Python a hell of a lot more than Matlab, but for examining how an algorithm works (say, for implementing in another language or modifying it to do tricks), Matlab wins. Go look at these PRML collections in Python and Matlab and see if you disagree:

https://github.com/ctgk/PRML

https://github.com/PRML/PRMLT

discuss

order

svantana|5 years ago

I used to feel the same, but three years after making the switch, I've changed my mind. Matlab code has brevity, but sometimes at the expense of clarity. For example, sum(x,axis=1) is more clear than sum(x,1). Especially when matlab has functions like diff() where the second argument is not axis.

Broadcasting in python is a lot more clean than the "bsxfun(@plus, ...)" abomination in matlab. If you think all the "np." is too wordy then just do "from numpy import *". For matrix multiplication you can use "@". Numpy code can be dense but most people choose clarity over brevity.

scottlocklin|5 years ago

I'd rather write python than matlab any day (I made this choice, literally in '98): it's a statement about reading. Matlab is closer to a a math notation and python is a clunky programming language. I'd never in a million years write new code in Matlab, but I prefer it for didactics.

srvmshr|5 years ago

The only thing I find nice in what Mathworks offers nowadays is their caps & T-shirts at conferences. MATLAB is on Medicare in deep learning times.