Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: fyi, small note on using Mathematica for object
Replies: 5   Last Post: Apr 13, 2012 4:51 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
McHale, Paul

Posts: 60
Registered: 5/29/11
Re: fyi, small note on using Mathematica for object
Posted: Apr 8, 2012 4:18 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

This is not a simple answer. Here is my best attempt.

"Computer Science with Mathematica" (Roman Maeder),

14.1.4 Object-Oriented Programming in Mathematica
Object-oriented programming is not built into Mathematica. It has been implemented in the package Classes.m.

It can be downloaded from:
http://library.wolfram.com/infocenter/Articles/3243/

I would argue Mathematica support some object oriented concepts such as polymorphism.

mfunc[x_Integer] : x^2;
mfunc[x_Real] := x^3;
mfunc[2]
4
mfunc[2.0]
8

Encapsulation could be considered a natural fall out of the functional programing style. Though what you are encapsulating is extremely limited to a method with local scope variables via Module[].

To my eye, inheritance doesn't make sense without classes.

As far as rigid class structure, it appears it is not here, per se. Roman's book was written for Mathematica 4. Maybe Mathematica 8 has new additions...

My conclusion is Mathematica is a modern functional programming language. It is not a modern object oriented programming language. Many people here resort to Java for their object oriented needs as Java integrates very well with Mathematica.

To be fair, IDE environments like VisualStudio C# set object oriented programming bar so high that all other object oriented environments will be laborious by comparison. Just my opinion.

Having said all of this, there is a definite gap between Mathematica notebook scripting and Mathematica large program development. Fortunately the scripting is powerful enough to get me through most tasks.

Paul

Paul McHale | Electrical Engineer, Energetics Systems | Excelitas Technologies Corp.

Phone: +1 937.865.3004 | Fax: +1 937.865.5170 | Mobile: +1 937.371.2828
1100 Vanguard Blvd, Miamisburg, Ohio 45342-0312 USA
Paul.McHale@Excelitas.com
www.excelitas.com



Please consider the environment before printing this e-mail.
This email message and any attachments are confidential and proprietary to Excelitas Technologies Corp. If you are not the intended recipient of this message, please inform the sender by replying to this email or sending a message to the sender and destroy the message and any attachments.
Thank you

-----Original Message-----
From: Ralph Dratman [mailto:ralph.dratman@gmail.com]
Sent: Saturday, April 07, 2012 5:58 AM
Subject: Re: fyi, small note on using Mathematica for object

Bobby,

Please explain how you mean this. It is not a technique I have been able to find in the Virtual Book or other documentation.

What corresponds to a class, and how does one use a class to create one or more object instances? How does one run a method from an object?

A brief example would be most helpful.

Thank you.

Ralph


On Fri, Apr 6, 2012 at 5:58 AM, DrMajorBob <btreat1@austin.rr.com> wrote:
> Mathematica is already object-oriented WITHOUT all that. What a lot of
> overhead for nothing.
>
> Bobby
>
> On Thu, 05 Apr 2012 04:49:54 -0500, Nasser M. Abbasi <nma@12000.org> wrote:
>

>>
>> Just FYI,
>>
>> I wrote this small note on using Mathematica for object-based
>> programming. I found that it works really well for me.
>>
>> Nothing too advanced, just a simple way of using Module[] but in a
>> way to emulate object based programming that I did not know about
>> before.
>>
>> http://12000.org/my_notes/object_based_in_mathematica/v1.html
>>
>> --Nasser
>>

>
>
> --
> DrMajorBob@yahoo.com
>






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.