
Wolfram Research launched the Tweet-a-Program service: interesting Wolfram Language programs that are no longer than 140 characters
- Transfer

In Wolfram Language, small code can do a lot. Using this, we made a service that will allow you to enjoy it, today we open it - Tweet-a-Program .
This service combines Wolfram Language programs with a length of one twitter message and the ability to automatically send them to @WolframTaP . Our Twitter bot will launch your program on the Wolfram Cloud , and then publish the result. Everyone can do it in Wolfram Language, which will be no longer than one tweet. Say, below you see a program with a length of 78 characters, which makes it fill the cube with colored spheres: You can easily make interesting ornaments:
![Hello World from Tweet-a-Program: GeoGraphics [Text [Style ["Hello!", 150]], GeoRange -> "World"] Hello World from Tweet-a-Program: GeoGraphics [Text [Style ["Hello!", 150]], GeoRange -> "World"]](https://habrastorage.org/getpro/habr/post_images/c5e/7bf/fdb/c5e7bffdbc4f3002eed6dafcd79197af.png)
![Graphics3D [Table [{RGBColor [{i, j, k} / 5], Sphere [{i, j, k}, 1/2]}, {i, 5}, {j, 5}, {k, 5 }]] Graphics3D [Table [{RGBColor [{i, j, k} / 5], Sphere [{i, j, k}, 1/2]}, {i, 5}, {j, 5}, {k, 5 }]]](https://habrastorage.org/getpro/habr/post_images/378/222/fff/378222fffd80747e5420fb623a39d7fc.png)
![Graphics [Riffle [NestList [Scale [Rotate [# ,. 1],. 9] &, Rectangle [], 40], {Black, White}]] Graphics [Riffle [NestList [Scale [Rotate [# ,. 1],. 9] &, Rectangle [], 40], {Black, White}]]](https://habrastorage.org/getpro/habr/post_images/25e/36e/9da/25e36e9da25dc541ff679c819b6cba8c.png)
Below you see a program with a length of 44 characters that looks like a small calculated poem: You can make the program even shorter, say this program with a length of 36 characters makes it look like a fractal: By adding a little math you can get complex three-dimensional structures: You do not have to make pictures. Below, let's say you see the first 1000 characters of the number π, the size of which is selected depending on the size of their module (see how the nines run one after another!): Wolfram Language knows not only how to calculate the number π, but also a huge many other algorithms . A huge amount of knowledge about the real world is also built into it . So, directly in the language, you can ask about films
![Graphics3D @ Point @ Tuples @ Table [Range [20], {3}] Graphics3D @ Point @ Tuples @ Table [Range [20], {3}]](https://habrastorage.org/getpro/habr/post_images/18c/1da/57a/18c1da57a5aa18424f7e7e60c802da09.png)
![NestList [Subsuperscript [#, #, #] &, o, 6] NestList [Subsuperscript [#, #, #] &, o, 6]](https://habrastorage.org/getpro/habr/post_images/783/ae5/ed1/783ae5ed1d9ed0f16c819647717e77c7.png)
![ContourPlot3D [Cos [{x, y, z} / Norm [{x, y, z}] ^ 2] == 0, {x, -0.5,0}, {y, 0,0.5}, {z, - 0.5.0}] ContourPlot3D [Cos [{x, y, z} / Norm [{x, y, z}] ^ 2] == 0, {x, -0.5,0}, {y, 0,0.5}, {z, - 0.5.0}]](https://habrastorage.org/getpro/habr/post_images/26a/738/900/26a7389005ce324c96b72d60402a09b6.png)
![ReliefPlot [Arg [Fourier [Table [1 / LCM [i, j], {i, 512}, {j, 512}]]]] ReliefPlot [Arg [Fourier [Table [1 / LCM [i, j], {i, 512}, {j, 512}]]]]](https://habrastorage.org/getpro/habr/post_images/b6d/2da/e1a/b6d2dae1a8525aa1667556c542458946.png)
![Row [Style [#, 5 # + 1] & / @ First [RealDigits [Pi, 10,1000]]] Row [Style [#, 5 # + 1] & / @ First [RealDigits [Pi, 10,1000]]]](https://habrastorage.org/getpro/habr/post_images/3ca/0f0/106/3ca0f0106b9febc80c620cf6014fffb8.png)
, countries , chemicals and much more. Below you can see a 78-character program that creates a collage of European flags, and the size of the flag depends on the country's population: We can make this program even shorter if we use some form of writing in natural language directly inside the program. In the regular interface of Wolfram documents that you know from Mathematica, you can do this using the keyboard shortcut , but in the Tweet-a-Program you can do this simply using the construction of the form = [...]: Wolfram Language knows about geography
![ImageCollage [CountryData ["Europe", "Population"] -> CountryData ["Europe", "Flag"]] ImageCollage [CountryData ["Europe", "Population"] -> CountryData ["Europe", "Flag"]]](https://habrastorage.org/getpro/habr/post_images/80b/965/3ad/80b9653ad3ed99f5c7fafbfa356e493d.png)

![ImageCollage [= [Europe populations] -> = [Europe flags]] ImageCollage [= [Europe populations] -> = [Europe flags]]](https://habrastorage.org/getpro/habr/post_images/dc0/3bf/987/dc03bf98773c16fd03008fc638a811f5.png)
![ImageCollage [= [Europe populations] -> = [Europe flags]] ImageCollage [= [Europe populations] -> = [Europe flags]]](https://habrastorage.org/getpro/habr/post_images/5a4/f06/1ca/5a4f061ca8d0fa8c2f09265f87e67941.png)
. Below is a program that displays circles of different radii (a sequence of degrees 10) in meters, with the center of each disk being the Eiffel Tower. There are many kinds of real-world knowledge built into Wolfram Language that may surprise you. Say, below is a map of a shipwreck in the Atlantic Ocean: Wolfram Language can also work with images. Below you see a program that takes images of the planets of the solar system , and then mixes their R, G and B channels, giving the output quite exotic pictures. Below you see my image, to which the algorithm for searching for borders on the image has been applied several times:
![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}]](https://habrastorage.org/getpro/habr/post_images/09e/1d7/154/09e1d7154e92ec07ea3cba13ad47107b.png)
![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}]](https://habrastorage.org/getpro/habr/post_images/2cf/82d/95f/2cf82d95f956e0ec4bda53c654a86765.png)
![GeoListPlot [GeoEntities [= [Atlantic Ocean], "Shipwreck"]] GeoListPlot [GeoEntities [= [Atlantic Ocean], "Shipwreck"]]](https://habrastorage.org/getpro/habr/post_images/f97/798/011/f97798011138b73da6e85862ff405ccc.png)
![GeoListPlot [GeoEntities [= [Atlantic Ocean], "Shipwreck"]] GeoListPlot [GeoEntities [= [Atlantic Ocean], "Shipwreck"]]](https://habrastorage.org/getpro/habr/post_images/86f/6f4/4b9/86f6f44b966e34f623a7e9eb33dd92ec.png)
![ColorCombine [RandomSample [ColorSeparate [#]]] & / @ EntityValue [= [planets], "Image"] ColorCombine [RandomSample [ColorSeparate [#]]] & / @ EntityValue [= [planets], "Image"]](https://habrastorage.org/getpro/habr/post_images/db2/38a/6be/db238a6bea2cb8349b10ae7396aa1fdd.png)
![ColorCombine [RandomSample [ColorSeparate [#]]] & / @ EntityValue [= [planets], "Image"] ColorCombine [RandomSample [ColorSeparate [#]]] & / @ EntityValue [= [planets], "Image"]](https://habrastorage.org/getpro/habr/post_images/66e/c1a/ce0/66ec1ace036c02728a904e787800bd97.png)
![NestList [EdgeDetect, = [Stephen Wolfram image], 5] NestList [EdgeDetect, = [Stephen Wolfram image], 5]](https://habrastorage.org/getpro/habr/post_images/4d1/065/912/4d10659125cdaf45dc3cc9e5222978da.png)
![NestList [EdgeDetect, = [Stephen Wolfram image], 5] NestList [EdgeDetect, = [Stephen Wolfram image], 5]](https://habrastorage.org/getpro/habr/post_images/014/c29/2bd/014c292bdd07870eed293cf956ec5de7.png)
Or, you can do something more related to “pop culture” (you can also use these images by applying all kinds of processing and analysis algorithms to them). Below you see a table of posters of randomly selected films: Wolfram Language is also very good at working with words and texts . Let's say the program below generates an “infographic” showing the relative frequencies of the first letters in the words of the English and Spanish languages: Here is the program, exactly the same size as a tweet, which calculates the smoothed histogram of the frequency distribution of the words “Alice” and “Queen” in the original text Alice in Wonderland : Graphs and Networks
![Grid [Partition [DeleteMissing [EntityValue [RandomSample [MovieData [], 50], "Image"]], 6]] Grid [Partition [DeleteMissing [EntityValue [RandomSample [MovieData [], 50], "Image"]], 6]]](https://habrastorage.org/getpro/habr/post_images/531/566/c47/531566c4715426c13e85f1f2a6ae0c64.png)
![Row [Style [#, # 2/70] & @ @ @ Tally [ToUpperCase [StringTake [DictionaryLookup [{#, All}], 1]]]] & / @ {"English", "Spanish"} Row [Style [#, # 2/70] & @ @ @ Tally [ToUpperCase [StringTake [DictionaryLookup [{#, All}], 1]]]] & / @ {"English", "Spanish"}](https://habrastorage.org/getpro/habr/post_images/692/e50/7a5/692e507a5d52780d50427862aaf80a54.png)
![SmoothHistogram [Legended [First / @ StringPosition [ExampleData @ {"Text", "AliceInWonderland"}, #], #] & / @ {"Alice", "Queen"}, Filling-> Axis] SmoothHistogram [Legended [First / @ StringPosition [ExampleData @ {"Text", "AliceInWonderland"}, #], #] & / @ {"Alice", "Queen"}, Filling-> Axis]](https://habrastorage.org/getpro/habr/post_images/1b2/ce6/d53/1b2ce6d535fe628a983129ac742f8c9d.png)
also good to use for Tweet-a-Program. Here is a program that creates a sequence of graphs: And here - and again the length of the program does not exceed the limit of characters in the Twitter message - a program that creates a cloud of random polyhedra: What is the shortest "interesting program" in Wolfram Language? In some languages, it may be Quine, a program that outputs its own code. But in Wolfram Language, a quine looks very trivial. Since all expressions are represented in symbolic form, in order to create a quine, just enter any character:
![Table [Graph [Table [i-> Mod [i ^ 2, n], {i, n}]], {n, 105,110}] Table [Graph [Table [i-> Mod [i ^ 2, n], {i, n}]], {n, 105,110}]](https://habrastorage.org/getpro/habr/post_images/f0b/617/7f8/f0b6177f8fd41a141a2ae726ff68b317.png)
![Graphics3D [Table [{RandomColor [], Translate [PolyhedronData [RandomChoice [PolyhedronData []]] [[1]], RandomReal [20.3]]}, {100}]] Graphics3D [Table [{RandomColor [], Translate [PolyhedronData [RandomChoice [PolyhedronData []]] [[1]], RandomReal [20.3]]}, {100}]]](https://habrastorage.org/getpro/habr/post_images/71d/7b2/50a/71d7b250a99c1c6b2c449234dcfaea9f.png)

Using the knowledge built into the Wolfram Language, you can create very short programs that do something interesting. Like this 15-character program that creates an image of a fragment of an embedded database on nodes of node theory : Some short programs are very easy to understand: It's funny to create “cryptic” programs. Say what does this one do? Or this one ? Or, a little more complicated , such as this: I actually spent many years of my life studying short programs and what they do and I created a whole science about the universe of computing , which is described in my book A New Kind of Science
![KnotData [{8,4}] KnotData [{8,4}]](https://habrastorage.org/getpro/habr/post_images/b88/abe/6d2/b88abe6d23bd313181e0221207806d43.png)
![Grid [Array [Times, {12,12}]] Grid [Array [Times, {12,12}]]](https://habrastorage.org/getpro/habr/post_images/854/d8b/f03/854d8bf03cffb99a0fb74b0ee6cd72ad.png)
![NestList [# ^ # &, x, 5] NestList [# ^ # &, x, 5]](https://habrastorage.org/getpro/habr/post_images/c05/8d4/513/c058d4513e0717a6f8930d207dae65e4.png)
![FixedPointList [# /. {S [x _] [y _] [z _] -> x [z] [y [z]], k [x _] [y _] -> x} &, s [s [s]] [ s] [s] [s] [k], 10] // Column FixedPointList [# /. {S [x _] [y _] [z _] -> x [z] [y [z]], k [x _] [y _] -> x} &, s [s [s]] [ s] [s] [s] [k], 10] // Column](https://habrastorage.org/getpro/habr/post_images/ab4/ac9/b4b/ab4ac9b4b282e84e27b1af8b757f8423.png)
![Style [\ [FilledCircle], 5 #] & / @ (If [# 1> 2.2 # 0 [# 1- # 0 [# 1-2]], 1] & / @ Range [50]) Style [\ [FilledCircle], 5 #] & / @ (If [# 1> 2.2 # 0 [# 1- # 0 [# 1-2]], 1] & / @ Range [50])](https://habrastorage.org/getpro/habr/post_images/98e/497/5d2/98e4975d251d39ead5f222add35936f8.png)
. Все это началось более трёх десятилетий назад с компьютерного эксперимента, который я могу сделать с помощью всего лишь одного твита:
![GraphicsGrid [Partition [Table [ArrayPlot [CellularAutomaton [n, {{1}, 0}, {40, All}]], {n, 0.255}], 16]] GraphicsGrid [Partition [Table [ArrayPlot [CellularAutomaton [n, {{1}, 0}, {40, All}]], {n, 0.255}], 16]]](https://habrastorage.org/getpro/habr/post_images/fd8/1d0/028/fd81d0028ed0e2de4e0841624a437583.png)
Мое самое любимое открытие также можно опубликовать в одном твите:
![ArrayPlot [CellularAutomaton [30, {{1}, 0}, 100]] ArrayPlot [CellularAutomaton [30, {{1}, 0}, 100]]](https://habrastorage.org/getpro/habr/post_images/a3f/6be/e16/a3f6bee16c5814f6c6aa5fd0decb7976.png)
Если вы начнете изучать вселенную вычислений, вы сможете с легкостью обнаружить в ней множество потрясающих вещей:
![ArrayPlot [CellularAutomaton [{1635, {3,1}}, {{1}, 0}, 500], ColorFunction -> (Hue [# / 3] &)] ArrayPlot [CellularAutomaton [{1635, {3,1}}, {{1}, 0}, 500], ColorFunction -> (Hue [# / 3] &)]](https://habrastorage.org/getpro/habr/post_images/621/cb3/f6e/621cb3f6e3bff64a8bb9c07286c9612e.png)
Встает основной вопрос — существует ли где-то глубоко во вселенной вычислений программа, которая отображает всю нашу физическую вселенную. И является ли эта программа достаточно короткой, чтобы записать ее в одном твите на языке Wolfram Language?
But regardless of this, we already know that the Wolfram Language allows us to write amazing programs, no more than one tweet in length, about an incredible amount of things. It took more than a quarter century to build a huge “building” of knowledge and automation, which now exists in the Wolfram Language. But it was precisely this richness of language that made it possible to do so much even in the “Twitter world”.
In the past, only ordinary human languages were rich enough to transmit meaningful information via Twitter. But what is striking today is that the Wolfram Language seems to have crossed a sort of threshold of “expressiveness," and this allows it to easily create interesting and complex things, even with the limitations of Twitter. Like ordinary human languages, it can talk about all kinds of things and express all kinds of ideas. But there is also something else in it: unlike ordinary human languages, everything in it has a precisely defined meaning, and what we write is not only readable, but also calculated.
Tweets in ordinary human language (presumably) have some effect on the mind of the person who reads them. But the result may be different depending on mental abilities, and it is usually difficult to know exactly what this effect is. But tweets in Wolfram Language have a well-defined effect that you see when you start the program.
It is interesting to compare Wolfram Language with ordinary human languages. A common language, such as English, has several tens of thousands of fairly common built-in words, excluding proper names, etc. The Wolfram Language language has about 5,000 named built-in objects , excluding Entity-based constructions (database access keys) that can be considered as proper names.
One important thing about the Wolfram Language - and which it shares with ordinary human languages - is that it is not only written by people, but also read by them. It contains a dictionary that you need to remember, as well as several principles that you need to remember - while a person needs only a little time to study them and begin to understand typical programs in the Wolfram Language language.
Sometimes it’s quite easy to give at least a rough translation (or “explanation”) of a Wolfram Language program into ordinary human language. But very often it turns out that a Wolfram Language program expresses something that is rather difficult to talk about - at least briefly - in ordinary human language. And this inevitably means that there are things about which it is easier to think in the Wolfram Language, but difficult in an ordinary language.
As in ordinary languages, Wolfram Language has a kind of art of expressing and writing down thoughts. It has reading and reading comprehension. It has the writing and writing of sentences. You can always say something in it in different ways, but at the same time say absolutely for sure, and there is also a measure of the optimality of your sentences - the speed of their calculation.
As in ordinary human language, there is a concept of elegance. You can think of both meaning and its external realization. And you might also think of something like “code poetry” in that language.
When I first came across Tweet-a-Program, it seemed to me something commonplace. But what I saw and understood was that it is actually a window into the world of a new kind of expression and a new form of interaction between people and computers.
Of course, this service is intended for entertainment. It really gives me great pleasure to create short, concise programs that create something amazing.
And now I look forward to seeing what you can do in this service. What kinds of things will be created? What types of shortcodes will become popular? Who will be inspired by these short programs? What tasks will be proposed and solved? What competitions will be open and what prizes will be awarded? And what great “actors” and “poets” will appear in this world of code?
Now we have programs that fit in just one tweet, let's see what they can do ...
In order to develop and test programs for Tweet-a-Program , you can create a free account in the Wolfram Programming Cloud ( Wolfram Programming Cloud ), or use any other Wolfram-based systemsboth for the desktop and the Cloud. You can learn more about Tweet-a-Program here .