April 20th, 2007, 3:21 am
QuoteOriginally posted by: CuchulainnQuote don't think matlab is very good for large-scale apps though. Its natural workflow is jotting down some lines, refining them on the fly, breaking it down into functions as it starts to become unmanageableIs this situation caused by 1) inherent limitations of the language 2) not using OO or 3) other reasons? 4) combination of 1-3?Of course - as you say - memory considerations do play a role.1. Inherent limitation.The main problem with Matlab as a language is its lack of pointers, references, or handles to objects. Basically, it is modeled on Fortran 77, not on C. Matlab also lacks heap, but with dynamic global memory, and few other facilities like an access to the top scope it is possible to work around. The lack of pointers makes hard writing big asynchronous programs. Asynchronous in practice means event processing - including GUI and interactive graphics. Processing of events, as a rule, involves modification of internal data. How to find the modified data without pointers? With smaller programs we can make the data global, but with bigger programs it is not a good solution. At this point most of people abandon Matlab and port codes to C, C++, Fortran or other languages.2. Not using OO in Matlab:- Chicken and egg problem. People do not use OO because nobody uses it. - High barriers to entry to OO:-- Practically no real-life codes to learn from. I do not know a single MathWorks "toolbox" that uses OO. -- Poor documentation. The descriptions and examples of OOP in the documentation are boring and labor intensive: most of them are just long switches with template snippets of codes for each variable. Generic programming saves the Matlab OO, but it is not described at all in Matlab documentation. My impression is that MathWorks does not know that the generics is possible.-- Confusion between three kind of OOP in Matlab: Graphic objects, Java classes (yes, Matlab is open to Java classes), and Matlab classes proper. Personally, I spent three months on learning Matlab OOP, about 1.5 to 2 of them in futile attempts to learn how to inherit Matlab objects from Matlab graphic objects (there was some vague wording in documentation that it is possible, but it is impossible).3. Other reasons:Matlab is positioned as a prototyping tool, and few people ever consider it for production. However, in its current form, I would say after version 6 or 6.5, it can be used in production. I was forced to write in Matlab an interactive graphics / computational geometry / signal processing program, consisting of about 385-390 files / functions. It was fast enough (soft real time) and my users did not complain for crashes for months. I would prefer to code it in C++, but it proved to be possible in Matlab.