
Wolfram Language - lelf
https://reference.wolfram.com/language
======
jwr
I find it amusing that many people (seemingly Hackers) concentrate on
Wolfram's ego rather than on the actual thing at hand. I don't care about
egos, lipstick color, or the pants the language creator wears. I care about
the language, so let's talk about it now:

From a long-time Mathematica user: this is not a language I like. I use it,
but there is little to no fun. Many things aren't immediately clear or become
problematic if you stop using the language for a while. As an example, quick,
what is the difference between Module[], Block[] and With[]? Even if you
remember that With[] is a lexical scoping construct, Module[] and Block[] can
be confusing.

It doesn't help that Mathematica is absolutely horrible for debugging code. I
don't know why they put so little emphasis on their REPL, but it's way behind
the times. Even mismatched parentheses can cause serious pain (and I _hate_
the fact that things move around when I edit parentheses).

That said, I have a lot of respect for Mathematica as a complete system. It is
incredibly useful, most mathematical tools you will ever need are there. It is
also a great tool for explorative data analysis. Have a pile of data you'd
like to see patterns in? Load it up, mash it into shape with high-level
functions, then quickly produce great-looking graphics. Nothing even comes
close to the flexibility of Mathematica here.

~~~
maaku
Because ego blinds one to effective criticism. And the criticism many of us
have with Wolfram products is that while smart in limited domains, they can be
blindingly stupid in others (your various examples providing evidence for
this). If he _listened_ to and _respected_ our complaints, maybe we'd have a
better product. But no.

~~~
taliesinb
Not really. Stephen knows how poor our debugging facilities are (and I
regularly tell him how bad the situation is) -- we've just had limited
bandwidth to actually fix it properly to our satisfaction.

Luckily I have a totally revamped debugging and logging system that will put
us _ahead_ of the curve here (imagine DTrace at a program level). Probably a
point release of V10.

Same goes with multiple undo and retina support -- we know how embarrassing
their absence is, and we've luckily been able to fix these for v10. I've been
in design meetings where the multiple undo has bumped several other desirable
features off our roadmap.

~~~
spitfire
How about hashmaps, something like records and other constructs for building
large, long lived applications.

I'd kill for hashmaps, some sort of records and strong typing in Mathematica.

~~~
trurl42
Here are your hashmaps:

