/ #podcast #code #creativity #La horde du contrevent 

Creativity and programming languages

Since the second half of the 20th century, we know that every language in which we can write a Turing Machine is a language with which we can write every single possible algorithm ever possible to write. Another way to say it is that for many years we know that all the programming language are equivalent, no one is able of more than any other, end of the story.

Drop mic

As a consequence, we could live happily in a world where every programmer is using the same language to talk to machines, but it’s entirely not the case. According to Wikipedia, there are more than 700 languages (and with no doubt all programming language ever created is not on this page). And it’s only the programming languages, we can add libraries that sometimes modify so much a programming language that you can’t recognize it.

Timeline of programming languages

Programming languages are actually the hidden place of considerable creativity. I love art, cinema, theater and it’s in this particular field that I’ve been the most surprised by all the new idea we can discover.

If you don’t believe me, this post is for you, I’ll try to answer these three questions :

Why do we still create new languages?

Are they really different?

Why is it a creative activity?

The ultimate programming language

The ultimate programming language has been tried long ago, and it didn’t stop the creation of new ones. Every programmer has his favorite language so this is not to start a war, I’m talking of a ultimate programming language as a perfect idea that the language LISP illustrate perfectly in my opinion. This language was born in 1958 and as so is one of the first programming language ever created (14 years before C and 32 years before Python that you probably know for example). Its syntax is straightforward, parenthesis, functions arguments… and that’s all!

(function arg1 arg2 arg3)

People think LISP is an ultimate language because some of his core concepts come directly from the dreams of Ada Lovelace: There are no differences between the data (inputs of our algorithms) and the language in which we process these inputs (the code we write). To put it in another way, we can use this language to modify its own behavior and adapt it to every problem.

LISP, created in 1958 can not only do everything (you can code a Turing machine), but it is also possible to modify its syntax as you need to adapt to your problem. Why would we need new languages after this one?

For reasons that are very similar to why it is powerful: LISP is hard to read, hard to use, hard to master and not necessarily the most efficient language for every application.

We must not judge a programming language only by what it can do or by its efficiency to do it but also by its ability to communicate an idea, an algorithm, to a computer. And, as it’s sometimes forgotten, to describe these algorithms to others humans!

Believing that we need only one programming language is like believing only one art form is sufficient to communicate any idea. It’s assuming we should stop making movies, tv shows, comics, music because we already have books and it’s good enough.

The best way

Godel, Escher & Bach is a famous book which tries to connect the mathematician Godel, the artist Escher and the musician Bach. In the introduction to the French version, written by the author, Douglas Hofstadter explains that this French version is not an inferior version, neither a copy of the original version that would have lost some concepts during the process. No, he worked with the translators to make the same book, but in French. He presents this version as another projection of his ideas and that probably by reading the two text (if ever you are fluent in the two languages) you would get closer to the impression he wanted to transmit.

A book or any work of art is only the transmission, as good as possible of what was of a mind of an artist. And sometimes some bugs occur: When Sam Ramy presents his horror movie Evil Dead and the public laugh in some scenes where it was supposed to be scared, it’s a bug (that will be used a lot in the following episodes).

Many works of art appear nowadays in several formats, sometimes freely adapted. The Martian first a book is getting stressful and addictive as an audiobook when the main character is telling us, day by day what happened to him. And of course, the movie presents incredible sightseeing.

Some other works of art seem to be stuck to one specific format. In Flowers for Algernon, we read the journal of a retarded person who is having treatment to enhance his IQ. At the beginning of the book the writing is very hard to follow, and as we turn the pages, the novel evolves with the narrator IQ.

Some writers use their medium to the limit. As if limited by their own language, they invent a new one. In La horde du contrevent, Alain Damasio invents a syntax to describe the wind. With commas, parenthesis and other signs, we can see the wind move, hit and kill on the pages of the book.

La horde du contrevent

Artists have in every epoch ask the question a programmer starts with: what is the best way to tell my story?

