avatarNicholas Obert

Summarize

If Programming Languages Were Spoken Languages

A lame comparison between programming and normal languages.

Photo by Vladislav Klapin on Unsplash

Many programming languages have similarities with regular spoken languages. Some of them share a like structure, syntax or grammar; others have instead a comparable history or community.

This article is meant just for fun, so don’t take anything personally.

Python and English

These two languages share a nearly identical syntax. They are both very flexible languages, as they don’t require any specification regarding adjective gender or variable data types and the word order sometimes doesn’t matter.

There are even cases in which phrases are literally the same:

if my_age is 10: print("You are 10!")

Also, both like to join words using dashes, be it the classical high dash - or the underscore _.

Moreover, both Python and English are cross-platform languages, as they can be used in any country and nearly everybody can speak them. Due to their large community, there are many different dialects and accents. It’s hard to write standardized and maintainable code when everybody writes the way he wants.

Despite their wide popularity, they’re not normally used for large and complex systems such as philosophical treatises, for which more precise languages such as German or Latin are preferred.

C++ and Latin

They are both incredibly capable languages. You express any concept in great detail and you have fine control over your sentences’ meaning by just tweaking a few letters according to the case.

unsigned int a = pointer;
unsigned int a = *pointer;

They have a set of words so wide you won’t be able to learn a considerable portion in a lifetime. Also, you might need a dictionary (cppreference.com) to translate some expressions. Despite that, there are a few people who can speak it naturally without much thought.

It often gets taught in schools and students hate it. Moreover, the majority of them won’t ever use it in their career, unless they have to work with complex texts such as philosophy or medical treatises.

Despite the fact that most people skip learning it, its syntax and concepts are the base of many modern languages and the ones who study it are able to understand words they have never met simply because of their etymology.

Java and German

Both Java and German are old and particularly structured languages. Its syntax is incredibly verbose and you cannot join together multiple sentences without repeating yourself.

ArrayList<String> list = new ArrayList<String>();

Words are joined together to form complex lexemes with a more specific meaning. For example the word “science”, the subject you study at school, is “Naturwissenschaft” (Natur+wissen+schaft). Java has an analogous naming convention:

public ArrayList<String> getFirstNamesList() {/* ... */}

Another similarity is the fact that even simple concepts are usually expressed with long classes due to the language’s strict grammar. For the same reason, the verb must occupy the second place in a main sentence and the final position in a relative clause, much like Java programmers will yell at you if you write static public void main instead of public static void main.

C# and French

Although it’s inspired from Java/German, this language also derives from C++/Latin.

Germany is historically in conflict with France for various reasons. The same can be said for Java and C#, whose developers claim their language to be better than its counterpart.

internal static HttpRequest CreateConnectRequest (Uri uri)
{
  var host = uri.DnsSafeHost;
  var port = uri.Port;
  var authority = String.Format ("{0}:{1}", host, port);
  var req = new HttpRequest ("CONNECT", authority);
  req.Headers["Host"] = port == 80 ? host : authority;
  return req;
}

Both French/C# and German/Java share many similarities, as they developed in the same field, but the former is by design simpler and less strict. Despite that, Java has always been much more popular than C#, just like Germany is historically and also actually more powerful and economically superior than France.

APL and Arabic

The majority of people cannot understand a word of this language. Both APL and Arabic are based on an unconventional character set which differs significantly from the recommended ASCII.

∇ inst MoveRequestData REQ;data;m;i;lcp;props;args;mask
  :Access public shared
  inst._PageData←⎕NS''
  :If 01↑⍴data←{⍵[⍋↑⍵[;1];]}REQ.ArgumentsREQ.Data
    :If 0∊m←1,2≢/data[;1]
      data←(m/data[;1]),[1.5]m⊂data[;2]
    :EndIf
    i←{⍵/⍳⍴⍵}1=⊃∘⍴¨data[;2]
    data[i;2]←⊃¨data[i;2]
    :If 0≠⍴lcp←props←('_'1⊃¨props)/props←(inst.⎕NL-2)
    :AndIf 01↑⍴args←(data[;1]∊lcp)⌿data
      args←(2⌈⍴args)⍴args
      i←lcp⍳args[;1]
      ⍎'inst.(',(⍕props[i]),')←args[;2]'
    :EndIf
    :If ∨/mask←'_'1⊃¨data[;1]
      args←mask⌿data
      :Trap 0
        args[;1]←inst._PageData PrepareJSONTargets args[;1]
        ⍎'inst._PageData.(',(⍕args[;1]),')←(⊃⍣(1=⍬⍴⍴args))args[;2]'
      :EndTrap
    :EndIf
  :EndIf

Only insiders who work with it can read and write it. Moreover, it’s adopted only in one part of the world, as its actual use cases are fairly limited. It’s normally used in mathematical computing, to which Arabs were pretty inclined.

JavaScript and Spanish

This language can be initially simple to learn, but it’s actually hard to master. Only a few can actually speak it in a proper standardized way and write maintainable code.

As Spanish is spoken all around the globe, JavaScript has colonized nearly every field, from web and desktop applications to server-side programs. Because of its large community, there are many different dialects and browsers specifications. Plus, everyone has his own coding style, since formatting and approach conventions aren’t really strict.

function acceptParams(str, index) {
  var parts = str.split(/ *; */);
  var ret = { value: parts[0], quality: 1, params: {}, originalIndex: index };
  for (var i = 1; i < parts.length; ++i) {
    var pms = parts[i].split(/ *= */);
    if ('q' === pms[0]) {
      ret.quality = parseFloat(pms[1]);
    } else {
      ret.params[pms[0]] = pms[1];
    }
  }
  return ret;
}

Go and Esperanto

Both Go and Esperanto are very young languages. They were created specifically with efficiency in mind. They’re designed to be simple to write and understand, without an unusual character set and syntax bits from already-existing popular languages.

func (u User) Allowed(url string, noModification bool) bool {
  var rule *Rule i := len(u.Rules) - 1 
  for i >= 0 {
    rule = u.Rules[i]
    isAllowed := rule.Allow && (noModification || rule.Modify)
    if rule.Regex {
      if rule.Regexp.MatchString(url) {
        return isAllowed
      }
    } else if strings.HasPrefix(url, rule.Path) {
      return isAllowed
    }
    i--
  }
  return noModification || u.Modify
}

Go/Esperanto has an incredible potential to become a mainstream language because of its stability and well-thought structure. Despite that, it has never really taken off.

Assembly and that Indo-European language

They seem to be the root of every language. Every history book mentions that ancient populations spoke that Indo-European language, but nobody actually knows it. The same can be said for Assembly, on which is based all modern programming and everyone knows it, but only a few elites can understand it.

shl ebx, 16
shl ecx, 8
mov bx, cx
shl edx, 2
mov bl, dl
and ebx, 0x00ffffff
or ebx, 0x80000000
mov eax, ebx
mov dx, PCI_CONFIG_ADDRESS
out dx, eax
pop rax
mov dx, PCI_CONFIG_DATA
out dx, eax

Hardware programming and rock inscription

They are the first form of writing that appeared. Both hardware programming and rock inscription store information permanently in a physical material, be it a specific transistor configuration soldered together or symbols carved in the rock.

Photo by Valentin Petkov on Unsplash

Nowadays these pieces of history are shown in museums for people to admire. Nonetheless, there are still artists who carve in rocks or build 8-bit computers from scratch just out of passion.

I hope you enjoyed this article. I’d like to know what you think about these matches and do you have any other good ones?

Thanks for reading!

More content at plainenglish.io. Sign up for our free weekly newsletter here.

Programming
Humor
Coding
JavaScript
Software Development
Recommended from ReadMedium