4 ms·
This seems very likely not to be a programming style choice but some kind of optimization trick by a JS minifier/compiler. I don't think this has anything to do
by mistercow 14y ago
This seems very likely not to be a programming style choice but some kind of optimization trick by a JS minifier/compiler. I don't think this has anything to do with the typical semicolon war.
- darrenkopp 14y agoWell, we do know that the guy at Twitter that works on their bootstrap is anti-semicolon, so I would say its likely both.
- cristiantincu 14y agoAnd we know, as well, that this so-called-argument is an ad hominem attack and a red herring.
- aggronn 14y agoIts also his opinion and the result of decisions made by people who represent twitter.
- cristiantincu 14y agoIt’s the result of a bug in Opera’s JavaScript interpreter, parsing a minified file. ☺
- mistercow 14y agoI doubt any remnant of a programmer's semicolon preference would make it through a compiler that performs this sort of optimization. The code is likely going to be transformed into an intermediate form (after applying ASI rules) and then that will be transformed into an optimized output.
- jessedhillon 14y agoThere was a story here a while back about how the Twitter/Bootstrap developer was arguing with Douglas Crockford about whether or not he should have to insert semicolons. The cause of the argument was the fact that the minifier was changing the meaning of the code, IIRC, by preserving semicolon preference.
- mistercow 14y agoRight, but that was JSMin, which is more of a souped-up find and replace, whereas this comma-replacement strategy is what you'd expect from a much more sophisticated compiler which does static analysis and complex code transformations to squeeze out more than you can achieve by simply compacting white space and deleting comments. That level of modification would be crazy and fragile if you were modifying the original source code, so it's a fair bet that ASI is irrelevant by the time you're looking at the compiler output.
- kitsune_ 14y agoWhen I first had a look at the bootstrap source I was astonished. It seems to be a rather vain thing to do. What does it gain you?
- jonknee 14y agoPurity. Read the issue tracker threads about it, he's militantly against semicolons, even when it's demonstrated to introduce problems with other software (like minifiers). Update: Here's the thread I was thinking of https://github.com/twitter/bootstrap/issues/3057 https://github.com/twitter/bootstrap/issues/3057
- jarin 14y agoBeing anti-semicolon in JavaScript is kind of like being anti-parentheses in Lisp. The automatic semicolon insertion is a "feature" to give some leeway to new/sloppy developers, not a real feature that good developers should use.
- streptomycin 14y agoThe comments on the blog post say it's because of Google Closure Compiler.
- acqq 14y agoAnd Google has a long history (years!) of making Opera appear as bad as possible. One of the classical things were that they had more sites that declined to work at all but worked with no problem in Opera if you force Opera to report itself as "Firefox."
- mkopinsky 14y agoI bet Google intentionally wrote Closure Compiler to use commas, with the knowledge that Opera has a bug with too many commas, so as to intentionally cause Opera to mess up and look bad. </sarcasm>
- acqq 14y agoLet me guess, you never used Opera yourself? Otherwise, you wouldn't question the facts, you would have lived them: Google sites intentionally blocked Opera based only on the User agent. The most recent intentional annoyance is less than two weeks old: http://www.zdnet.com/google-annoys-opera-users-who-wont-switch-to-chrome-7000000279/ http://www.zdnet.com/google-annoys-opera-users-who-wont-swit... "(...) it's a mark of pure arrogance from a company that isn't afraid to act like Microsoft (1998) when it needs to muscle out a competitor. The Google roadblock for Opera is crude. If you change the User-Agent string for Opera so that it identifies itself as Google Chrome, the Blogger editing and management screens work perfectly."
- mistercow 14y agoBut none of that is relevant because it just isn't very plausible that Google would intentionally exploit a bug this way in their compiler specifically as a way of attacking Opera. They used a valid optimization technique that does save some space, and does conform to the standard. Did they likely test it extensively in Opera? No. But to act like this is an intentional offensive move is conspiracy theory level nonsense.