MATLAB Answers


MATLAB is not a fully oop yet... why is this?

Dear MATLAB community,
Could anyone tell me why some authors say that MATLAB is not a fully object-oriented programming language yet? They never argue.
Thank you!


Sign in to comment.

2 Answers

Answer by Walter Roberson
on 4 Jan 2012
 Accepted Answer

MATLAB OOP does not handle multiple inheritance.
Methods are chosen only based upon the first parameter, and not based upon the full signature.
There are some aspects of meta information and dynamic properties that are not really together yet.
Arrays of homogenous objects have to be derived from a specific class, and they have some clunky behaviours.
MATLAB OOP is also measurably slow.
At last glance, it looked like OOP support was not well advanced at all at the Mex level, but I might have misunderstood what I was glancing at.


Thank you Walter. Your explanation helped me a lot.
FYI, OOP programming at the mex level is very inefficient. The only functions available, mxGetProperty and mxSetProperty, make copies of the properties instead of returning pointers to the properties. For large sized properties this can be a major issue. I have written a mxGetPropertyPtr routine (in the FEX) that solves part of the problem. Your comments remind me that I need to test and post the other routine I wrote, mxSetPropertyPtr, that solves the other half of the problem.
Dear James. Thank you very much for the additional information. I know this is not the right place to ask these kinds of things, but let me ask. Comparing Matlab with Python, which language do you think better deals with OOP, considering numerical computing not an issue?
Thank you.

Sign in to comment.

Answer by Titus Edelhofer on 4 Jan 2012

Another aspect: you might well stick to the functional programming paradigm in MATLAB, if you like. My personal view would be to call MATLAB in this sense a hybrid language (in some sense like C++ where you can also mix OOP and functional programming, it's neither nor to 100%).


Thank you Titus for the extent.
Comparing Matlab and C++ is not correct in this sense. C++ is hybrid, but in a different sense, with full ability and efficiency of different paradigms (OOP, generic (template based), structured progrming, system programming, etc). Matlab tries to emulate these practically. However, it doesn't mean either of C++ or matlab is always worse or better (I use matlab)

Sign in to comment.