Skip to content
DevMeme
176 of 7590
Languages Post #216 · source on Telegram

The optional semicolon dilemma in modern JavaScript

Description

A classic meme format known as 'The Most Interesting Man in the World' is used to comment on programming syntax. The image features a distinguished, bearded man in a dark pinstripe suit sitting at a table with a bottle of Dos Equis beer. The top text, in a bold white font, reads: 'I DON'T ALWAYS USE SEMI-COLONS'. The bottom text continues the phrase: 'BUT WHEN I DO, THERE'S NO REASON FOR IT.' This meme speaks to the experience of developers, especially those who switch between languages. The caption 'When you switched from Python to modern JS' provides key context, as Python does not use semicolons to terminate lines, whereas in modern JavaScript, they are mostly optional due to Automatic Semicolon Insertion (ASI). The humor lies in the relatable habit of adding semicolons out of muscle memory or stylistic uncertainty, even when the language parser doesn't require them

Comments

8
Anonymous ★ Top Pick JavaScript's Automatic Semicolon Insertion is the most passive-aggressive feature in programming. It will fix your code for you, but it will also introduce a subtle bug just to remind you who's in charge
  1. Anonymous ★ Top Pick

    JavaScript's Automatic Semicolon Insertion is the most passive-aggressive feature in programming. It will fix your code for you, but it will also introduce a subtle bug just to remind you who's in charge

  2. Anonymous

    I migrated from tabs-vs-spaces to JS and now defend a single, purposeless semicolon - apparently it’s the load-bearing bike shed that keeps ASI, Prettier, and the code reviewer all from collapsing at once

  3. Anonymous

    I don't always use semicolons in JavaScript, but when I do, it's because I'm still traumatized by that one time ASI didn't work the way I expected and my function returned undefined instead of an object literal

  4. Anonymous

    Semicolons in modern JS are like sign-off meetings in agile: technically optional, ritually inserted, and someone's linter will still block the merge over them

  5. Anonymous

    The semicolon: simultaneously the most pedantic requirement in C-family languages and the most passive-aggressive optional feature in JavaScript. After 20 years, you've mastered the art of knowing exactly when ASI will betray you, yet you still occasionally append one to a Python statement out of pure muscle memory - only to have the interpreter mock your decades of polyglot trauma

  6. Anonymous

    Thought semicolons were optional until ASI turned 'return' newline into a Friday outage

  7. Anonymous

    That 'no reason' semicolon? It's JS ASI's frenemy, silently averting the minified merge horror show

  8. Anonymous

    In C a missing semicolon is a compiler error; in JavaScript it’s a 3am incident blamed on ASI

Use J and K for navigation