Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: fyi, small note on using Mathematica for object

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125942] Re: fyi, small note on using Mathematica for object
  • From: "McHale, Paul" <Paul.McHale at excelitas.com>
  • Date: Sun, 8 Apr 2012 04:17:02 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <201204060958.FAA22979@smc.vnet.net>

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 at 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 at gmail.com]
Sent: Saturday, April 07, 2012 5:58 AM
To: mathgroup at smc.vnet.net
Subject: [mg125942] 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 at 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 at 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 at yahoo.com
>




  • Prev by Date: Re: evaluate to True?
  • Next by Date: Re: Integers that are the sum of 2 nonzero squares in exactly 2 ways
  • Previous by thread: Re: fyi, small note on using Mathematica for object
  • Next by thread: Re: fyi, small note on using Mathematica for object