Wolfram Blog
Stephen Wolfram

Introducing Tweet-a-Program

September 18, 2014 — Stephen Wolfram

In the Wolfram Language a little code can go a long way. And to use that fact to let everyone have some fun, today we’re introducing Tweet-a-Program.

Compose a tweet-length Wolfram Language program, and tweet it to @WolframTaP. Our Twitter bot will run your program in the Wolfram Cloud and tweet back the result.

Hello World from Tweet-a-Program: GeoGraphics[Text[Style["Hello!",150]],GeoRange->"World"]

One can do a lot with Wolfram Language programs that fit in a tweet. Like here’s a 78-character program that generates a color cube made of spheres:


It’s easy to make interesting patterns:


Here’s a 44-character program that seems to express itself like an executable poem:


Going even shorter, here’s a little “fractal hack”, in just 36 characters:


Putting in some math makes it easy to get all sorts of elaborate structures and patterns:



You don’t have to make pictures. Here, for instance, are the first 1000 digits of π, sized according to their magnitudes (notice that run of 9s!):


The Wolfram Language not only knows how to compute π, as well as a zillion other algorithms; it also has a huge amount of built-in knowledge about the real world. So right in the language, you can talk about movies or countries or chemicals or whatever. And here’s a 78-character program that makes a collage of the flags of Europe, sized according to country population:


We can make this even shorter if we use some free-form natural language in the program. In a typical Wolfram notebook interface, you do this using CTRL + =, but in Tweet-a-Program, you can do it just using =[...]:

ImageCollage[=[Europe populations]->=[Europe flags]]
ImageCollage[=[Europe populations]->=[Europe flags]]

The Wolfram Language knows a lot about geography. Here’s a program that makes a “powers of 10” sequence of disks, centered on the Eiffel Tower:

Table[GeoGraphics[GeoDisk[=[Eiffel Tower],Quantity[10^(n+1),"Meters"]],GeoProjection->"Bonne"],{n,6}]
Table[GeoGraphics[GeoDisk[=[Eiffel Tower],Quantity[10^(n+1),"Meters"]],GeoProjection->"Bonne"],{n,6}]

There are many, many kinds of real-world knowledge built into the Wolfram Language, including some pretty obscure ones. Here’s a map of all the shipwrecks it knows in the Atlantic:

GeoListPlot[GeoEntities[=[Atlantic Ocean],"Shipwreck"]]
GeoListPlot[GeoEntities[=[Atlantic Ocean],"Shipwreck"]]

The Wolfram Language deals with images too. Here’s a program that gets images of the planets, then randomly scrambles their colors to give them a more exotic look:


Here’s an image of me, repeatedly edge-detected:

NestList[EdgeDetect,=[Stephen Wolfram image],5]
NestList[EdgeDetect,=[Stephen Wolfram image],5]

Or, for something more “pop culture” (and ready for image analysis etc.), here’s an array of random movie posters:


The Wolfram Language does really well with words and text too. Like here’s a program that generates an “infographic” showing the relative frequencies of first letters for words in English and in Spanish:


And here—just fitting in a tweet—is a program that computes a smoothed estimate of the frequencies of “Alice” and “Queen” going through the text of Alice in Wonderland:


Networks are good fodder for Tweet-a-Program too. Like here’s a program that generates a sequence of networks:


And here—just below the tweet length limit—is a program that generates a random cloud of polyhedra:


What’s the shortest “interesting program” in the Wolfram Language?

In some languages, it might be a “quine”—a program that outputs its own code. But in the Wolfram Language, quines are completely trivial. Since everything is symbolic, all it takes to make a quine is a single character:


Using the built-in knowledge in the Wolfram Language, you can make some very short programs with interesting output. Like here’s a 15-character program that generates an image from built-in data about knots:


Some short programs are very easy to understand:


It’s fun to make short “mystery” programs. What’s this one doing?


Or this one?


Or, much more challengingly, this one:


I’ve actually spent many years of my life studying short programs and what they do—and building up a whole science of the computational universe, described in my big book A New Kind of Science. It all started more than three decades ago—with a computer experiment that I can now do with just a single tweet:


My all-time favorite discovery is tweetable too:


If you go out searching in the computational universe, it’s easy to find all sorts of amazing things:


An ultimate question is whether somewhere out there in the computational universe there is a program that represents our whole physical universe. And is that program short enough to be tweetable in the Wolfram Language?

