MathGroup Archive 2005

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

Search the Archive

Re: Re: Types in Mathematica

  • To: mathgroup at
  • Subject: [mg62205] Re: [mg62203] Re: Types in Mathematica
  • From: Andrzej Kozlowski <akoz at>
  • Date: Tue, 15 Nov 2005 04:16:04 -0500 (EST)
  • References: <> <> <dl8s4g$n41$> <dl980q$r2a$> <>
  • Sender: owner-wri-mathgroup at

>> a=1;
>> simply means whenever you see "a", replace it with "1". That's  
>> all. No
>> type.
> But there is IntegerQ.

Yes, but

f[(x_)?IntegerQ] := x^2

a /: IntegerQ[a] = True;



> One can view all symbols in Mathematica as variables in the sense of
> computer science.

All symbols? In what sense of symbol? How about:



Is Table a "variable in the sense of computer science"?

>> FORGET C++.
> Why?  Just because Mathematica doesn't behave like C++, doesn't  
> mean there
> is no value in comparing the two languages.

Undoubtedly, when you are beginner in Mathematica, knowing some other  
programming language can be of help. I remember that early versions  
of the Mathematica Book included several paragraphs in the  
introduction, each comparing Mathematica to a (then) better known  
programming language: I still recall that among these languages were  
C, Pascal, Lisp, and even Basic. However, once you get to a more  
advanced level thinking about other programming languages can be more  
of a hindrance than help.
The reason is that people coming form other programming languages  
tend to identify language with syntax. If they find that they can use  
familiar syntax they often believe they now know the language. But in  
the case of Mathematica the equation language = syntax does not hold.  
Users notice this eventually when they discover that two Mathematica  
programs, both written using perfectly valid syntax, and both  
seemingly implementing the same algorithm (note the word "seemingly")  
can differ in performance by several orders of magnitude (if you want  
to see this really convincingly demonstrated just search for some  
past postings by Carl Woll). If then one understands by "knowing the  
Mathematica language" simply knowing how write programs that run,  
then it is true that anyone who knows C or LISP already knows quite a  
bit about Mathematica programming. But if by "knowing the Mathematica  
language" one means "knowing how to write efficient programs" than  
the advice "FORGET C++." needs to be only supplemented by the advice  
In spite of some deliberate similarities in syntax internally  
Mathematica is neither like C nor like Lisp (which I am sure RJF, who  
certainly knows about LISP, will be happy to confirm ;-)) In fact  
Mathematica isn't even a really functional language (the only real  
functional aspect of Mathematica are pure functions like Function 
[x,x^2] or #^2&). the language is obviously a hybrid, with certain  
unique characteristics. For me this "hybrid" nature is one of the  
best things about the language but I am aware that there are some who  
have the opposite view on this. But I think everybody who has been  
following this list for a few month would would agree that to write  
an efficient Mathematica program knowing other languages is of very  
little help.

Andrzej Kozlowski

  • Prev by Date: Re: Re: Re: Timing runs for the last part of my previouspost
  • Next by Date: Re: Absolute value of a symbolic complex expression
  • Previous by thread: Re: Types in Mathematica
  • Next by thread: Re: Types in Mathematica