Is Matlab (vs. C/FORTRAN) a respectable language for a professional mathematical researcher of the 21st century?

mr matlab picture mr matlab · Dec 11, 2010 · Viewed 12.1k times · Source

I am a die hard user of matlab, mostly because this is what I learned first and I have not encountered a problem with a significant enough difference to switch. I come from numerical optimization/linear algebra, where I have performed optimization and eigenvalue computations in millions of degrees of freedom. Recently, I have entered the realm of randomness, where I was originally under the impression I would be forced to change. But, after optimizing code, and carefully initializing the seed to the random number generator, I am able to do the same Monte Carlo tasks as my contemporaries in roughly the same time. My understanding has been that base-level 'if' statements, etc., are significantly slower in matlab. However, if there are significant computations within each loop which can be vectorized, I'm not convinced C would be better. And, anyway, matlab seems to do just fine, in the sense that my upper bound is no less than any other professional (and in many cases, seems to be more). I have a feeling that I will get lots of responses from pro-C people here, who have written off matlab long ago as some trivial toy language. I am a professional researcher and contend that matlab is competitive for the highest level computationally intensive mathematical programming. Am I wrong ? Do I need to consider changing to a lower-level language, such as C/FORTRAN ? Why or why not ? Are there others like me ? Thanks alot! Cheers

Answer

High Performance Mark picture High Performance Mark · Dec 11, 2010

I work with a team of professional research geophysicists though I'm more of a numerical software engineer myself. I think that if your work is numerical mathematics then Matlab is very suitable, especially so since you are already skilled in its use.

You might write faster programs if you picked up C or Fortran, though perhaps not as much faster as you would hope since Matlab uses, for a lot of its numerical routines, the same BLAS (etc) libraries as you would if you were writing in C or Fortran. But from my working experience my colleagues find the ability to write programs more quickly much more important than writing quicker programs. They generate a lot of ideas which, upon reflection, they later reject. The added speed of development that Matlab gives over and above C and Fortran means that they go through the whole cycle (which generally includes visualisation of results) a lot more quickly and do it more often, so doing more science by some crude measure.

(As an aside: one of the jobs I get is to turn some of the Matlab code that is not rejected into Fortran programs for execution on the company's large clusters. But that's what happens to some of our codes when the initial research is complete and we want to deploy them for production.)

I'd also point out that Matlab has good parallel computing capabilities (if you can afford them) through its Parallel Compute Toolbox, which will probably be of interest as your problems become larger and you realise that you are underusing some of your cores, gosh it's even got integration with GPU computing in the latest release.

In a nutshell I'd suggest that staying with Matlab will allow you to focus on your mathematical research and not divert your attention to wrestling with a new toolset. Especially so since you do not suggest that Matlab is inadequate for your expected needs.