The language was dynamically typed, and made it appear (by default) to the programmer as if every numeric variable was a matrix of doubles, but that didn't mean that all variables actually had to be implemented as matrices of doubles. The big issue with MATLAB (and other dynamic languages) is that the languages are very... dynamic, and as such, make little information available to the compiler as to the precise semantics of programs. This type information was then fed into a type analysis which allowed the JIT to lazily generate a compiled version of this function that was optimized specifically for the given argument types.