But regardless of this, we already know that the Wolfram Language lets us write amazing tweetable programs about an incredible diversity of things. It’s taken more than a quarter of a century to build the huge tower of knowledge and automation that’s now in the Wolfram Language. But this richness is what makes it possible to express so much in the space of a tweet.

In the past, only ordinary human languages were rich enough to be meaningfully used for tweeting. But what’s exciting now is that it seems like the Wolfram Language has passed a kind of threshold of general expressiveness that lets it, too, be meaningfully tweetable. For like ordinary human languages, it can talk about all sorts of things, and represent all sorts of ideas. But there’s also something else about it: unlike ordinary human languages, everything in it always has a precisely defined meaning—and what you write is not just readable, but also runnable.

Tweets in an ordinary human language are (presumably) intended to have some effect on the mind of whoever reads them. But the effect may be different on different minds, and it’s usually hard to know exactly what it is. But tweets in the Wolfram Language have a well-defined effect—which you see when they’re run.

It’s interesting to compare the Wolfram Language to ordinary human languages. An ordinary language, like English, has a few tens of thousands of reasonably common “built-in” words, excluding proper names etc. The Wolfram Language has about 5000 built-in named objects, excluding constructs like entities specified by proper names.

And one thing that’s important about the Wolfram Language—that it shares with ordinary human languages—is that it’s not only writable by humans, but also readable by them. There’s vocabulary to acquire, and there are a few principles to learn—but it doesn’t take long before, as a human, one can start to understand typical Wolfram Language programs.

Sometimes it’s fairly easy to give at least a rough translation (or “explanation”) of a Wolfram Language program in ordinary human language. But it’s very common for a Wolfram Language program to express something that’s quite difficult to communicate—at least at all succinctly—in ordinary human language. And inevitably this means that there are things that are easy to think about in the Wolfram Language, but difficult to think about in ordinary human language.

Just like with an ordinary language, there are language arts for the Wolfram Language. There’s reading and comprehension. And there’s writing and composition. Always with lots of ways to express something, but now with a precise notion of correctness, as well as all sorts of measures like speed of execution.

And like with ordinary human language, there’s also the matter of elegance. One can look at both meaning and presentation. And one can think of distilling the essence of things to create a kind of “code poetry”.

When I first came up with Tweet-a-Program it seemed mostly like a neat hack. But what I’ve realized is that it’s actually a window into a new kind of expression—and a form of communication that humans and computers can share.

Of course, it’s also intended to be fun. And certainly for me there’s great satisfaction in creating a tiny, elegant gem of a program that produces something amazing.

And now I’m excited to see what everyone will do with it. What kinds of things will be created? What popular “code postcards” will there be? Who will be inspired to code? What puzzles will be posed and solved? What competitions will be defined and won? And what great code artists and code poets will emerge?

Now that we have tweetable programs, let’s go find what’s possible…

To develop and test programs for Tweet-a-Program, you can log in free to the Wolfram Programming Cloud, or use any other Wolfram Language system, on the desktop or in the cloud. Check out some details here.

Posted in: Wolfram Language
Leave a Comment




Posted by mtnn    September 18, 2014 at 6:03 pm
George Woodrow III

Great idea, but there has to be some sort of filter/curation. My twitter feed was overwhelmed by junk. This included obvious syntax errors or re tweeting examples.

Posted by George Woodrow III    September 18, 2014 at 6:19 pm
    The Wolfram Team

    Thank you for your comment! This particular problem is best solved by un-following the account as it could accrue large amounts of tweets every hour from external users submitting code.

    Posted by The Wolfram Team    September 18, 2014 at 6:53 pm
      George Woodrow III

      Thanks. I unfollowed the account, and I noticed that someone on Wolfram community is picking out the ‘gems’.

      Posted by George Woodrow III    September 20, 2014 at 6:38 pm
George Woodrow III

signing in with Twitter appears to be broken.

Posted by George Woodrow III    September 18, 2014 at 6:22 pm
    The Wolfram Team

    Hello, thank you for your comment. We believe the issue you’re experiencing may be with your Twitter account or, if you are referring to tweeting from within Mathematica using ServiceConnect, please contact Technical Support.

    Posted by The Wolfram Team    September 18, 2014 at 6:48 pm

Hi! I’m really sorry, about 20 minutes ago I sent it a kind of self-referential snippet to try to display images from its own twitter page. Harhar. :P I didn’t see thing about “no external url access”. Since then it has stopped responding to any tweets, it seems. I hope I didn’t break it?