[https://reference.wolfram.com/language/guide/Associations.ht...](https://reference.wolfram.com/language/guide/Associations.html)

~~~
spitfire
Awesome. Is this a new thing? I can't find it in the Mathematica 9
documentation.

So now there's just strong types and something like records left for me for
general purpose development.

~~~
trurl42
Yep, they are marked as new here:
[https://reference.wolfram.com/language/ref/Association.html](https://reference.wolfram.com/language/ref/Association.html)

------
klrr
I like what they write about functional programming.

"Functional Programming

Long viewed as an important theoretical idea, functional programming finally
_became_ truly convenient and practical with the introduction of the Wolfram
Language."

Not sure if anyone can take that seriously.

~~~
jordigh
Not just that, he also seems to think that he invented Lisp's idea of code-as-
data: "In most languages there’s a sharp distinction between programs, and
data, and the output of programs. Not so in the Wolfram Language. It’s all
completely fluid. Data becomes algorithmic. Algorithms become data. There’s no
distinction needed between code and data." (
[http://blog.wolfram.com/2013/11/13/something-very-big-is-
com...](http://blog.wolfram.com/2013/11/13/something-very-big-is-coming-our-
most-important-technology-project-yet/) )

Kinda funny considering how the Mathematica language is built on top of the
M-expressions that lisp never bothered to implement.

~~~
msutherl
Note that this is marketing copy aimed at Mathematica users, mainly scientists
and mathematicians, most of whom probably don't know what LISP or Haskell are.

~~~
taliesinb
I think that's part of it. It's also aimed at non-hackers who took a look at
Clojure once and said 'yuck'. And managers who are being 'groomed' not to
totally freak out when someone on their team says "can we use the Wolfram
Language on such and such a project?".

------
ianbicking
These comments would be a lot more interesting if people identified what was
cool rather than just bitching about ego or syntax or licensing. I'm not going
to be using the Wolfram Language, but I'd love to identify the best ideas from
it. And it's a different enough language that I am confident there are
interesting ideas in it.

My own contribution:

Idly looking about I come upon this page, which is not particularly notable:
[https://reference.wolfram.com/language/ref/Sow.html](https://reference.wolfram.com/language/ref/Sow.html)

What is notable is this example:

    
    
      In: Reap[Sow[a]; b; Sow[c]; Sow[d]; e]
      Out: {e, {{a, c, d}}}
    

Reap/Sow ss a funny language feature that I haven't imagined before, but
that's not really the point. The point is that this is a runnable example –
that's actually what is output. Typically when you run something like that you
get "NameError: a is not defined". And "a" here is really a variable, of sorts
– it's not a string or symbol (at least not a symbol in the sense that we know
them in programming).

Given this, snippets of code are just as executable as entire programs. Every
expression is like a function with the free variables as its parameters, and a
sequence of expressions is a bit like function composition.

This is all natural from the perspective of mathematic notation. In a more
traditional programming environment I think it's reminiscent of partial
evaluation:
[https://en.wikipedia.org/wiki/Partial_evaluation](https://en.wikipedia.org/wiki/Partial_evaluation)
– where you analyze a program and execute expressions opportunistically. It's
really almost the same as partial evaluation, but the Wolfram Language knows a
lot more about how you can execute different combinations of expressions than
a typical language. A typical language does not really "believe" that (a+b)
and (b+a) are equivalent. It doesn't know how to relate different operations.
Nor do normal languages have a concept of simplification, so they can't
speculatively try other arrangements (where none in isolation is clearly
better or simpler than another) to see if simplifications are possible.﻿

~~~
pr_fancycorn
What you are getting at here is the fact that Mathematica is a symbolic
language through-and-through.

In my webpage here:
[http://www.oftenpaper.net/sierpinski.htm](http://www.oftenpaper.net/sierpinski.htm)
I try to give passing mentions to how the Mathematica language and its
infrastructure make various things easier.

As a programming language geek, I haven't found a language more powerful than
Mathematica, and that's before considering the infrastructure it comes with.

~~~
sixbrx
I've always found the repeated application of rules to simplify patterns in
expressions until the expression stops changing to be pretty powerful when
just playing around, especially with small problems. However, in my experience
in bioinformatics, that flexible approach is so slow in the face of actual
data as to be totally useless for use on real problems in my line of work.

I think an option to use a faster, less powerful, linear pattern matching
algorithm more like in ML/Haskell would help a lot in this regard.

------
oleganza
When I was a student and working with Mathematica 5 and 6 a lot, I was always
amazed about its simplicity and power. I had just two windows: typing in a
white document window without any toolbars (only zoom control in the bottom)
and having another window with documentation. And the documentation was great:
you could evaluate examples right inside the doc page, play with parameters,
like in your own document.

The design of the language, user interface and depth and clarity of
documentation makes me think that Wolfram Research is even more design-
obsessive than Apple. Stephen Wolfram takes credit for too many things (like
Jobs), but he also delivers amazing stuff.

~~~
sampo
> _a white document window without any toolbars_

How did you set that up?

~~~
tokipin
you can do

    
    
        SetOptions[EvaluationNotebook[], DockedCells :> {}]
    

and there are options to remove the window frame, etc. but i think if you are
using certain licenses the toolbar may not disappear. and the _main_ toolbar
never disappears, to my dismay

------
trurl42
So far it seems like the "Wolfram System" and the future "Mathematica 10.0"
are the same thing (see:
[http://reference.wolfram.com/language/tutorial/WolframSystem...](http://reference.wolfram.com/language/tutorial/WolframSystemFileOrganization.html)
)

Licensing doesn't seem to have changed:
[http://reference.wolfram.com/language/guide/SystemAndLicense...](http://reference.wolfram.com/language/guide/SystemAndLicenseManagement.html)

~~~
xradionut
So it's "A New Kind of Marketing" ?

~~~
tokipin
part of the problem Mathematica has is that people assume it's just for math,
which isn't the case. it's a very general system. this renaming, while utterly
dorky and aesthetically hamhanded, will at least help clear that
misunderstanding

------
lispm
The language lacks a spec. For a language with mathematical background this is
a joke. The descriptions of core features are just not existing - not even
talking of a semantic definition, like Scheme has now since a few decades.

Maybe they want to prevent alternative implementations.

~~~
tokipin
the spec of the underlying language would be very simple. it's basically just
repeated pattern matching. beyond that, knowing where to draw the line would
be a bit weird. for example, does the function TextRecognize [1] need to be
specified?

and by the way, Mathematica's documentation is enormous so i don't think a
single spec would be necessary. maybe a few functions here or there would need
some clarification in certain edge cases, but those would be higher-level
functions like Plot

[1]
[http://reference.wolfram.com/mathematica/ref/TextRecognize.h...](http://reference.wolfram.com/mathematica/ref/TextRecognize.html)

~~~
lispm
Wrong. Just check the core language. It large and there is much more than
repeated 'pattern matching'.

~~~
tokipin
right, but in those cases you can just go to the documentation, which is
pretty clear in the various ways you can use functions. for example:
[https://reference.wolfram.com/language/ref/Map.html](https://reference.wolfram.com/language/ref/Map.html)

~~~
lispm
does it provide closures?

~~~
tokipin
yes, using Module primarily. here's one way you might make a basic object-like
thing (though i would generally advise against OO stuff in Mathematica. part
of the power of the language is due to how it keeps everything
straightforwardly manipulable):

    
    
        makeObj[] := Module[{obj, i = 0},
         obj["inc"] := ++i;
         obj["dec"] := --i;
         obj[] := i;
         obj];
    

precisely speaking, however, Module simply renames symbols to make them
unique. the effect is the same as a closure, but it isn't a "pure" closure
like you would find in other functional languages, because you can do for
example Names["i*"] and find that the supposedly-private 'i' has the name
i$2656 and you can alter its value that way

another point is that you could, if you wanted to, create your own version of
Module and other scoping stuff, since it's a matter of making a macro by using
the HoldAll atttribute [1] and using 'ReplaceAll' to replace specific
variables or arbitrary structures

[1]
[http://reference.wolfram.com/mathematica/ref/HoldAll.html](http://reference.wolfram.com/mathematica/ref/HoldAll.html)

~~~
lispm
are functions being passed/returned as closures?

~~~
tokipin
if you're asking whether functions in Mathematica are first-class values, then
yes. everything in Mathematica is first-class. functions are just symbols that
have associated pattern-matching rules in the form f[___], otherwise they are
the same as any other symbol.

you can do, for example:

    
    
        RandomChoice[{Plus, Times}][2, 3]
    

where the result will be either 5 or 6. in more explicit form:

    
    
        If[RandomReal[] < .5, Plus, Times][2, 3]
    

example of an "anonymous" function:

    
    
        (#1^2 + #2^2 &)[2, 3]
    

square of all numbers from 1 to 100:

    
    
        #^2 & /@ Range[100]
    

simpler form:

    
    
        Range[100]^2
    

all pairwise products of the first seven prime numbers (among themselves):

    
    
        Times @@@ Tuples[Prime /@ Range[7], 2]
    

etc.

~~~
lispm
I'm asking if first class functions also can be closures. Does it use lexical
binding?

~~~
tokipin
i think i answered that question already, which is _yes_ , but technically
_no_. here is a rough Javascript version of the original example:

    
    
        makeObj[] := Module[{obj, i = 0},
         obj["inc"] := ++i;
         obj["dec"] := --i;
         obj[] := i;
         obj];
    
    
        makeObj = function() {
            var i = 0;
            
            var obj = function(in) {
                switch(in) {
                    case "inc" : return ++i;
                    case "dec" : return --i;
                    case undefined: return i;
                };
            };
    
            return obj;
        };

------
petercooper
I'm always struck by how slick and well produced everything related to Wolfram
is. It's not what I've come to expect from most academically leaning companies
at all. This goes for NKS which is a beautifully presented book whether or not
you go along with its contents.

~~~
jordigh
It seems that whenever Wolfram makes these grandiose and dubious claims, there
are always people cheering him on. The comments on his blog posts are always
unending adulation. You sound just like those people.

I very much doubt that those of us who doubt just about all the marketing
fluff that he exposes are just not understanding his genius. I have read parts
of NKS, and I don't think it's all that fascinating other than "cellular
automata produce pretty pictures, and there's no reason to try to understand
why they do this." It's very cranky.

I think Stephen Wolfram is just a rare breed of socially successful crank. He
scores high on the crackpot index, but not high enough to be completely
discredited as a lunatic. His litigious nature and ability to wrangle the
legal system in order to label everything "mine" is what keeps him in
business.

~~~
hdevalence
For those curious for more details about "He scores high on the crackpot
index, but not high enough to be completely discredited as a lunatic. His
litigious nature and ability to wrangle the legal system in order to label
everything "mine" is what keeps him in business.", see this review of "A New
Kind of Science", which begins:

> Attention conservation notice: Once, I was one of the authors of a paper on
> cellular automata. Lawyers for Wolfram Research Inc. threatened to sue me,
> my co-authors and our employer, because one of our citations referred to a
> certain mathematical proof, and they claimed the existence of this proof was
> a trade secret of Wolfram Research. I am sorry to say that our employer
> knuckled under, and so did we, and we replaced that version of the paper
> with another, without the offending citation. I think my judgments on
> Wolfram and his works are accurate, but they're not disinterested.

> With that out of the way: it is my considered, professional opinion that A
> New Kind of Science shows that Wolfram has become a crank in the classic
> mold, which is a shame, since he's a really bright man, and once upon a time
> did some good math, even if he has always been arrogant.

[http://vserver1.cscs.lsa.umich.edu/~crshalizi/reviews/wolfra...](http://vserver1.cscs.lsa.umich.edu/~crshalizi/reviews/wolfram/)

~~~
elehack
How can they have legal standing for such a claim, unless one of the authors
had privileged access to Wolfram Research knowledge to misappropriate a trade
secret? Seems to me that the principle of trade secrets should have a clear
defense for independent rediscovery, although law often fails to reflect
common sense.

~~~
dragonwriter
> How can they have legal standing for such a claim, unless one of the authors
> had privileged access to Wolfram Research knowledge to misappropriate a
> trade secret?

The absence of legal standing obviously is something that can be raised once a
lawsuit is underway, but it doesn't prevent the threat of a lawsuit, and many
organizations will knuckle under to the threat of a lawsuit from a wealthy
opponent just to avoid the expense of consulting with lawyers if there isn't a
big cost in avoiding the lawsuit.

------
vph
One has to take a grain of salt with Stephen Wolfram's claims of superiority.

Nevertheless, it appears that people have to pay to use "the Wolfram language"
(although there might be scenarios that allow "free usage" for the purpose of
attracting users who will eventually pay for using the language if they want
to scale up their work). The concept of paying to use a language is
troublesome in terms of common understanding of what a language is.

------
xfax
Serious question - is Mathematica popular outside of academic circles? I
remember being blown away in college but haven't used it since.

~~~
bhouston
I've seen it used for prototyping, proving and equation simplification in the
simulation space, but then those algorithms were converted to C++ for
production use.

MATLAB can also be used in this fashion:
[http://www.mathworks.com/products/matlab/](http://www.mathworks.com/products/matlab/)

------
xradionut
The more interesting details aren't on this page. The license and the costs
associated with the license.

------
klausnrooster
Searched for REBOL from Wolfram's site (hope that language can 'flatten' it's
own nest of URLs, jeez...). Didn't find REBOL but interesting NLP blog post
from 2010: [http://blog.stephenwolfram.com/2010/11/programming-with-
natu...](http://blog.stephenwolfram.com/2010/11/programming-with-natural-
language-is-actually-going-to-work/)

------
xntrk
Is there a PDF of this doc somewhere? I would like to scroll through it to see
what is in there. but I don't think i'm going to click on 10000 links to see
every language construct...

------
jcutrell
Got really excited about Language Processing, then I saw what's on the page.
[https://reference.wolfram.com/language/guide/LanguageProcess...](https://reference.wolfram.com/language/guide/LanguageProcessing.html)

I do look forward to what's next on this, especially because I have yet to buy
a Pi.

------
vseloved
The better name would be Wolfram standard library

------
memracom
Realistically, rather than work with the fussy syntax of this pseudo
functional language, most people who work in data science would be better of
using Python because of the IPython Notebook
[http://ipython.org/notebook.html](http://ipython.org/notebook.html) which
provides similar mixing of code and graphical results. The matplotlib,
inspired by Mathematica, can produce a wide variety of graphical plots. Newer
libraries like pandas have been bringing all the power of R into the Python
world.

Five years ago, Wolfram may have been worthwhile, but today the wave has
formed and it is converging on Python.

------
Xdes
So how do I use this language? Do I need to buy Mathematica?

~~~
mcguire
Or get a Raspberry Pi:
[http://www.raspberrypi.org/archives/5282](http://www.raspberrypi.org/archives/5282).

(Or get someone else to buy it, etc., etc.)

------
leoc
So, it employs term-rewriting magics of some kind rather simple evaluate-the-
subexpressions, doesn't it?

------
GuerraEarth
The red fire truck _russianed_ in a lot of Wolfram interest.

------
berntb
To me this looks like a Lisp variant with a large set of utility libraries.

Am I missing something? Is the point the quality/volume of the support
libraries?

~~~
Jtsummers
> To me this looks like a Lisp variant with a large set of utility libraries.

I feel like I'm missing something because I read this a lot, but don't see it
when I look at Mathematica. The language seems to be a higher-order,
functional programming language with dynamic (?) typing. That part sounds like
lisp, but syntactically it looks nothing like lisp to me. Is there a portion
of the language that I'm overlooking?

~~~
brandonbloom
[http://reference.wolfram.com/language/ref/FullForm.html](http://reference.wolfram.com/language/ref/FullForm.html)

~~~
Jtsummers
Interesting. And after looking at Mathematica (the language) more this
morning, I can see the influence of Lisp and other languages. I think my
definition of "lisp variant" is stricter than others' definition. I wouldn't
consider Rebol, TCL or Ruby "lisp variants", even though they both derive a
lot of language concepts from the lisp family. So I can't really consider
Mathematica a lisp variant either.

~~~
brandonbloom
Put it in any bucket you like, but don't ignore it. Mathematica is absolutely
worth studying. If you've never used a general purpose term rewriting system
before, you're missing out on some mind-altering stuff.

~~~
Jtsummers
I'm not ignoring it, I used it years ago in grad school, it was fantastic. It
just has no relevance (as a tool) to my current work or sideprojects. My
question was strictly about calling it a lisp variant.

