Skip to content
DevMeme
1921 of 7435
JavaScript's Lax Attitude Towards Semicolons
Languages Post #2132, on Oct 8, 2020 in TG

JavaScript's Lax Attitude Towards Semicolons

Description

A two-panel meme contrasting how different programming languages handle semicolons. The top text reads, "When you feel like using semicolons only occasionally". The left panel, labeled "Literally any programming language", features a still of Willem Dafoe as Norman Osborn from the movie Spider-Man, looking distressed and saying, "YOU CAN'T DO THIS TO ME". This represents programming languages with strict syntax rules where semicolons are mandatory. The right panel, labeled "Javascript", shows Ken Jeong as Señor Chang from the TV show Community, wearing a sombrero, leaning back relaxedly in a chair with his feet up, and saying, "I'll allow it.". This humorously depicts JavaScript's feature of Automatic Semicolon Insertion (ASI), which makes the use of semicolons optional in many contexts. For senior developers, the joke hits on the long-standing debate about JS's quirks, where this flexibility can be both a convenience and a source of subtle, hard-to-diagnose bugs if not fully understood

Comments

22
Anonymous ★ Top Pick JavaScript's ASI is like a pull request approval from a junior dev at 5 PM on a Friday. It seems helpful at the time, but you just know you'll be debugging a cryptic 'undefined is not a function' error over the weekend
  1. Anonymous ★ Top Pick

    JavaScript's ASI is like a pull request approval from a junior dev at 5 PM on a Friday. It seems helpful at the time, but you just know you'll be debugging a cryptic 'undefined is not a function' error over the weekend

  2. Anonymous

    JavaScript’s fine with you skipping semicolons - until ASI turns ‘return\n{ ok: true }’ into ‘return;’, and suddenly the post-mortem is about your “relaxed coding culture.”

  3. Anonymous

    After 15 years of arguing about semicolons in JavaScript, we've finally reached consensus: the real bug was the friendships we destroyed during code reviews over whether to use them or not

  4. Anonymous

    JavaScript's ASI is the programming equivalent of 'move fast and break things' - except it's your parser that's moving fast, and your code that's breaking in production when you accidentally return undefined because the semicolon insertion decided your return statement was complete on its own line. Meanwhile, every other language is sitting there like a strict parent insisting you finish your statements properly, while JavaScript is the cool uncle who lets you get away with anything until suddenly you can't figure out why `return\n{value: true}` doesn't work

  5. Anonymous

    JavaScript lets you treat semicolons as a lifestyle choice - right up until an IIFE or a return newline turns ASI into your on-call rotation

  6. Anonymous

    JavaScript: "I'll allow it" - right up until ASI turns return\n{} into return; {} and your concatenated bundle ships a heisenbug that only reproduces without a newline at EOF

  7. Anonymous

    JS ASI: optional semicolons for that artisanal 'undefined in prod' flavor every senior dev secretly loves debugging

  8. @RiedleroD 5y

    cough cough python

  9. @coleale 5y

    пояснительная бригада

    1. @nykytenko_yevhenii 5y

      В джс иногда можно без семиколон

  10. @Four_Velocity 5y

    Python: "Да кто такие эти ваши семиколонс нахуй?"

  11. @maxgraey 5y

    Да ладно даже в Rust можно без разок в конце блока)

    1. @cringle_flex 5y

      В расте это обусловлено семантически, в жабаскрипт семиколоны практически декоративные

      1. dev_meme 5y

        There are few cases when they’re required

        1. @cringle_flex 5y

          O da vi iz Anglii

  12. @golikova_anna_aaa 5y

    *Laughs in Kotlin*

    1. @denisndenis 5y

      *Laughs in Scala*

      1. @somanithpreap 5y

        *laughs in JavaScript*

  13. @p_0xbadf00d 5y

    *laughs in swift*

  14. @freeapp2014 5y

    lol

  15. @aw0x0 5y

    golang, ruby ?

  16. Deleted Account 5y

    Kotlin

Use J and K for navigation