this post was submitted on 25 Jan 2025
702 points (98.1% liked)

Programmer Humor

33090 readers
348 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 26 points 5 days ago (3 children)

My personal favorite is when it complains about a missing semicolon. So it's 100% knows what the problem is, it knows where the problem is, and it knows how to fix it. But it's not going to fix it out of spite.

[–] [email protected] 4 points 3 days ago

Thing is, if it just guesses what you meant instead of sticking to the standard, you can end up with ambiguous meanings. Like what if you forgot a character that wasn't a semicolon but inserting a semicolon would turn it into valid code?

Like:

x = y z++;

Inserting a semicolon would turn that into set x to the value of y and then increment z. But maybe the line is missing a plus instead of a semicolon and the intent was to set x to y plus z and then increment z.

It's a pain but strict syntax helps avoid frustrating to debug bugs.

Taking it a step even further, you can make your code more robust by treating warnings similarly to errors. Even though the general cases usually still work despite warnings, they are great for avoiding edge cases that can also be difficult to debug. At least if you take the time to understand what the warning is really about and don't just google "how to get rid of warning x" and add some casts or something you don't understand to make the message go away.

[–] [email protected] 14 points 5 days ago (2 children)

Oh boy, are you gonna LOVE Javascript

[–] [email protected] 1 points 3 days ago (1 children)

Is your point that JS doesn't really need semicolons at all any more?

[–] [email protected] 1 points 3 days ago

Not just that, it's the reason why it doesn't need semicolons: https://en.wikibooks.org/wiki/JavaScript/Automatic_semicolon_insertion

[–] [email protected] 1 points 3 days ago

Javascript and html are more suggestions on how to write something that may work in a web browser.

[–] [email protected] 2 points 5 days ago

This is why i flunked college