If programming were only about communicating to a computer, no programmer would invent a new syntax, a new language to describe what he is doing to his peers. A computer doesn’t care about that, it’s a machine after all.

Think different

This far you must understand that there are several languages but, after all, what can make all these languages different? It’s still some cooking recipes, a list of instruction, some operation that we repeat, other done if some conditions are validated, etc.

So, of course, you can write.

if(condition){action1();}

or

action1() if condition

but it’s maybe not a reasonable justification for such a post…

If the only differences between languages were this kind of small syntax changes, it would be pointless. But developers are way more creative.

Let’s take an example: How to color a map with France, Belgium, Switzerland, and Germany with 3 colors (Red, Blue, Green) without having two adjacent regions with the same color?

Writing a cooking recipe to solve this problem would be quite long as we would do what we are doing by hand: We try a color for the first country, use a différent one for the next one, etc. If at one point it’s impossible, we go back, and we change the colors.

Another way to solve this problem is to use a declarative language. For example, with Prolog, we can write the following code :

  • First, we describe the fact that our colors are not the same
different(red,green). different(red,blue).
different(green,red). different(green,blue).
different(blue,red). different(blue,green).
  • Next, we describe which are the neighboring countries
coloring(France,Belgique,Suisse,Allemagne):-
different(France,Belgique),
different(France,Suisse),
different(France,Allemagne),
different(Belgique,Allemagne),
different(Suisse,Allemagne)
  • Finally, we ask for the solution
coloring(France,Belgique,Suisse,Allemagne)

Where is the algorithm? That’s precisely what seems magic with this way of programming: the algorithm is the description of the problem! We call this kind of language declarative, we declare some rules, and after that, we can ask questions. One of the most popular declarative languages is SQL, a language used by most of the databases.

There is no restriction on how should work a programming language. The only limits are the programmers’ imagination. For example in the programming language Haskell, we can define infinite lists! Of course, a computer can’t display all the elements of the list and crash if we ask for it but the programming language is lazy, as far as we don’t ask, he doesn’t try.

Some programming languages are more exercises of style like the Shakespeare Programming Language where we code as if we were writing a Shakespeare play. For example, this program writes “Hello World.”

