# Is MATLAB a compiler?

105 views (last 30 days)

Show older comments

### Answers (3)

Jan
on 24 Sep 2017

Edited: Jan
on 24 Sep 2017

No, Matlab is not a "compiler", but an "interpreter". A compiler converts the source code to an executable file, which is not readable by human anymore. When working with an interpreter, the readable source code remains the base of what is executed. But even in Matlab the code is interpreted and optimized, here by the "JIT accelerator". This removes e.g. redundant code and re-orders the commands, if it improves the processing speed. But the accelerated code is not written a the disk, but stored in the RAM only. It is debatable, if this can be called "compiling" or not.

In opposite to Matlab, FORTRAN compiles the source code into an executable file. This takes some time, but it is done once only, while Matlab interprets the source code each time it is loaded the first time in a Matlab session (or after a user called the bad clear all).

In fact some code is processed faster in FORTRAN or C compared to MATLAB. MATLAB's JIT accelerator could work more efficiently, I assume. But as usual I point out, that MATLAB as other programming languages is not designed for benchmarks only, but to solve problems. The time to solve a problem consists of different parts:

total time = design + programming + testing and debugging +

documentation + run time

When I create a tiny function for a linear algebra problem:

x = B \ (A * b + c) % A, B: Matrices, b, c: vectors

this can be done very compact in MATLAB. Internally very fast C/Assembler routines of the BLAS libraries are called to perform the calculations. You can call these functions from C or FORTRAN also, but the calling is much more complicated and prone to bugs. Therefore I assume, that programming and debugging will take more time in FORTRAN and especially in C than in MATLAB.

##### 2 Comments

Image Analyst
on 24 Sep 2017

##### 0 Comments

Snoopy
on 24 Sep 2017

##### 4 Comments

Star Strider
on 25 Sep 2017

@ Walter —

If I could give a separate vote to your Comment here, I would.

### See Also

### Categories

### Products

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!