Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The Mathematica language is optimized for the <a href="https://stackoverflow.com/q/4430998/211232">symbolic programming paradigm</a>, and provides the most leverage and convenience when one stays within that paradigm. Object-oriented programming is a significant departure from the symbolic paradigm, and one ends up having to write most of the supporting infrastructure from scratch. There is nothing inherently wrong with that, of course, but it would be much less effort to exploit the <a href="http://reference.wolfram.com/mathematica/JLink/tutorial/Overview.html" rel="nofollow noreferrer">J/Link</a> facility and write OOP code in Java. The <a href="http://www.wolfram.com/products/workbench/" rel="nofollow noreferrer">Wolfram Workbench</a> makes it easy to mix Mathematica and Java code.</p> <p>It would be fruitful to think about what requirements are driving one towards an OOP solution. The question suggests that the interest is in how to <a href="https://stackoverflow.com/q/7356691/211232">simulate structure types</a>, but perhaps there are other concerns like encapsulation and polymorphism. It seems there is scope for some more specific follow-up questions along the lines of "What is the Mathematica equivalent of the object-oriented idiom <em>X</em>?". </p> <p><strong>OOP Considered Harmful?</strong></p> <p>Within the context of Mathematica, object-oriented programming might even be considered harmful. OO emphasizes the creation of "black box" objects whose internals are inaccessible to outside callers. While this has obvious benefits for complexity control through information hiding, it does fly directly in the face of the power of symbolic programming. Mathematica emphasizes synergy between seemingly unrelated components by allowing the symbolic representation of one to be transformed into the symbolic representation of the other. A "black box" does not play well in this ecosystem. As a concrete example, contrast the difference between <code>Graphics</code> "objects" and the new V8 <code>Graph</code> objects. The latter take a somewhat OO approach -- generating some <a href="https://stackoverflow.com/questions/6315899/how-can-i-programmatically-access-information-about-a-graph-object-in-mathemati">negative feedback</a> in the community.</p> <p>None of this is to say that OO is intrinsically harmful. The point of this discussion is that OO is foreign to the Mathematica ecosystem and that by taking that design choice, one might rule out some desirable synergies in the future. Take that decision consciously.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload