The End of the Semicolon Era

DeadEnd by Austin Mulhern

Throughout most of my early professional career, I programmed in languages where you terminate or separate statements with a semicolon; it was like an ideograph distinguishing coders from laypeople. I had a motor reflex to type a semicolon (;) without having to think about it. So when I got involved in the early discussions about the new language that JetBrains was working on back in 2010, the language that would be later called Kotlin, I was not thrilled about the proposal to drop the mandatory semicolons. Who minds the semicolons I thought. I had quite a strong opinion about the need to solve the billion-dollar problem with nulls¹ to make our software safer, but the visuals I cared less about. How narrowminded I was!

As it turns out, the disappearance of the semicolon has become the distinguishing characteristic of the rising modern languages of the late 2000s and 2010s to such an extent that it almost becomes synonymous with the very feeling of programming in the “modern language”. Scala (2004), Go (2009), Kotlin (2011), and Swift (2014) are all statically typed, all follow C/C++/Java syntactic tradition with curly braces, all were introduced and grew big in the last 20 years and all had totally ditched the mandatory semicolon despite the tradition. Is it a coincidence? I don’t think so. I see a trend here.

The ground zero

Syntactically Python is a thing in itself. It is a rare breed of fully indentation-sensitive language (aka off-side rule³) that is not some kind of an academic or a toy language. The clean and concise looks of Python code are quite appealing. Switching from something as lean as Python (unless you try object-oriented Python, that is) to something as verbose as Java (1995) or C# (2000) is tough, so no surprise that modern languages are racing to find some middle ground here.

With type-inference now a defacto-standard language feature, it is becoming feasible to avoid visual noise and repetitiveness while maintaining type-safety and scalability. The motto becomes:

If both compiler and human can easily guess it then you should not explicitly spell it out in the code.

Don’t Repeat Yourself (DRY) desire is getting stronger, cleanness is treasured. Sans-serif fonts had occupied our code editors for quite some time, with new coding fonts raising clarity bar even higher; programming languages are becoming sans-type and sans-semicolons.

A false-start

const name = "World"
["Hello", name].forEach(word => console.log(word))

actually gets interpreted as one statement by the rules of JS, forcing the programmer to use the semicolon just to make sure the compiler understands what the author meant by their code, even as it is totally unambiguous to a human reader in the first place. It is so bad in JS that modern JS coding styles recommend always using semicolons to save mental energy thinking about whether you need one or not. TypeScript (2012), being backward-compatible with JavaScript, suffers from it as well.

The solution

The rigor of the modern programming style makes it possible to design such rules even for the C-family of indentation-insensitive languages. We, the developers, are taught and are used to split statements into multiple lines after opening braces and operators. Take a look at a multi-line function call statement:
).doSomethingWithIt() // one multi-line statement

When formatted in a good style, it is clearly distinct from two separate statements, both for a human and for a well-engineered compiler, even if you remove all the indentation: // the first statement
(parameter).doSomethingWithIt() // the second statement

Once it crosses the threshold from “I have to think whether semicolon is needed here” to “I never need a semicolon”, the bliss of not having to write and never having to see semicolons in the code becomes truly liberating.

As with all quality-of-life improvements they only become apparent when you have to do without them for a while. Have you ever tried to read code that is typeset in Times New Roman? You may not even realize it at first, but you get this distinct feeling that something is not right — there’s too much visual noise from all that serif. Nowadays I get the same feeling when I see semicolons in the modern code, especially if it is written in some seemingly modern language. Every time I cannot stop myself but open Wikipedia to double-check in what year the language I’m reading was introduced in.

We are living in the end of the semicolon era. The recipe is out there. It is only a matter of time for it to become truly ubiquitous.

Further reading and footnotes

  1. ^ PYPL PopularitY of Programming Language
  2. ^ Off-side rule
  3. ^ Types are moving to the right
  4. ^ JetBrains Mono Font

Project Lead for the Kotlin Programming Language @JetBrains

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store