Wolfram Language
reference.wolfram.com
reference.wolfram.com
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.
What helped me straighten it out was to evaluate the examples here with Trace: http://reference.wolfram.com/mathematica/tutorial/BlocksComp...
In[1]:= m=i^2
Out[1]= i^2
In[2]:= Block[{i=a},i+m]
Out[2]= a+a^2
In[3]:= Module[{i=a},i+m]
Out[3]= a+i^2
In[4]:= Block[{i=a},i + m] // Trace
Out[4]= {Block[{i=a},i+m],{i=a,a},{{i,a},{m,i^2,{i,a},a^2},a+a^2},a+a^2}
In[5]:= Module[{i=a},i+m]//Trace
Out[5]= {Module[{i=a},i+m],{i$5592=a,a},{{i$5592,a},{m,i^2},a+i^2},a+i^2}
It's a bit dense to read through but with Block, "i" has been assigned the value "a", but still remains in the form "i" throughout the evaluation, and once "m" is replaced with "i^2", the "i" is seen and replaced with "a", acting as normal dynamic scoping.In Module, however, "i" is replaced by a temporary variable with the form "i$5592", which does not have a definition anywhere in Mathematica, so when "m" is evaluated, "i" is left alone, which is how lexical scoping acts.
I dislike forgetting parts of languages in the ones I use. C# is full of things whose behavior I have to look up, as is javascript, python, and especially while I'm learning them: clojure and cljs.
But what's nice about this language is that these two concepts, Module and Block, while having different meaning, have the same form.
> Long viewed as an important theoretical idea, functional programming finally became truly convenient and practical
> with the introduction of the Wolfram Language. Treating expressions like as both symbolic data and the application
> of a function provides a uniquely powerful way to integrate structure and function—and an efficient, elegant
> representation of many common computations.
I see nothing on the reference page that could be said to make Wolfram's FP constructs more convenient or practical. They make it sound like FP was a long lost dream but then Wolfram came along and actually made it happen. They're seemingly using the exact same constructs as everyone else.
What you do actually get from the reference page, though, is that they went the Haskell route and decided the FP stuff shouldn't be readable by anyone who hasn't used the language before. This is all fine and dandy, really; it's a model as good as any other, since it at least gives writability where it loses readability... They aren't doing anything new, from the looks of it, though. They seem to be doing precisely the opposite... In exactly the same way.
[0] - https://reference.wolfram.com/language/guide/FunctionalProgr...
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.
Unless it's the same kind of curve Go is judged against (aka the curve of 30 years ago), that's a very tall order. Are you working on something better than a time-traveling debugger?
> imagine DTrace at a program level
so... DTrace?
I'd kill for hashmaps, some sort of records and strong typing in Mathematica.
https://reference.wolfram.com/language/guide/Associations.ht...
So now there's just strong types and something like records left for me for general purpose development.
obj["a"] = 1;
obj["b"] = 2;
Print[obj["a"]]
or obj = { "a" -> 1, "b" -> 2 };
Print["a" /. obj]
?As for the REPL and general editing, if I were you, I'd quickly go towards LightTable integration — it should be doable, and the effects could be spectacular.
Still, would be interesting to try. I have great enthusiasm for what Chris Granger is doing.
"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.
Kinda funny considering how the Mathematica language is built on top of the M-expressions that lisp never bothered to implement.
Or Wolfram-W
There was also a recent article on here about how programming is a dead-end, non-prestigious job in research circles. Sounds like a continuation of that sentiment.
But even if you did believe the mathematicians claim, by the same logic you would philosophy above them.
Anyway, in regard to the idea of science "stack", I kind of enjoyed Alan Lightman's Reunion where he poses a nineteenth century astronomer's obsession with and histrionics in response to rejection by a cute young woman in his observatory as a kind of "proof" that biology studied more powerful forces. The event simultaneously lead to the astronomer abandoning his career and inspired hers in biology.[1] Though obviously meant as joke, the author himself transitioned from a successful career as a physicist to writing and teaching literature.
[1] http://books.google.com/books?id=4nQhY2fbX2IC&lpg=PP1&pg=PA1...
I always thought that the old tired line of "X is the core science!" was a trap that only mathematicians, physicists, and ignorant grad students fell into. I wasn't aware that any respected (and respectful) scientists actually took it seriously.
Again, this is not a value judgement. A similar thing exists with computers. People who write web applications depend on user-application infrastructure, who depend on systems applications, which depend on operating systems, which depends on computer architecture, which depends on materials engineering and so on. As a systems programmer, I regularly reason about operating systems and computer architecture. But I never reason about the properties of the materials that make the hardware. The computer architects, though, may have to reason about the materials, as it can provide constraints to their designs.
that said, i think it is lisp-like as a design choice. the Mathematica language itself is more raw than even lisp -- you can take the language in different design directions. Wolfram chose to include lisp aspects
My own contribution:
Idly looking about I come upon this page, which is not particularly notable: 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 – 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.
newtype Farm a b = Farm (b, [a]) deriving (Eq,Show)
instance Monad (Farm b) where
return x = Farm (x, [])
Farm (b, as) >>= f =
let Farm (b', as') = f b in Farm(b', as ++ as')
reap :: Farm a b -> (b, [a])
reap (Farm x) = x
sow :: a -> Farm a ()
sow a = Farm ((), [a])
-- prints ("e", ["a","c","d"])
main = print (reap (do sow "a"
return "b"
sow "c"
sow "d"
return "e"))
(Reimplemented in a simple way here to show the underlying machinery; usually, instead of lists, a writer is parameterized by an arbitrary monoid.)In my webpage here: 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.
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.
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.
How did you set that up?
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 dismayLicensing doesn't seem to have changed: http://reference.wolfram.com/language/guide/SystemAndLicense...
Maybe they want to prevent alternative implementations.
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...
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 wayanother 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
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. 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;
};But ironically he is a much better entrepreneur than he is a scientist.
If only he was looking for praise in the former rather than the latter he would get all the recognition he seems to crave.
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.
> 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...
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.
And is the employer in question the Santa Fe Institute? I am not sure whether to be incredulous about or cynically believing that they would go along with that.
"The real problem with this result, however, is that it is not Wolfram's. He didn't invent cyclic tag systems, and he didn't come up with the incredibly intricate construction needed to implement them in Rule 110. This was done rather by one Matthew Cook, while working in Wolfram's employ under a contract with some truly remarkable provisions about intellectual property. In short, Wolfram got to control not only when and how the result was made public, but to claim it for himself. In fact, his position was that the existence of the result was a trade secret. Cook, after a messy falling-out with Wolfram, made the result, and the proof, public at a 1998 conference on CAs. (I attended, and was lucky enough to read the paper where Cook goes through the construction, supplying the details missing from A New Kind of Science.) Wolfram, for his part, responded by suing or threatening to sue Cook (now a penniless graduate student in neuroscience), the conference organizers, the publishers of the proceedings, etc. (The threat of legal action from Wolfram that I mentioned at the beginning of this review arose because we cited Cook as the person responsible for this result.)"
I suspect much of his/their success comes through his/their Jobsian eye for detail and ability in presentation and while this is at its best when applied to meritorious work, it's certainly a skill/asset in its own right too.
In my field, there are many people smarter than I am. Many of my significant contributions to others come from knowledge and experience.
Try to take yourself back to 1988. Macs are newish. Desktop publishing is new. There's this neat new program called Mathematica. You can type in equations, solve them, and even graph them in 3D. You can laser-print the notebooks and they look better than textbooks.
Wolfram may be an egomaniacal self-promoter, but it's not all empty hype.
It's hard to know how much he has created now, because he just keeps being deceptive about it.
I've used MMA since 2.0 on NeXT and love it to bits. But I've met Stephen and he lives up to his reputation.
Btw, which side of his reputation does he live up to? To being a visionary genius or to being a raving crank?
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.
MATLAB can also be used in this fashion: http://www.mathworks.com/products/matlab/
However, I'm noticing a trend towards using mainstream programming languages and whatever free libraries are available, to do the same kind of work. I used Mathematica 15+ years ago, and for doing the same kind of work today, I now use Python and am quite happy with it.
I do look forward to what's next on this, especially because I have yet to buy a Pi.
Five years ago, Wolfram may have been worthwhile, but today the wave has formed and it is converging on Python.
(Or get someone else to buy it, etc., etc.)
Am I missing something? Is the point the quality/volume of the support libraries?
Now I know that none of those things were invented by Wolfram (the company or the man), but they were put into productive use, in a very slick and beautiful application with a slew of symbolic and numerical math libraries which were world class.
I guess to a large extent, you're not missing something, but the libraries are comprehensive, well designed, well documented, very consistent and reasonably intuitive.
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?
It does naturally suit functional thinking, so that becomes the default 'best' way of engaging with it.
[1] http://en.wikipedia.org/wiki/Rewriting#Term_rewriting_system...
In[1]:= FullForm[a + b]
Out[1]= Plus[a, b]
In[2]:= a + b /. Plus -> Times
Out[2]= a b