Sunday, September 21, 2014

First Look at the Future OR How Seeing the Wolfram Language Reminded Me of Watching ECW

"Arms, and the man I sing, who, forc'd by fate, 
And haughty Juno's unrelenting hate,
Expell'd and exil'd, left the Trojan shore.
Long labors, both by sea and land, he bore,
And in the doubtful war, before he won
The Latian realm, and built the destin'd town;
His banish'd gods restor'd to rites divine,
And settled sure succession in his line,
From whence the race of Alban fathers come,
And the long glories of majestic Rome.
-- The Aeneid, Virgil
Translated by John Dryden
Book I, Lines 1-10

"Wow!" that is what I have down as the main take-away in my notes for Strange Loop 2014's session, "Inside the Wolfram Language".  I walked away feeling, as I believe, Hegel felt as he famously saw Napoleon, "I have just seen the world sprit".*

In a time when designers are aiming for yet smaller and smaller frameworks and languages, Stephan Wolfram proudly shows what one can do if they think different.  The Wolfram Language combines language, algorithms, and data into one complete platform (I can assure you I have not nor expect to get anything for these words), giving the user a lot of power in one console.

What would a Hello World look like in such a language?

Yes, that is both code and execution in a tweet!

That is nice and all but how about something more in-depth?

Here is my own "Hello World" Wolfram Language tweet.

I used the build-in text of the Aeneid and computed a histogram on the length of the words used in the english translation.

Histogram[StringLength[ToLowerCase[ExampleData[{"Text","AeneidEnglish"}, "Words"]]]]

Let's break this line down.

First we get the words of the Aeneid in a data structure.

ExampleData[{"Text","AeneidEnglish"}, "Words"]

Next we convert all the words to lower case so we do not have to worry about "The" not matching "the".

ToLowerCase[ExampleData[{"Text","AeneidEnglish"}, "Words"]]

Then we calculate the length of the different words.

StringLength[ToLowerCase[ExampleData[{"Text","AeneidEnglish"}, "Words"]]]

Last, we graph the data as a histogram.

Histogram[StringLength[ToLowerCase[ExampleData[{"Text","AeneidEnglish"}, "Words"]]]]


CloudDeploy[Histogram[StringLength[ToLowerCase[ExampleData[{"Text","AeneidEnglish"}, "Words"]]]]]


Not bad for a one-liner.

Just one more thing, if we tweet to the program to @wolframtap it will tweet back the results.

Very nice.

* Actual text from Hegel's correspondence to Niethammer, "I saw the Emperor -this soul of the world- go out from the city to survey his reign; it is a truly wonderful sensation to see such an individual, who, concentrating on one point while seated on a horse, stretches over the world and dominates it." (as quoted here)