[Romeo](https://en.wikipedia.org/wiki/Romeo "Romeo"), a young man with a remarkable patience.
[Juliet](https://en.wikipedia.org/wiki/Juliet "Juliet"), a likewise young woman of remarkable grace.
[Ophelia](https://en.wikipedia.org/wiki/Ophelia "Ophelia"), a remarkable woman much in dispute with Hamlet.
[Hamlet](https://en.wikipedia.org/wiki/Prince_Hamlet "Prince Hamlet"), the flatterer of Andersen Insulting A/S.

Act I: Hamlet's insults and flattery.
Scene I: The insulting of Romeo.
[Enter Hamlet and Romeo]
Hamlet:
You lying stupid fatherless big smelly half-witted coward! You are as
stupid as the difference between a handsome rich brave hero and thyself!
Speak your mind!
You are as brave as the sum of your fat little stuffed misused dusty
old rotten codpiece and a beautiful fair warm peaceful sunny summer's
day. You are as healthy as the difference between the sum of the
sweetest reddest rose and my father and yourself! Speak your mind!
You are as cowardly as the sum of yourself and the difference
between a big mighty proud kingdom and a horse. Speak your mind.
Speak your mind!
[Exit Romeo]
Scene II: The praising of Juliet.
[Enter Juliet]
Hamlet:
Thou art as sweet as the sum of the sum of Romeo and his horse and his
black cat! Speak thy mind!
[Exit Juliet]
Scene III: The praising of Ophelia.
[Enter Ophelia]
Hamlet:
Thou art as lovely as the product of a large rural town and my amazing
bottomless embroidered purse. Speak thy mind!
Thou art as loving as the product of the bluest clearest sweetest sky
and the sum of a squirrel and a white horse. Thou art as beautiful as
the difference between Juliet and thyself. Speak thy mind!
[Exeunt Ophelia and Hamlet]

Act II: Behind Hamlet's back.
Scene I: Romeo and Juliet's conversation.
[Enter Romeo and Juliet]
Romeo:
Speak your mind. You are as worried as the sum of yourself and the
difference between my small smooth hamster and my nose. Speak your
mind!
Juliet:
Speak YOUR mind! You are as bad as Hamlet! You are as small as the
difference between the square of the difference between my little pony
and your big hairy hound and the cube of your sorry little
codpiece. Speak your mind!
[Exit Romeo]
Scene II: Juliet and Ophelia's conversation.
[Enter Ophelia]
Juliet:
Thou art as good as the quotient between Romeo and the sum of a small
furry animal and a leech. Speak your mind!
Ophelia:
Thou art as disgusting as the quotient between Romeo and twice the
difference between a mistletoe and an oozing infected blister! Speak
your mind!
[Exeunt]

And, as strange as it is, this language is powerful enough to write a Turing machine, and as a consequence, any algorithm can be written with it. Yes, Microsoft World can be written in Shakespeare Programming Language, and it would be quite impressive.

Human communication

There are a lot of differences in programming languages as the previous one. And if you can find a lot of programming languages that’s partly because of these kinds of design choices. It even seems that some paradigms of programming languages have the same roots as the cultural differences in human communication.

In the book The Culture Map, Erin Meyer presents 7 criteria to analyze cultural differences :

  • ** communication:** is the context very important or not
  • ** feedback:** direct or indirect negative feedback
  • ** leading:** egalitarian or hierarchical
  • ** deciding:** consensual or top down
  • ** trusting:** according to what is done or via our relationships
  • ** disagreeing:** confrontation or avoiding confrontation
  • time management: linear or non-linear

These criteria seem to correspond also to essential programming designs.

For example, some libraries use a high context. In Ruby on Rails, only writing has_many :friends in a file named user.rb is enough for the tool to understand that we have a database named Users and another one Friends and that the database Friends will store a reference to the Users database for each entry. So with only a small line of code, we avoid lines of descriptions. And as human communication, this kind of high context suppose that everyone is sharing the same context or some problems will occur quickly.

How to make feedback is also a severe difference between languages. Variables have what we call a type. For example 1 is an integer and "1" a string. Some programming languages are nice, you can write 1+"1" and the language will convert the string in an integer to do the sum. The other will be more strict and crash because they can’t add a string and an integer.

More interesting even is the time management. As a cooking recipe, we can think as a programming language as a linear time algorithm where we do the operations line by line in order. But some languages start the next line without waiting for the previous one to finish, they are asynchronous.

These are only some examples of the differences between languages. Creating a language follow most of the time a need to communicate something in a particular way. We can find the same with books, some authors create a new world full of imaginary creatures to tell their story.

What is surprising with programming languages is that other people will use these weird creations and make it their primary tool, even if it requires a lot of adaptation. If very few worlds created by authors are used by others, for programming language it’s widespread. Most of the programmers can use several languages and adapt their choice to their needs. It’s as if a writer decided to use Italian to write his romance and switched to English for his thriller.

Communicate with machines

New languages are of course also created to make execution by machines more efficient.

With the internet and the Web, it’s rarely only one computer which is processing the data but way more in parallel. As a consequence, these last years programming languages have been created to make this task easier.

As a conclusion, there are a lot of programming languages, and there will probably be a lot more in the future. Because culture changes, because habits change because needs change, because it’s interesting, because it’s entertaining because it’s one of the ways humans have found to express their creativity.

Notes

This is a translation of Podcast Science 319, a weekly popular science podcast in french.

Références

Author

Baptiste Coulange

CTO at @cornis_SAS / socially acceptable maths nerd of @podcastscience / always improvising