News for hackers. Stuff that matters.
Re:Why are programmers afraid of not using semicolons in Jav... by einaregilsson on Sunday August 07, 2011 @11:33AM (#2856808)
But isn't that part of learning any language? There are plenty of weird edge cases in other languages but we get used to them. Basically this boils down to:

"When you have a single statement, that stretches out over more than one line, but those lines are legal statements on their own, then it won't work like you want it to"

I would guess that the number of statements that stretch out over many lines are a very small part of the overall number of statements for most code.

But it just seems like most developers think that javascript might insert semicolons all over the place. Which it won't, the rules are clear once you learn them.

Re:Why are programmers afraid of not using semicolons in Jav... by einaregilsson on Sunday August 07, 2011 @11:42AM (#2856832)
Ahem, maybe not as clear as I thought, since I found a few other edge cases I didn't know of in this excellent article:

Best article I've read on the subject: http://inimino.org/~inimino/blog/javascript_semicolons

Re:Why are programmers afraid of not using semicolons in Jav... by felipemnoa on Sunday August 07, 2011 @02:04PM (#2857261)
Or, just add a semicolon and keep it simple. Why risk it? KISS at work.
Re:Why are programmers afraid of not using semicolons in Jav... by einaregilsson on Sunday August 07, 2011 @02:32PM (#2857349)
There are two possibilities:

1. Prefix lines that start with punctuation, specifically [(-+/ with a ;. Then omit them everywhere else. Lines that start with punctuation are a tiny subset of all lines generally.

2. Postfix every line with a ;, "just in case"

I can't see how nr. 1 is harder. And in case 2 you don't actually put ; at the end of every line, you don't put them after {} blocks for example, so it's not like it's somehow easier to remember.

"Because we're used to doing it that way" is a reason I guess, but not a great one in my opinion.