this post was submitted on 04 Dec 2024
87 points (89.2% liked)
Programmer Humor
19833 readers
198 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I don't get it? When has this ever fixed a bug? Compiler error sure? But a bug?
I actually had a bug in a game jam freshman year because of this. It was java, so there was a lot of questionable decisions going on, but adding the semicolon fixed it!
...I want details. Java is my most used language and I want to know lol
… now that I’m thinking harder it may have been a colon? The real problem was that we’d only been programming a few months at that point and were pretty good at accidentally fucking up syntax
Ah, I mean syntax issues trigger compiler errors though. I'm not sure of one that compiles but has odd behavior... except the increment/decrement operators. Maybe I'm just not remembering one
Semicolons are technically optional in JS, but there are some rare cases where omitting them can result in different behaviour.
And this is why you should enforce code style, kids. Preferably with an automated tool.
I'm on my phone rn so can't format well, but one such example is:
const thing = require("module")
(async () => { something })()
without a ; at the end of the first line, JavaScript will try to do require("module")() instead
I don't get the semicolon either, may be a language barrier. used question marks like this for optional chaining in typescript though...