Personally I think the Google Javascript Style Guide has it right: > Relying on implicit insertion can cause subtle, hard to debug problems. Don't do it. You're better than that. http://google-styleguide.googlecode.com/svn/trunk/javascript...
Poll: Semicolons in JavaScript
21–30 of 44 posts
Re: Poll: Semicolons in JavaScript
#22Re: Poll: Semicolons in JavaScript
#23When the curly-braces-syntax is replaced with proper sexp, I'm all for it. Until then, I prefer to keep the semicolons.
Parenscript; the happy amalgamation of Common Lisp and JavaScript, in your server or your browser. http://common-lisp.net/project/parenscript/ People are writing Node.js code in it :-) http://tryparenscript.com/ It reminds me of an old Scheme dialect, implemented in Common Lisp, and was used to implement the Yale Haskell compiler (by Sandra Loosemore[1], et al.); it's just one of those baroque language towers that yo…
Re: Poll: Semicolons in JavaScript
#24Re: Poll: Semicolons in JavaScript
#25I add semicolons for the same reason I surround if blocks with braces, pad out blocks with whitespace, and avoid the ternary operator in all but the most trivial cases. If you ever find yourself dropped onto a line of my code by a debugger, chances are you'll be able to figure out exactly what's going on immediately.
At least that's the goal.
(more here: http://expatsoftware.com/articles/2007/06/getting-your-prior... )
Re: Poll: Semicolons in JavaScript
#26Re: Poll: Semicolons in JavaScript
#27For me it's a 'yes' based on the simple rule that explicit is always better than implicit. That sort of 'optimisation' seems to be really cool when you're just starting out in a language but in the long run it isn't worth it. The first time you're bitten in the behind by a subtle bug after a couple of hours searching you've given up a hundredfold the time you have saved up to that point by not having to type those ;s…
> For me it's a 'yes' based on the simple rule that explicit is always better than implicit. That sort of 'optimisation' seems to be really cool when you're just starting out in a language but in the long run it isn't worth it. I don't really get what you call implicit when you terminate statements with semicolons instead of linebreaks... ... Ok, I get what you're hinting it: there are some (very) few exceptions. How…
x = y
/* TODO: clean this up to make it more readable
* and maybe add some semicolons
*/
+ 4
... is a single statement.Re: Poll: Semicolons in JavaScript
#28Earlier quoted context omitted.
Was going to say that this is clearly a bug in the minifier but then I thought about the effort involved in properly supporting non-terminated lines (or even detecting it). You're going to end up writing a JS parser. This really shows the cost of this syntactic nicety to the language.
I would hope that minifiers use a JS parser!
Re: Poll: Semicolons in JavaScript
#29JS minimizers tend to remove all the newlines, so semicolons are often necessary if you use one.
The YUI minifier, for example, works perfectly fine without semicolons in the original. Equally, the Google Closure Compiler does also.
If you're using a minifier that just removes new lines and suffers without semicolons, I think you should rethink your minifcation process.