
Mathematica vs. Matlab vs. Python - soundsop
http://www.larssono.com/musings/matmatpy/index.html
======
gjm11
The title is a bit misleading; it compares the three for one single task only.
It's useful as an indication of how a few particular things might be done in
Mma, MATLAB and Python, but here are a few reasons to be very cautious about
(e.g.) looking at the amount of code involved in each case and leaping to
conclusions.

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".)

~~~
stcredzero
_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._

But which are the "native" formats for each environment?

~~~
gjm11
A Python pickle would be comparable to a MATLAB .mat file. For Mathematica,
you'd typically either make a text file containing Mma code (e.g., with the
Save function) or write binary data in some proprietary Mma form with
DumpSave. I'd guess the latter is faster and makes smaller files, but I've
never checked.

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.)

------
mjtokelly
Note that this article is dated 2005. Much has changed since then--for
instance, Python has migrated almost universally from Numeric to NumPy for
scientific computation.

------
aaronsw
I'm not Mathematica's biggest fan, but this is just a smear job. He goes way
out of his way to write code to do things that Mathematica does automatically.
For example, his 32 lines of bar chart display code can be replaced with:

    
    
        BarChart[numbers]

~~~
buugs
I agree that he is not a mathematica expert but to be one is a pain, the
documentation while good is a pain in the ass to navigate and why in the world
with so many functions is there no tab completion.

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]'

~~~
gjm11
Um. MATLAB _does_ have tab-completion.

(I agree with you about the Mathematica documentation.)

~~~
buugs
I said mathematica did not have tab completion, I do most of my school work in
matlab I know it has tab completion :) but it does have a very stupid
limitation that a function is a separate file.

edit: by stupid I mean can get annoying matlab really wouldn't work any other
way

~~~
gjm11
I'm sorry I misunderstood. You said "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 still don't quite see how I could have parsed that as
"Mathematica doesn't have tab completion", but no matter.

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.

------
sdfx
From the main page:

 _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._

------
illumen
It's nice comparing the python code from this article to what you can do now.

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.

