Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

From the comments

> I believe it's Google Closure compiler putting commas in there.

Someone else linked to an explanation of why

> http://blog.vjeux.com/2011/javascript/javascript-comma-trick...

</fact><opinion>

So from the looks of it, the problem is in Opera's javascript implementation.

I'm not sure how much Google uses Closure Compiler internally but I wouldn't have thought they would use code they knew to cause issues in some browsers. I guess that ether means the Opera implementation is wrong and the code should work fine, or Google didn't test this as fully as they should have done



Uglify uses the comma trick a lot, and from my experience, Closure Compiler doesn't rely on it very often.

Regardless, the actual bug is in Opera as the resulting javascript is legit, even if its absolutely crazy to have 4MB of script be only a single javascript statement.


That "explanation of why", when you take the trouble of reading it, is just an explanation of how. The article ends with:

Conclusion - Using the comma trick to do { }-less indentation is far from viable. However this may still be useful for debugging and overall it is fun to try new coding styles!


Reading the article and the comments made it more clear to me. Twitter is using some minification tool (maybe Google Closure) which attempts to reduce the number of characters used. Using commas you can reduce two characters by avoiding some brackets.

    if(true){dothis();dothat();}

    if(true)dothis(),dothat();


Is it a bug though? Sounds like a conscious design limitation in the parser. A bad limitation, but not a bug. Sounds like it's behaving "as expected".


ECMAScript is a language with an ISO standard behind it. Any time a parser doesn't comply with that standard, it's a bug.


They consider it a bug:

We already knew that we had a limitation that other browsers don't have in the parser, and it was already considered important to fix. Breaking Twitter of course raises the profile of this bug.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: