Re: Language vs. Library

*To*: mathgroup at smc.vnet.net*Subject*: [mg61317] Re: Language vs. Library*From*: albert <awnl at arcor.de>*Date*: Fri, 14 Oct 2005 22:23:06 -0400 (EDT)*References*: <did3bd$qij$1@smc.vnet.net> <difr10$fc2$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hi Steven, > What I'm trying to identify is which parts of Mathematica are logically > more primitive than the others.Â Â > OneÂ thinkÂ I'mÂ confidentÂ ofÂ isÂ thatÂ theÂ core language is expressed in > FullForm, and involves neither boxes nor cells, nor does it require any > special characters such as \[Del]. If you are looking for the core of the language, FullForm is in my opinion quite a step forward. Remember that even {} is just a shortcut for List[]... If it is about extracting the essentials of Mathematica in order to learn how to use it better I think it helps much more to have a completley different point of view than trying to identify which functions (or symbols) are core and which are not. The following is probably not correct in every detail and a little oversimplified, but helps me to understand how Mathematica works. There is a chance that I am completly wrong, anyway :-). The core of the language are: 1) expressions, made of Atoms (Symbols, Strings, Numbers) and always of the (full-)form head[arbitrary,number,of,arguments]. I think you can find a more exact definition and a complete listing of the supported Atoms within the documentation. 2) replacement rules including very powerful patterns for expressions, applied to expressions implicitly by the evaluation process and to be changed, added to and deleted from the system with Functions like Set, SetDelayed or Clear. The evaluation process can be influenced in various ways by giving symbols Attributes like HoldAll, Listable, Orderless and others. That's it and it's even mentioned somewhere in the documentation: 'Mathematica is a term rewriting system'. This oversimplified view would make the chapters about the evaluation process and pattern matching probably the most important in the documentation if you seek for the core of Mathematica (understanding these in detail will also enable you to examine and answer your questions yourself). This is also the part that is hardcoded and can't be changed in any way (I think). That's in strong contrast to anything that could be thought of a 'core' function, see below. And last but not least, the pattern matcher is probably the most outstanding feature of Mathematica, compared to other Computer Algebra Systems. You should also learn that it makes no sense to even try to know all of the functions or even a complete subset, it is more important to develop a feeling to identifiy whenever you are trying to solve a problem that someone else might already has solved and learn techniques to find the functions/packages that do what you need. These search techniques are basically provided by the ?-Operator and the HelpBrowser, but could of course be improved. Sometimes a smart search patterns in google give you better answers much faster... To make clear why I wouldn't think it makes much sense to make listings of core or not so core functions within Mathematica look at this (I am using For not because I think that it is such an important "core" function, just because it was mentioned earlier): In[1]:= Unprotect[For] Out[1]= {For} In[2]:= For[___]:=Print["functional fundamentalist weirdo speaking: Don't use procedural programming, stupid!"] Now the following: In[3]:= For[i=1,i<10,i++,Print[i]] will not show exactly the behaviour you would expect from the 'core' of the language... And you could do this basically to every function/symbol (except for a few which happen to have the Attribute Locked) and you will even find many postings in this group where for special purposes doing things like this are even recommended. The possibility to change the behaviour of alsmost all symbols within Mathematica is very powerful and on the other hand makes it possible to produce complete nonesense. IMHO the latter is a general rule: the more power, the greater the danger of missuse. Producing nonsense is possible with any other system or language, too, and no special problem with Mathematica. A healthy skepticism towards any results you receive by functions (a.k.a. a set of replacement rules :-)) that you can't check should be recommended, anyway. Especially if you are after 'mathematical rigour' you better check everything, prefferable with another system. Also, honestly, I wouldn't enjoy a flight in an airplane controlled by a Mathematica notebook, but all that doesn't mean I consider Mathematica to be useless... And another remark which I know could be challenged in various ways: If you want comparations to other languages, I think something like XSLT (seen as handling "pattern matching" and "replacing" of XML "expressions") is much closer to Mathematica than any of the languages you mentioned. It also shares the fact that the syntax of the language is the same as that of the expressions it can handle. (Maybe someone is interested in writing an CAS in XSLT working on MathML expressions :-)). Don't expect me to spend much time discussing these statements, since I know they stand on loose ground and I'm only an "interested layman" concerning these things. And yes, if you want to use Mathematica in an efficient way, you will also need to know some of it's functions, but I think you can then savely choose the ones that are helping you most without spending time to find out whether they are part of the core language or not. albert