Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why was Matlab written in C instead of Fortran?

As you may know, Fortran is a language for scientific computing. however, the kernel of the most famous high level language for scientific computing has been written in C instead of Fortran. Why?

like image 885
Kamran Bigdely Avatar asked May 29 '09 10:05

Kamran Bigdely


People also ask

Is MATLAB written in Fortran?

It was based on Fortran, it was not a particularly powerful programming language, and it did not represent current research work in numerical analysis.

What benefits does MATLAB hold in contrast with C or Fortran?

MATLAB was built for matrix computations, and while yes it is slower than C++/Fortran compiled code, there is a powerful way to make it really fast called vectorization, which is easy to learn. These are a single line of code, that can manipulate data in many ways in giant arrays/matrices.

Is C better than Fortran?

Judging the performance of programming languages, usually C is called the leader, though Fortran is often faster. New programming languages commonly use C as their reference and they are really proud to be only so much slower than C.


1 Answers

To answer your original question: Matlab was originally written in Fortran. But one of the first things that the creator of Matlab, Cleve Moler, and his partner did in 1983 was to rewrite the entire Matlab app in C:

Jack Little left his job at the consulting company and bought a new COMPAQ portable computer at Sears. The machine had only 256 KB of memory and no hard disc; Jack had to swap 5-1/4-inch floppies to compile programs. Jack and Steve took a year and a half to re- write MATLAB in C, adding new features they had envi- sioned. (The Growth of MATLAB and The MathWorks over Two Decades)

I think a more relevant question for today would be to ask: why did they switch to C back in 1983 ?

My guess is that C probably had certain features that Fortran did not have and thus the switch was more out of necessity and in the interest of code maintainability.

One killer feature missing in Fortran77 was dynamic memory allocation (Dynamic memory allocation was only added in Fortran90). Getting around that single limitation would be a horrible deal breaker in my opinion.

EDIT:

dmckee's answer has a great explanation of why using Fortran77 would be painful.

like image 69
Trevor Boyd Smith Avatar answered Oct 06 '22 01:10

Trevor Boyd Smith