Posted by Timeroot    September 18, 2014 at 7:39 pm

    Edit: Seems like it was fixed just as I posted this. Hope I wasn’t the cause!

    Posted by Timeroot    September 18, 2014 at 7:41 pm

Just an idea: if Out[] is incorporated in, then twitter could be an alternative interface to MMA. Have a nice day.

Posted by kiwiqin    September 18, 2014 at 8:35 pm

soooo AWSOME !!!

Posted by unyq    September 19, 2014 at 3:53 am

great! however, using the dot before the username in replies floods everyone’s stream. what about removing the dot from the replies?
thank you.

Posted by xan    September 19, 2014 at 6:47 am

Hello, I’ve send some wrong syntax to the @wolframtap and now I got “Null” tweets… all the time. Can it be stopped somehow?

Posted by fenbf    September 19, 2014 at 7:44 am

Shorter “fractal hack”: Image@Array[BitAnd,{1,1}2^9,0]

Posted by AlephAlpha    September 19, 2014 at 7:56 am
Philipp Blume

I tweeted to @WolframTaP once, and by now have received the response back 5 times — and counting?

Posted by Philipp Blume    September 19, 2014 at 10:01 am
    The Wolfram Team

    Thank you for your comment, a fix has been put in place and this issue should now be resolved. For additional assistance please see our Tweet-a-Program info page.

    Posted by The Wolfram Team    September 19, 2014 at 1:40 pm
martin Gollery

I would like to add a bunch of Bioinformatics named objects- SNVs, kinases, promoters, etc etc, etc!

Posted by martin Gollery    September 19, 2014 at 7:55 pm

WOW i’m really amazed!

Posted by Andreas    September 20, 2014 at 2:32 am
Mohamed Al-Emam

Hello Wolfram Team,

Interesting idea , but what about the security (injection) and limitation (parallel processing)?


Posted by Mohamed Al-Emam    September 20, 2014 at 5:49 pm
    The Wolfram Team

    Thank you for your comment! Tweet-a-Program runs in a secured sandbox mode and has limits on processing time. Please see the the info page for more details.

    Posted by The Wolfram Team    September 23, 2014 at 8:46 am

Stephen Wolfram you’re my hero. Always interesting.

Posted by john    September 21, 2014 at 2:14 am
Udo Krause

> And here’s a 78-character program that makes a collage of the flags of Europe, sized according to
> country population:

The 85% inhabitants of Russia in its European part do not show up …

In[6]:= Intersection[CountryData["Europe"], {CountryData["Russia"]}]
Out[6]= {}

but here it is

In[8]:= Intersection[CountryData["Asia"], {CountryData["Russia"]}]
Out[8]= {Entity["Country", "Russia"]}

Posted by Udo Krause    September 21, 2014 at 9:11 am

Some of the tweets are programs that don’t work as intended, such as by returning a form of the input expression. For example, someone tweeted “Pi to 1000 digits.”

On a related note, I’ve noticed that this app doesn’t interpret natural language the same way Mathematica does if you type the equal sign.

So some curation would seem to be in order. It’s not just a matter of unfollowing, but that it would be good to keep the feed clean. (Especially once spammers discover it.)

Posted by ===Dan    September 22, 2014 at 5:25 pm
Michael Stern

What a fun idea. Is there an alternative mode of submitting for those of us who don’t use Twitter?

Posted by Michael Stern    September 23, 2014 at 9:05 am
greg pearce

cool, absolutely. thanks.
Stephen, on the GeoListPlot(GeoEntities(“Atlantic”, “shipwreck”)), is there a file API where i can supply the equivalent of a file with the geo-location “Shasta” that contains all the (lat, lon) tags?

Posted by greg pearce    September 23, 2014 at 11:32 pm

How does one format the -> (arrow) in a Tweeted program?

Posted by Catooney    October 4, 2014 at 4:31 am
    The Wolfram Team

    Thank you for your question. Because Tweet-a-Program works primarily with ASCII text the answer is exactly as you indicated ->.

    Posted by The Wolfram Team    October 6, 2014 at 12:01 pm
Pierre Pucheu

Interesing Wolfram!

Posted by Pierre Pucheu    November 26, 2014 at 10:53 am
tutor peter

wow, great idea!

Posted by tutor peter    February 16, 2015 at 1:54 pm
Erik Gonzalez

All this goes over my head right now. I want to learn more about this language! Just amazing! Very cool stuff.

Posted by Erik Gonzalez    January 22, 2016 at 5:16 pm

Leave a comment


Or continue as a guest (your comment will be held for moderation):

Translate this page: