Skip to content
DevMeme
1157 of 7590
Languages Post #1294 · source on Telegram

JavaScript's Ambiguous Relationship with Semicolons

Description

This is a 'Well yes, but actually no' meme format featuring the Pirate Captain character from an Aardman animation. The top section presents a dialogue about programming syntax: 'Me: Do I need a semicolon? C++: Yes. Python: No.' followed by 'Javascript:'. The bottom image delivers the punchline, with the Pirate Captain saying 'Well yes, but actually no.' This meme humorously critiques JavaScript's optional semicolon feature, a mechanism known as Automatic Semicolon Insertion (ASI). While semicolons are not strictly required as they are in languages like C++, the ASI process can sometimes lead to unexpected behavior and subtle bugs, making their use a contentious topic and a best practice in many style guides. The meme perfectly captures this nuance, contrasting it with the clear, unambiguous rules of C++ and Python

Comments

7
Anonymous ★ Top Pick Automatic Semicolon Insertion is the language feature equivalent of a non-committal partner. It's there for you most of the time, but will occasionally leave you for the line below, returning 'undefined' and breaking your heart in production
  1. Anonymous ★ Top Pick

    Automatic Semicolon Insertion is the language feature equivalent of a non-committal partner. It's there for you most of the time, but will occasionally leave you for the line below, returning 'undefined' and breaking your heart in production

  2. Anonymous

    JavaScript’s ASI is that ghost intern who silently inserts semicolons at 2 AM and then says “well yes, but actually no” when your `return\n{ ok: true }` sends half the pods into CrashLoopBackOff

  3. Anonymous

    JavaScript's ASI rules are like that senior architect who says "we follow best practices" but then you find return statements on their own line wondering why undefined keeps showing up in production

  4. Anonymous

    JavaScript's ASI is the programming equivalent of autocorrect: it thinks it knows what you meant, confidently makes assumptions, and occasionally produces hilariously broken results when you forget that return statement on its own line. Senior engineers know the real answer isn't 'yes' or 'no' - it's 'configure your linter and never think about it again.'

  5. Anonymous

    JavaScript’s ASI is eventual consistency for parsers - fine until a return meets a newline and your hotfix 500s in prod

  6. Anonymous

    JavaScript semicolons: optional per ASI, mandatory per reality - add a newline after return, an IIFE, and Terser, and suddenly optional pages ops at 3am

  7. Anonymous

    JS ASI: optional semicolons today, inexplicable parser bugs rewriting your return statements tomorrow

Use J and K for navigation