Mathematica vs. Matlab vs. Python
larssono.com
larssono.com
1. It's just a single problem.
2. It happens to be (by accident or design) one that plays right to MATLAB's strengths (matrix manipulation and plotting). Numeric Python and Pylab are aiming at pretty much the same domains. Mathematica, less so.
3. The MATLAB code reads the input data from a MATLAB .mat file (which only MATLAB knows how to read and write). The Mma and Python code gets it from a text file. Curiously, the MATLAB code for reading the data is much shorter than the Mma and Python code for the "same" job.
4. The code is less than perfectly idiomatic. For instance, the Mma code for counting null data occupies 11 lines when it could be one line (and that not terribly long or terribly obscure): numbers = BinCounts[Map[Count[#,Null]&,matrix],{0,genes}] .
5. The MATLAB and Python plotting code just accepts the default options for the plots. The Mma plotting code is full of option-setting. Presumably the author really likes the MATLAB defaults and can't stand the Mma defaults. At least one instance of this option-setting (the repeated DisplayFunction -> Identity) is simply explicitly setting the Mma default.
(About half the difference between the Mma column and the others is accounted for by this gratuitous option-setting.) [NOTE: edited to insert the word "half", which I accidentally omitted.]
The author says "using the wrong tool can cause undue work". That's true, and to some extent his comparison demonstrates this. But it also demonstrates the almost equally obvious principles: "using a tool you don't know how to use well can cause undue work", and "doing unnecessary work just for the sake of making your code longer can cause undue work".
(For the avoidance of doubt: I agree that Mathematica is a poor choice of tool for this job. I think the author of the page could, if he'd bothered, have done a comparison that demonstrates that honestly rather than giving a false impression. He could even have tried them on a variety of tasks, some of which weren't optimized for MATLAB and Python+Numeric+Pylab. But perhaps that would have been "undue work".)
Posts like these should be attached to the original article.
But which are the "native" formats for each environment?
More realistically, though, in any situation where you're seriously trying to decide between Mma, MATLAB and Python, your data will be coming in in some "neutral" format and you'll need to parse it. So the Mma and Python code is much more realistic than the MATLAB code.
(But perhaps when the author actually needed to do this, it happened that the previous step had been done in MATLAB. That would explain taking input as a .mat file.)
BarChart[numbers]Most of the naming seems to be okay in matlab but sometimes it would be nice if you could tab and see a list of matches.
and I much prefer matlabs: 'help [function]' to the output of '??[Function]'
(I agree with you about the Mathematica documentation.)
edit: by stupid I mean can get annoying matlab really wouldn't work any other way
Yes, the one-function-per-file rule in MATLAB is horrible. (Of course you can have one class per file and define many methods there, if you want.) As is just about everything else about MATLAB-qua-programming-language.
Using mathematical languages to solve real world problems can offer very different experiences. The results will be the same but using the wrong tool can cause undue work. Here I present a table of three different language solutions to the same problem; Calculating and displaying the Singular Value Decomposition of a set of Micoroarray experiments.
Modern python/numpy will look more elegant.
Also modern numpy can do GPU, multi core and SIMD optimisations (not out of the box... yet).
There's a few pages on the numpy wiki for converting between the two. However both numpy and matlab expressions often look very similar.