The Wolfram Language: Fast Introduction for Programmers
wolfram.com
wolfram.com
I write a lot of Mathematica code for my job. To make life easier I've built in a macro system that makes day-to-day programming a whole lot more pleasant. It will be available in Mathematica 10.4 in the GeneralUtilities package that ships with Mathematica.
One of the built-in macros is a construct that automatically localizes any variables that occur as the L-value of an assignment:
Needs["GeneralUtilities`"]
foo[x_, y_] := Scope[
z = x * y;
PrimeQ[z + 1]
]
This gets rewritten at definition time to be: foo[x_, y_] := Block[{z},
z = x * y;
PrimeQ[z + 1]
]
It's a small thing, but it adds up, especially for large functions, and indeed its silly this isn't a core feature of the language.There are a couple other nice features of Scope, too, like the ability to use a single quote ' anywhere in the body of your function to Echo the value there to the current notebook without actually changing the behavior of the code -- essentially a very lightweight form of 'debugging print'. That also makes a huge difference.
And it has some more powerful variants, like "z '= 2 * 3" will echo a line that explicitly says "z = 6", rather than just "6".
Likewise '' means EchoHold, which prints the expression before being evaluated AND afterwards, so you'll see "z = 2 * 3 = 6" in the above case.
Lastly ''' means Tap, which is a higher-order form of EchoHold which instruments a function to echo its input and output (again without changing behavior). So Fold[Plus''', Range[10]] prints out all the intermediate steps in the fold.
There's a variety of features that add a very lightweight syntax for monadic and exception-based error handling, but that's not quite stable enough to advertise yet.
Same goes for debugging: there's some really powerful stack browsing, history capture and replay features, but again not quite stable enough to advertise for this version.
Like, the third slide of the introduction:
Range[20]
Why not just something like List[1..20] ? Maybe List[1..20] works in Wolfram, but then it's weird that you have this Range function that serves no other purpose than to define a Range.
Same with NestList[f, x, 5]. I don't offhand know the way to create its output in something like Scala or Haskell but I imagine it's pretty concise, but meanwhile, in this case... if it's possible to get the effect without using NestList, then why use it? And if it's not possible to get the effect without using NestList, then how would you ever find out that you can use NestList?
It just seems like the actual programming experience would be a lot more about hunting-and-pecking through documentation and google searches, rather than reasoning your way to solution.
I'd love to hear from someone skilled with Wolfram to offer some clarity. Are you just basically thumbing through the documentation all the time to find that one perfect function call?
That said, WL is in fact based on pretty simple primitives. If you are familiar with functional programming, things like NestList are familiar and you'll start learning by finding the analogues of your favorite FP constructs.
WL also has a lot of functions that you might call "optional": those that could be restated as simple combinations of other functions. The rationale there is pretty simple: if there is a well-defined, commonly used chunk of computation, it should be given a name (and design). The fact that a fair amount of work is put into both the name and design of these things gives a higher sense of coherence (and predictability) than you might expect from their number.
Amazingly, I get the impression they say it as a point of pride, rather than as an embarrassing design decision. Don't get me wrong, having a rich, large standard library is great, but unless you use some kind of hierarchical namespaces, it's impossible to deal with.
Typical Mathematica notebooks (I won't say "programs") use a fair bit less than one hundred of the common functions, plus a handful of domain-specific functions from that the greater set of five thousand. At any time, you can enter ?FunctionName to access documentation far more comprehensive than most languages offer.
The UpperCaseForStandardLibrary and lowerCaseForYourCode convention actually makes a lot of sense in the context of Mathematica's primary use cases vs traditional software engineering projects. When I'm just trying to solve some problem in Mathematica, using my computer as a bicycle for the mind, I appreciate not having to putz with import statements or avoid name collisions.
Yes, bashing PHP is fun, and yes, I do it all the time. PHP may be a joke, but there are a bunch of PHP websites because PHP is a very, very fast way to program websites, even widely used ones.
If you could program a simple website in Idris in 30 minutes starting from no prior knowledge, then a large amount of websites would be programmed in Idris (and the world would be a much nicer place). Since that's not the case, should we consider Idris a bad language with major downsides? Of course not, that's pointless, since it wasn't a language meant for building websites. PHP, however, is. Saying it has major downsides outside of its niche is somewhat irrelevant.
Sure, and none of that has anything to do with its horrible design decisions and inconsistent naming. This ability to whip up web sites quickly is not something that PHP achieves as the cost bad design, it achieves it despite unnecessarily bad design.
I wasn't aware that anyone thought English was an effective language for communicating. It's horrible. Even native English speakers have problems communicating all the time.
There is excellent research on text/email communication.
Citation needed.
[Edit: On reflection, this statement is probably true, if you define "miscommunication" to be "the message sent is not exactly the same as the message received". But I think that is an unreasonable definition.
I think it is more reasonable to define "miscommunication" as "the message sent is not substantially the same as the message received". If you claim that, I'd like to see your citations.]
Here is a similar abstract: http://pro.sagepub.com/content/56/1/1491.abstract
Note that emotion is also conflated with aspects like priority and whether the response is a criticism or positive acknowledgement which will affect future interactions or even immediate attempts to "repair" non-existent faults.
I personally find it slightly easier to communicate with non-native speakers over email as any bilingual must have more experience handling ambiguous communication.
In working with native speakers in open floor plans, I have seen hilarious results that I would have found all the more hilarious if I were further away from the projectiles and had fully independent finances.
(But I will concede that English is a good language for talking abstractly about subjects that are clearly neutral where it matters little if nuances are misunderstood.)
I don't think unreasonable in the context of this discussion.
When we use English, having a bit of miscommunication is likely harmless, and probably goes unnoticed most of the time. When we write a computer program, we really want the compiler to understand exactly what we mean.
Also, given that we can infer with decent accuracy what people are saying even in noisy environments, I would say it's really not too bad.
You could do better of course, but in a good spoke natural language you want a good mix of density (for efficient communication) and redundancy (for dealing with environmental variables). Optimizing for one comes at the expense of the other, and English strikes a pretty decent balance. [citation needed]
1: Pellegrino, et al. University of Lyons, 2011 <http://www.ddl.ish-lyon.cnrs.fr/fulltext/pellegrino/Pellegri... 2: There has been some valid criticism made to [1].
The existence of politicians (and politics) proves that it's easy to misunderstand.
Either all of your geography related function start with "Geo" followed by a capital. In that case you're basically using a namespace while reaping none of the benefits. You can't use the namespace to avoid repeating yourself in some local context, you can't rename it, you can programmatically inspect its content, etc.
Either they do not, in that case you have an inconsistent mess.
As a user, why should I care?
It's easier to recall a function name than recall the namespace and the function name, isn't it? With modern IDEs this is a none issue anyway. Though from my experience with Mathematica 5-7, the language feels a bit weird. Nevertheless it's quite an achivement that WolframAlpha (the AI search engine) runs on Mathematica code.
It can easily express things like associative and commutative operators (esp. useful if you have a pattern that matches on a use of that operator), and alternate evaluation orders (outside-in, mixed, lazy, held, &c). These are hard to trivially implement w/o very different kind of interpreter.
In this sense, most Lisp implementations pick a static evaluation strategy and leave implementing alternatives to a metainterpreter, which isn't exactly what's happening in Mathematica.
> The Wolfram Language is first and foremost an evolution of the symbolic language developed for Mathematica over the course of more than 25 years. But it's considerably more than that—adding the knowledge, knowledge representation and natural language abilities of Wolfram|Alpha, as well as a new symbolic deployment mechanism created with the Wolfram Cloud.
This is followed by a "Buzzword Compliance" section, which lives up to its name, but describes some of the features of the language
https://develop.open.wolframcloud.com/app/
The Wolfram Language also ships with Raspberrian for the RaspberryPi.
> How is it licensed?
> The Wolfram Language has multiple licensing models depending on usage scenario. It is available free for certain casual use in the cloud, in CDF Player, and on systems such as Raspberry Pi. It is available through site licenses at educational institutions. It is also available in a variety of subscription and paid-up product offerings. The Wolfram Language is also licensed for OEM use, embedded in hardware or software systems.
The "casual use in the cloud" may be referring to this: http://programming.wolframcloud.com/ (requires sign-up, haven't tried it), and I'm not sure how you'd go about grabbing the Raspberry Pi edition.
Easiest way is probably to start by buying a RPi.