How do you respond to somebody who's claiming something's bad, knowing all the arguments why something is considered good, and still tries to spread the badness about it? I don't know, actually. I didn't want to burn myself with that one either. I'm afraid it'll be a useless discussion.
Today I was pointed towards a blogpost
Now by itself, I don't really care. I mean, he knows the potential pitfalls leaving out the semi-colons so if he ever faces such a problem, he'll only have himself to blame for it. But what if he participates in some OSS project like CommonJS? Or how will he program at work, in an environment where maintainability and coworkers should be one of your primary concerns? Will he suddenly use semi's now? I doubt it.@jdalton
also points out
that Safari 2 doesn't even allow leaving out semi's after throw statements. This would be one of those browsers mislav deems forgotten, I guess :)
Now recently Inimino also wrote a piece
I don't really want to get deep into those problems. The specification outlines them pretty clearly and there are tons of posts about these cases anyways (google them!). So let me just mention the two most important ones:
- A return/break/continue/throw statement with the argument on the next line will actually not use the argument (but use undefined).
- Certain multi line snippets could be interpreted wrongly (because auto semi-colons are not _always_ inserted).
var x = y
This would be executed as a single line; var x = y(a||b).alert(); (and most likely cause a weird error you'll be searching for a long time).
Not executed. There is no return allowed between these two components. Of course this is not a serious problem, but if you encounter it you'll be in serious problems.
So while semi-colons are optional, in some cases they are actually not. Granted, these cases are rare, but they are there and they can really be a pain to debug. So I think it is the responsibility of those that know about these thing to protect those that are unaware of the issues. Especially in a professional environment or a public group project, enforce semi-colons.
Just don't get used using the semi-colon-less style "for personal projects". It's very hard to unlearn a style once you get used to it. Before you know it you'll (try to) get this style into some project. And then what? On the other hand, how much is really involved in putting the semi's where they belong? Helping the readibility, structure and minification of your source while preventing possible obscure hard-to-debug-even-harder-to-fix bugs on the way.
As for the specification? Read Ecmascript 5
, paragraph 7.9 on Automatic Semicolon Insertion.