Some time ago, perhaps even as far as a year ago, I was just starting to watch conferences and lectures in my extensively useful youtube account, on topics like λ‑Calculus or Category Theory, when on a conference by Bartosz Milewski on Categories, he threw a brilliant sentence, that speaks something like this: «Humans shouldn’t downgrade themselves to speak like the machine, we should make the machine speak like humans!»
And very little time after that, while Leon was visiting me, I remember mentioning such aphorism. His response is something I still think about it today: «Yeah, that is what Python tries to do!». I think I never gave him a good explanation for why he was missing the point, and more or less a year later, maybe I can try to give him one.
First things first: I made a mistake in my storytelling that day, so no wonder he got the message out of context. Milewski’s sentence needs some context before it can be judged. It wouldn’t surprise even the youngest and most innocent average student: Computers are much better than us at performing algorithms! We all know it, we all admitted it every time we asked our maths teacher if we were allowed to use a calculator in class. It’s quite counterproductive to try to compete with a computer at this when we are able to keep around seven things in our working memory, and a human neural synapse is just around 100m/s fast, while computers have arbitrarily large memories and lightning fast chips. Instead, we humans are good at ideas and reasoning. So the point of making computers think like
Where Python slips is in something essential, simple, and traditionally missed: the distinction between Syntax and Semantics. An over-simplification that Leon and I are familiar with, is when we say that the Cyrillic alphabet is totally not the worst part of the Russian Language: it is very popular to over-emphasise the difficulty that a different alphabet implies, when in reality that carries very little significance in how the language produces meaning: it is still essentially symbolising human sounds by graphemes. That is not a great departure in any relevant sense, from say Latin, for example.
What Python criticised from languages like C was the clunky syntax: those inhuman-like curly braces all over the place, the semicolon to denote the end of a sentence, or the indentation being irrelevant for the compiler and the interpretation of the language. Humans don’t throw in their text so many non-alphabetic glyphs, and indentation matters to us, it gives us a lot of intuition about the structure of the text.
But the semantics didn’t change basically at all: it is still an imperative language with glorifications, like whether it is Object-Oriented or Garbage-Collected and what not. Parallelism is still done by manual vectorisation, concurrency still requires mutexes and threads, objects still block on their requests (or in more technical terminology, message passing is still entirely synchronous). Data is still named and aliased, functions are mutable, variables are mutable memory cells boxed on the heap. Python is still, essentially, like any other glorified imperative language, merely describing algorithms. The description of its semantics is strictly operational, and no other body is encoded in its execution. To understand a Python program, just like a C program or a Java program or any other of a large set of popular languages, you just execute it in your mind. Python is still talking like a computer, or as I called it some time ago, it is still a glorified Von Neumann language.
The distinction is subtle and deep. Syntax is how the language produces sentences. Semantics is how the language produces meaning. And just like with the alphabet in the Russian case, the alphabet is just twenty-to-thirty-something rules to learn, a fixed, predictable and limited set of rules, while the grammar of the language is painfully complicated, with all the declinations and how endings build meaning for example. Whether decisions are taken, made, met or lifted 1, or whether data is anonymous or immutable and messages are synchronous or asynchronous, changes the way the language produces meaning in deeper ways.
So when we say we should make the computer speak like us, we mean, we should make the computer understand our semantics. But then a last question arises: what are “our semantics”? While I prepare myself for answering such an endeavour, let me leave you, at last, with Milewski’s actual talk, he might as well make a much better job than me. Please enjoy: