Shared publicly  - 
 
There are idiot web developers who are using commas in place of semicolons because they need to be free to express their individual idiocy. It turns out there are consequences.

Moral: Don't forget to use your semicolons.
101
24
Jeroen Versteeg's profile photoMike Samuel's profile photoEddie Chaplin's profile photoAaron Voegele's profile photo
13 comments
 
I've never understood the move away from the semi colon. It's easy to see and has a single purpose.
 
The only good thing about something this stupid breaking a big site (on just one browser, admittedly) is that teh interwebs takes note, and hopefully discourages a few devs from using these hacks.
 
I put semicolons at the end of my statements;
 
+Jeroen Versteeg indeed. But (if I understand the problem correctly), isn't calling standard comma operator a "hack" a bit harsh? (Please don't take it as a provocation. I see it as a technical issue: there is well-described comma operator in standard, there is widespread convention of not using it for more or less obvious reasons, but FMoPW it does not make it a hack /per se/.)
Also, if there is not any standardized limit for amount of operators in single statement (is there?), isn't this post, at least partially, accusing web developers of certain browsers failure?
 
Wow, I don't care if Google Closure thinks it's a cool trick, that is awful, awful coding style. If you really hate the braces so much, put your multiple lines of code into a function or a lambda. Don't try to trick the compiler because you don't like one extra line of }.

And just to be snooty, as a professional programmer I NEVER do single line if statements. If I only need one line of code after a conditional statement I still put a pair of braces.

if(x)
{
    //single line of code;
}

This makes sure that anyone who reads my program knows for a fact that only that line is in scope, and if I ever need to add another line of code I will NEVER accidentally put it outside of the condition, since the braces are already there. Yes, I even do this in my javascript.

Whitespace is free. Use it.
 
+Eddie Chaplin I do this, too. I'm not concerned about someone else reading my code. I just don't want to confuse myself.
 
Great quote from Jurassic Park: "Yeah, but your scientists were so preoccupied with whether they could that they didn't stop to think if they should."

They were talking about manipulating dinosaur DNA, not faulty programming styles, but it still fits, except for the part about scientists.
 
Clearly, compilers/compressors do this to save space. There was seemingly never a concern about parsers being unable to handle it. I'm sure, now that it's been realised, the compressors will change their tacts. 
 
+James Padolsey Yes.  It allows shortening statements like {if (x) { foo(); return y; } else { bar(); return z; }} by factoring returns and throws left: (return x?(foo(),y):(bar(),z)).  The reason it's often done even when that or similar optimization aren't possible is an assumption that having mostly commas in the output source code and few semicolons will lead to better GZIP compression.  That latter is an empirical claim that I can't provide data for, but the thinking tends to be that GZIP like Huffman performs better when the distribution of chunks in the input is spikier.  (None of this is meant to excuse code-generator writers from failures to understand the limitations of code-consumers.)
 
+Liam Carton I have yet to see one good reason to avoid semi-colons. Can you give me an example for a good reason?
Ilya Sh
 
+Andrew Ray, The commas in question came from minifier, indeed. But twitter developers are "famous" for their hatred of commas. for example: https://github.com/twitter/bootstrap/issues/401

So, anger is justified, i think. Isn't it insanely stupid to break things just to get rid of semicolons because they are "bad"?
Ilya Sh
+
1
2
1
 
No, it IS a JS developer issue.

Constraints like this exists in virtually all languages. C/C++ compilers have a limited number of cases in a switch operator, and have limits on template instantiation depth. MySQL cannot join more than 32 tables. There are limits everywhere. If some feature works in a clean room environment, it does not mean it will work seamlessly in a production environment. Everything should be used in a way it is supposed to be used. And semicolon operator should be used to separate statements, not comma.

Opera now is in Microsoft's hat, because when ms made new versoion of windows (say, Windows 95, 98 ...), they had a lot of hacks to support buggy software written for previous verions. It was error in a third-party software, but it was Microsoft's responsibility to make a workaround. Because it's they who will be blamed.
So, when twitter is not working, it's Opera who will be blamed by end-users, that's why they are striving to fix it (and cursing twitter devs at the same time, i suppose)