r/javascript • • Feb 05 '11

Are Semicolons Necessary in JavaScript?

http://aresemicolonsnecessaryinjavascript.com/
0 Upvotes

66 comments sorted by

View all comments

11

u/skeww Feb 06 '11

They are necessary in some special cases. Since only a few people are aware of those special cases, it will save time to put semicolons everywhere and be done with it.

Use minifiers for minification. Don't waste anyone's precious time with this pointless shit.

Same thing goes for hugging braces. You don't need to use hugging braces everywhere. But it's of course easier to use hugging braces everywhere.

Or things like == and !=. Very few people memorized those massive result tables. Don't use that crap. (Use === and !== instead.)

Or operator precedence. Just add some parens to make clear what happens.

Run-of-the-mill source code isn't the place to show how clever you are. To be honest, it will make you look just plain stupid. Don't do things that are harmful to the productivity of the whole team. Don't do things that are harmful to your productivity. Don't do things that require additional attention - attention is a very limited resource.

0

u/sjs Feb 06 '11

The only reason few people are aware that you only need semis before lines beginning with ( and [ is because instead of educate people about the actual language all we seem to do is spread misinformation and FUD about semicolons in ES. It's so incredibly easy. That anyone thinks it's a lot to remember is utterly ridiculous. Doubly so in the context of software development. 1 measly rule, that's it.

Instead of saying "Sure use semis if you want, but be aware of ASI and that it may surprise you. Or leave them out except on lines beginning with ( and [, and be aware that ASI may surprise you sometimes. The canonical surprise cited is return\n{ but in practice nobody actually writes code like that so take the warning with a grain of salt.", we instead support this theory.

1

u/skeww Feb 06 '11

This isn't a religious issue. Don't try to make it look like one.

Since I'm not anonymous here (5 minutes of detective work will tell you that I'm Jos Hirth)... are you trying to say that you're a "total fuckwad"?

2

u/sjs Feb 06 '11

Sorry I'm honestly not trying to make this a religious issue. And I'm not anonymous either.

I don't care whether people use semis or not. It'd be like caring about brace style, it's purely aesthetic. I just don't like the misinformation.

Sami Samhuri

http://samhuri.net

http://twitter.com/_sjs

1

u/skeww Feb 06 '11

samhuri.net is a parked domain, in case you didn't notice.

1

u/sjs Feb 06 '11

Crap, I forgot about that. Waiting on the registar to sort that out (and to transfer the domain...), expired end of Jan and the reminders went to my old email address from school so I didn't notice until it was parked :/

https://github.com/samsonjs is the next best I've got.