9 ms·
Crockford on Bootstrap's semicolon omission: “insanely stupid code”
- shpoonj 15y agoWhat a child... Has anyone read the GitHub style guide? 'Do your best to never use a semicolon. This means avoiding them at line breaks and avoiding multi-statement lines.' Grow up Crockford. Do research before you post. Stop assuming because you supposedly once knew how to do something, you still do, and always will. Times change. However, this is all very exciting. It gives Twitter, or whatever other start up, an opportunity to replace an outdated piece of software by a nut case!
- FlemishBeeCycle 15y agoWhy do you believe the github style guide to be the authoritative source for JavaScript style? There is no benefit for avoiding use of semicolons other than not writing semicolons, whereas there are several detriments for their omission. > It gives Twitter, or whatever other start up, an opportunity to replace an outdated piece of software by a nut case! I don't know where this ad-hominem is coming from, but Douglas Crockford is hardly a nutcase.
- web_chops 15y agoGoogle style guide says otherwise: http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml#Semicolons http://google-styleguide.googlecode.com/svn/trunk/javascript... If people hate semi-colons with such a passion, why not simply use coffeescript and be done with it instead of depending on butterflies flapping their wings...
- simonw 15y agoYou're honestly telling Douglas Crockford to "do research" before posting on the topic of automatic semicolon insertion?
- Lazare 15y agoJacob is an idiot for writing code with a ridiculous fragile syntax that takes more effort to write in a vain effort to obtain "coolness" via winning a pointless language war that nobody on earth cares about. Crockford is an idiot for writing an JS minifier which explicitly promises to not break legal code but actually does, and then refusing to fix it because he's proud of his reputation for being an asshole. And everyone commenting on this post is an idiot for thinking that any of this is worth the pixels it takes to argue about it. And yes, that includes me. sigh This whole thing just makes my head hurt.
- Deestan 15y ago> a pointless language war that nobody on earth cares about. The comment section disagrees with you. He's just writing his damn code the way he wants to, which a large number of people seem to care about.
- smhinsey 15y agoFunny, I was just checking out Derby and noticed that their examples follow this style.
- felipe_csl 15y agoWhy the hell people are refusing to use semicolons? I don't get it
- smhinsey 15y agoI'm sure there is a whole huge debate here that I'm unaware of, but it seems like a largely aesthetic choice to me, and on that basis, I find it really jarring as someone who is not an everyday JS author.
- Groxx 15y agoI've seen a few reasons. The main ones I encounter are: raising the skill requirement to contribute (you have to know JS better than average to never use a semicolon, and do so correctly), aesthetic (fewer characters looks better), and minimalism (don't use what you don't need).
- ricardobeat 15y agoMissed the most important: no more errors from missing semi-colons.
- rpearl 15y ago> raising the skill level to contribute That's insane. Good programmers need not know stupid tiny nits about Javascript (heck, I've worked on a Javascript JIT and I don't really know Javascript). That does not mean that they are not skilled. > aesthetic I don't understand how "you must carefully understand how the language parses to understand this line of code" is aesthetically pleasing when compared to unambiguity. > minimalism Here, it is needed, at least arguably (by douglascrawford). You could argue that the "optional semicolons" rule is ugly and not minimalistic, and thus the minimalistic approach would be to not use that rule.
- drivebyacct2 15y agoCrockford's stance is annoying purely because it's pedantic and because there are many libraries that embrace this style. We use django_compressor and found bugs from the compressor that uses Jsmin. So I have to use something else to compress them before hand. Are there compressors that use the syntax tree rather than transforming the source?
- YuriNiyazov 15y agoIs there any particular reason why you refuse to put in the semicolons in Javascript?
- jpeterson 15y agoThere's a whole hipster movement going on right now around the idea of omitting semicolons from JavaScript code. I believe CoffeeScript is the culprit. Personally, I agree with Crockford -- it's dumb.
- leetrout 15y agoMeh, the real hipsters are just pushing comma-first.
- maratd 15y agoThey're all hipsters.
- deleted 15y ago[deleted]
- bratsche 15y agoKind of funny that you say this, since CoffeeScript inserts semicolons. The lack of semicolons is the one major thing in the Github style guide that I think is stupid. It seems silly to avoid using semicolons in Javascript because it actually takes a little bit more effort than just using them.
- joshontheweb 15y agoyes, yes, yes.
- magicalist 15y agoif there's anything worse than crockford being a jerk, it's the self-aggrandizing asi crowd. Let's not give either any attention.
- joshontheweb 15y agoI'm sure this thread is going to be a good, old fashioned flame war. Let the games begin.
- Jimmie 15y agoMy favourite part is half-time, when the flame-war overseer yells "Change Places!" and everyone has to argue for the other side.
- goronbjorn 15y agoIt's called forking.
- sferik 15y agoFor a good explanation of why it's a good idea to always use semicolons in your JavaScript, take a look at: http://lucumr.pocoo.org/2011/2/6/automatic-semicolon-insertion/ http://lucumr.pocoo.org/2011/2/6/automatic-semicolon-inserti...
- ricardobeat 15y agoThe examples he gives are exactly the situations where you should use semi-colons, as understood by those who skip them. Take a look at http://blog.izs.me/post/2353458699/an-open-letter-to-javascript-leaders-regarding http://blog.izs.me/post/2353458699/an-open-letter-to-javascr...
- ricardobeat 15y agoIt is a bug on JSMin. Minifying should never alter code behaviour.
- deleted 15y ago[deleted]
- ricardobeat 15y agoSo you think it's ok for a minifier to break working code? Please explain.
- abraham 15y agoThe minification isn't breaking the code. The authors had an incorrect expectation of how JSMin would minify the code. By the very act of minifying code where new lines matter your are always potentially changing the behavior.
- mistercow 15y agoThe minification is breaking the code. If a minifier takes valid JS in and produces JS that behaves differently from the input, then that minifier is broken, full stop. It doesn't matter how anyone personally feels about ASI; what matters is that ASI is a part of JS, so if you're making a tool that processes JS, you need to respect its rules.
- deleted 15y ago[deleted]
- Sephr 15y ago> ! is not intended to be a statement separator. ; is. Which is why there is a line break there. He's far too stubborn to realize that JSMin is at fault for not being able to correctly parse JavaScript.
- jpeterson 15y agoThe line break will not help if ! becomes an infix operator.
- jurre 15y agoBut as of now it's not.
- erichocean 15y ago! is already being discussed to be turned into an infix operator in a future version of JavaScript.
- deleted 15y ago[deleted]
- Sivart13 15y agoFuture versions of JavaScript might also replace the 'function' keyword with a picture of a chicken, but I'm still going to keep typing the word 'function' for now.
- deleted 15y ago
- dantillberg 15y agoI wonder if the "insanely stupid" comment isn't about the omission of the semicolon but about the omission of "if". Since when is a good old-fashioned if-statement out of style?
- rocktronica 15y agoLearning the minutiae of a language is important, sure, but I can't fathom why you'd willingly introduce unnecessary fragility or overthink into your codebase. Ideally, your goal as a hacker is to make cool shit. Your goal is not syntax.
- ajacksified 15y agoThis is precisely correct. "Don't do x, except in one or two cases where you have to, and then you can hack around it using y instead of x" - rather than "use x by default." Simplicity should win; but alas, being one of the cool kids is more important.
- gfodor 15y agoThere's something horribly wrong with everything about this. Why is such a smart person as Crockford wasting his time arguing about semicolons in 2012? Why is this at the top of the most popular hacker website? Why are people writing detailed opinions about semicolons in this thread (with surely more to come?) One would hope that at least over time the bike sheds being argued about would start to at least evolve into arguments about bike garages and eventually bike factories. But I guess the bike shed is forever a bike shed, as long as we're making bikes. Whatever the next disruption is in software engineering, please dear God let it be immune-by-design to this type of distraction.
- batista 15y ago>There's something horribly wrong with everything about this. Why is such a smart person as Crockford wasting his time arguing about semicolons in 2012? The disturbing thing is the idiot arguing about implicit semicolons in a language with not good support for them, in a general use library.
- batista 15y agoThanks for the donwvoting, at least Brendan Eich and Douglas Cockford agree with me... http://brendaneich.com/2012/04/the-infernal-semicolon/ http://brendaneich.com/2012/04/the-infernal-semicolon/
- deleted 15y ago[deleted]
- saurik 15y ago... Crockford is the developer of JSMin, and was explicitly dragged into the conversation because people claim (possibly correctly) that it is a bug in JSMin than when it is given code with semi-colons that are missing in places that the JavaScript specification claims are optional (possibly also stupidly), it generates output that is not semantically equivalent to the original code. Your statement thereby makes no sense: this is precisely the kind of argument and conversation--a bug report from a user that itself can be construed as a question about what the purpose of the project is and what parts of the specification it will choose to support--that one would hope the primary maintainer of a project should be "wasting his time" involving himself with.
- dubcanada 15y agoHow many times must this bush be beaten. I've read people complaining about no semicolons in javascript for ages. Get over it...
- Yarnage 15y agoI agree with Crockford.
- tbranyen 15y agoI think the stupidity here is entirely isolated to using JSMin.
- tbranyen 15y agoAllow me to explain further, as I've been down-voted a few times. My point is that its stupid to use a tool on code it was not written to support. If you want minification with valid JavaScript, use something like Uglify-js. If you write code, however, that works with JSMin, then use that tool. Douglass Crockford can write his software to work any way he likes and support any code he likes. Don't like it? Use something else, and don't be stupid.
- ronaldj 15y agoThat code is bad for more reasons than the semicolon omission.
- meric 15y agoExample when a semicolon is required in non-minimized javascript. alert(1) // add semi-colon here to make this code work (function(){alert(2)})()
- joedevon 15y agoSomeone should write a tool that automatically inserts that comment instead of a semicolon. LOL
- insin 15y agoThere are other options here too but, given the OP, people seem to get irate when you use the features the language specification guarantees :'/ alert(1) void function(){alert(2)}()
- meric 14y agoNice, didn't know void can be prepended to a function definition.
- losethos 15y agoASM in LoseThos is processed with Lex() so <CR> is ignored, mostly. The ASM syntax has been adapted accordingly. At the command line, an ending ';' is converted to two ;;. The compiler fetches the token ahead so compilation lags a token. God says... C:\LoseThos\www.losethos.com\text\PARADISE.TXT nflames the air; So started up in his own shape the Fiend. Back stept those two fair Angels, half amazed So sudden to behold the grisly king; Yet thus, unmoved with fear, accost him soon. Which of those rebel Spirits adjudged to Hell Comest thou, escaped thy prison? and, transformed, Why sat'st thou like an enemy in wait, Here watching at the head of these that sleep? Know ye not then said Satan, filled with scorn, Know ye not me? ye knew me once no mate For you, there sitting where ye durst not
- chrisguitarguy 15y agoFrankly this is less about semicolons and more about two people who both have strong opinions and feel that they need to act in a certain way. It doesn't take a lot more effort to rephrase fat's response to be more cordial. "Hi @englishextra, those two lines are valid JavaScript. We try not to use semicolons whey they aren't necessary. See (insert link to the wiki). "JSMin doesn't perform well on bits of JS like this. Maybe you can discuss it with @douglascrockford ?" Flamewar avoided (probably) and more stuff getting done.
- deleted 15y ago[deleted]
- jimmyjazz14 15y agoI agree. The real problem here is the complete lack of courtesy from either party. Software developers seem to have problems with this, maybe because we spend so much time commanding machines to do things with brief statements without the even the least bit of a please or thank you.
- seandon 15y agoI don't get it, @fat never said anything negative/positive towards Crockford. Why is this even a thread??
- jrockway 15y agoAh, I'm so glad that Github allows animations in pull request comments. They really increase the level of discourse!
- thealphanerd 15y agopopcorn.gif
- greghinch 15y agoWhile this "argument" has prompted several lol's on my part, JS really needs some equivalent of PEP8 And if you don't use semicolons you are an asshole.
- simonw 15y agoDouglas Crockford's JSlint is pretty much that.
- cletus 15y agoWow, I had no idea "asi" (automatic semicolon insertion) was a thing. Describing it as "hipster" is pretty much spot on (IMHO). I think this makes a great negative filter for interviewing actually: Q: How do you feel about using line-breaks and other obscure JS rules to avoid putting in semi-colons? A1: That's idiotic (interview progresses) A2: Great idea (rejected) That may sound harsh but here's my complaint: working with other programmers means writing code that's easily understood. Syntactic tricks to reduce the character count for a couple of dozen as an artificial barrier to entry shows me that you are far more concerned with mental masturbation and "Javascript elitism" than the needs of the project or your coworkers. Bad culture fit. User fat ("Jacob") is a perfect example of this. Crockford could've handled this better but honestly I sympathize with his frustration. Just because something is possible doesn't make it a good idea. You can technically drive a car with no seat belt using nothing but your feet but that doesn't mean you should. At the end of the day this is a bug in JSMin but how much exactly should one cater for pathological edge cases (which I consider this to be)? It's all about readability. Sometimes you put parentheses around arithmetic expression to make it clear what's happening, not because it's required. You put a semi-colon after each statement because it's clear.
- bkorte 15y agoOooh, developer drama.
- biafra 15y agoIf there is a tool to insert semicolons in all the right places, you could use that before using jsmin. Would that help?
- Jach 15y agoThe problem from my reading of it is that "all the right places" changes meaning depending on which specification of JS you're talking about. But yes it would work if you run into the problem and the semicolon-inserter targets the right spec.
- rasur 15y agoExcellent - another internet cock-fight, with both sides managing to act like total cocks.. What would be better is for both sides to fix their code: Crockford to fix minify for the edge cases like this (result: better, more robust code equals a win), and the twitter boys to add a semicolon for these edge cases (result: better, more robust code equals a win). But instead, as usual on the internet, it's just devolving into lots of "waah waah waah".
- TazeTSchnitzel 15y agoCrockford won't "fix" minify, because it's much easier to make JSMin work for a safe subset of JS than it is to make it work for all of JS.
- leif 15y agoI am not experienced with javascript, so I don't understand this argument. Can someone please confirm the following, or explain what's going on? Here is what I understand: 1. Javascript will add a phantom semicolon at the end of each line if it seems like you need it, for some definition of seems like. To me, it sounds like this is so that new HTML writers in '98 wouldn't see their pages blow up when they forgot a semicolon at the end of a script. It doesn't sound like professional programmers are expected to leave semicolons out on purpose (this is the opposite from python). The bootstrap authors took advantage of this because somehow screwing with the compiler is in vogue. 2. Crockford's tool broke when a semicolon was left out somewhere. I guess he didn't implement a proper js compiler that covers the entire language spec. 3. There's some business about unary and binary ! operators? Something about sticking a ! in front of your line lets you leave the semicolon off the end? This sounds utterly braindead to me. It's no fewer characters, and the thing you're typing is going really far away (at the beginning of a big block of code) from where it's actually meaningful to you (at the end). Also, it looks like it relies on some fairly convoluted unintended consequences of the spec, that may not be future-proof. Here is my analysis, if the above understanding is true: 1. Bootstrap needs to fix their code. This business of the compiler sticking in semicolons where it thought you meant them is a crutch to prevent stupid errors from being fatal errors in the average case, but that doesn't mean they aren't errors. Be explicit. 2. Crockford should fix his tool soon, not complain about other people's code, and say "I'll fix it soon, but for now, here's a workaround: just put a semicolon in your code". 3. What the hell. Are people really doing this? Is the web one big obfuscated javascript competition? What happened to writing simple, explicit, readable, maintainable code? Are we really bickering over single characters and trying to play subtle tricks with language esoterica to save them like a bunch of 14-year old perl newbies? Man, I hope these morons aren't in charge of my bank account. Overall, I'm with Crockford, but he doesn't need to be this much of a jerk about it. Further analysis, now that I've read it with a decent (non-cell) data connection: allowing gifs in a public issue tracker is a terrible decision.
- chris_wot 15y agoFor point 3, it might be worthwhile understanding what the ECMA standard says about automatic semi-colon insertion. It won't happen for the following: a = b ++c This becomes: a = b; ++c; and NOT: a = b++; c; There are other, odd gotcha's, but this is the one being discussed. I believe the issue with the bang (!) operator is that it's being considered as a binding de-reference of function objects. See here: https://mail.mozilla.org/pipermail/es-discuss/2010-July/011494.html https://mail.mozilla.org/pipermail/es-discuss/2010-July/0114... Therefore, the problem with the code would be that an automatic semi-colon would not be inserted and the code, which is currently: clearMenus() !isActive && $parent.toggleClass('open') Would become: clearMenus()!isActive && $parent.toggleClass('open'); Instead of: clearMenus(); !isActive && $parent.toggleClass('open'); That was my understanding, at any rate.
- ellie42 15y agoThat's really stupid. There's no plausible reason that the end of that method shouldn't have a semi-colon. I honestly wouldn't advise anyone use Twitter Bootstrap. You should always use semicolons in Javascript even if you're hippie. Hippies use coffeescript. And I think Google's style guide[1] is prevail over Github's style guide[2]. [1] http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml#Semicolons http://google-styleguide.googlecode.com/svn/trunk/javascript... [2] https://github.com/styleguide/javascript https://github.com/styleguide/javascript
- bbayer 15y agoyou don't have to use linebreaks either but people use it. There are lots of good practices making code easy to use, read and maintain. So just put f.. semicolon.
- deleted 15y ago[deleted]
- _rknLA 15y agoWhy is this discussion about semi-colon insertion and not about the use of short-circuiting as a replacement for specific 'if' statements and general inconsistency in the project? https://github.com/twitter/bootstrap/blob/master/js/bootstrap-carousel.js#L91 https://github.com/twitter/bootstrap/blob/master/js/bootstra... https://github.com/twitter/bootstrap/blob/master/js/bootstrap-modal.js#L61 https://github.com/twitter/bootstrap/blob/master/js/bootstra... (Incidentally, would lines 54/56 of bootstrap-modal suffer from the same problem? Or does the fact that the last function call on line 54 is already in an && expression change things) I'm kind of surprised that the bug wasn't fixed by changing the line to `isActive || $parent.toggleClass('open')` as is done here https://github.com/twitter/bootstrap/blob/master/js/bootstrap-alert.js#L52 https://github.com/twitter/bootstrap/blob/master/js/bootstra...
- Morcane 15y agoIf I would act like Crockford to my clients, I could clear out my fucking desk. Must be a really cushy place he is in.
- jhuni 15y agoI am so glad that I am a Lisper. I haven't dealt with issues of text file size or syntactic standards for at least a year.
- stiff 15y agoIt is hard for me to understand how one could make so many things in a programming language completely arbitrary - I mean it is natural for a language designer to have some vision of how the language will be used by other people, how will the common structure of the programs look like, but JavaScript looks like such a vision never existed, there are often several ways of doing the most basic things (writing vs. omitting semicolons mentioned here, writing vs. omitting "var", but above all else 1000 of ways of doing OO, all with it's own problems) and no easy ways at all of doing other very basic things (modules/namespacing). As a result you can find 10 or 20 programs written in JavaScript where each looks like it was written in a quite different language. Maybe it was an attempt to make an "easy" language for non-programmers (I doubt even this goal was in the end achieved), but as a primary language for programming client-side applications it is a utter disappointment. Not that I necessarily blame the JavaScript creator, I am sure there were plenty of corporate pressures involved and other factors of corporate/economic nature. I wish we could get some other programming language implemented in all the major browsers, then at least in the perspective of the next 10 years we could completely get rid of JavaScript, I am not sure if it possible to really improve the situation in a radical way just via incremental changes to the existing design.
- kellysutton 15y agoCrockford wrote JavaScript: The Good Parts. He did not write JavaScript: The Cool Parts.
- gorm 15y agoThe use of semicolon as best practice was sorted out years ago in the js community. Crockford has all his rights to tell these guys to sharpen up because that "fat" character is obviously a python smuch with no knowledge of JS history or respect for elders.
- alexchamberlain 15y agoShould JSMin being enforcing the spec or good practice? My vote: Good practice Upvote replies to vote. Please don't down vote the replies so we get a clear picture.
- alexchamberlain 15y agoGood Practice
- alexchamberlain 15y agoThe Spec
- mike_esspe 15y agoIt's obviously should be the spec + warnings for good practice.
- deleted 15y ago[deleted]
- prodigal_erik 15y agoThis isn't a legitimate HN poll, just a set of ordinary comments; please don't give undeserved karma for this abuse.
- biojazzard 15y agoIf I remember well, bootstrap is using cat & uglyfy, not JSmin. Every jQuery plugging in BS starts with a semicolon. The Battle of the blind egos.
- brown9-2 15y agoFor those that agree with leaving semi-colons out of JavaScript that they write for projects, can you explain what the benefit of doing so actually is? Seems like people are valuing aesthetics over producing code that works for 100% of the users/situations.
- dhconnelly 15y agoI'm new to JavaScript, but from what I can tell, the no-semicolons style - is incompatible with existing tools - is incompatible in places with upcoming versions of JavaScript - is harder to refactor, since you might need to add additional tokens to the beginning of lines depending on the previous lines - is confusing to new JavaScript programmers, since + it goes against the recommendations of many of the most popular books + it requires adding tokens to the _beginning_ of lines in places, making the entire enterprise more challenging to learn and of dubious utility + it discards one of the attractive qualities of JavaScript for programmers of other languages: familiar syntax And further, the use of constructs like !somethingHappened && otherwiseDo(x) instead of if (!somethingHappened) { otherwiseDo(x) } is bad practice in any language. "Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?" - Brian Kernighan, "The Elements of Programming Style" Although everyone has the right to maintain their projects with whichever style they prefer, given the above, I wonder why the chosen style was chosen.
- arethuza 15y agoActually constructs like: somethingHappened or otherwiseDo(x) used to be idiomatic perl (and might well still be for all I know). Edit: Just for amusement it would probably be: somethingHappened not { x otherwiseDo } if in PostScript
- knowtheory 15y agoAnd would allow for constructions like open FILE, "filename.txt" or die Which is nice enough to read (and can be seen in actual examples around the web: http://www.perlfect.com/articles/perlfile.shtml http://www.perlfect.com/articles/perlfile.shtml ) The semicolon wars frustrate me. We have an arbiter of what's correct/valid syntax and what isn't. It's the freaking lexer, heaping additional prescriptivism on top for something as trivial as semicolons is irritating. If your code has ambiguity problems, fix it by writing unambiguous code. Semicolons are not the only way.
- skylan_q 15y ago
- rbanffy 15y agoI happen to agree with Crockford on the omission of semicolons. I also have a strong opinion on clever code: you should always optimize for readability over aesthetics. But... Crockford could have said it in a much more tactful way that could elicit a more positive response, spare the world from this sad discussion, as well as channel the man-hours dedicated to this into more useful endeavors.
- jcoffey 15y agoWhat is insanely stupid is abusing the logical bitwise && operator rather than signifying their intent using a plain old if statement like the language intended.
- deleted 15y ago[deleted]
- grover3333 15y agoJacob/Fat was trying to minimize the code before it was run through minimizer and is surprised at the results? Sounds like another emotional issue.
- pbreit 15y agoThe obvious thing to do is: 1) JSmin should be modified to handle Bootstrap-style semi-colon-ing 2) Bootstrap should adopt the more commonly understood semi-colon-ing
- celticjames 15y agoI think older programmers will side with Crockford and for good reason. The bootstrap code makes assumptions about the future of the js spec and browser implementations that aren't safe. Young people don't remember the dark days of people writing js to leverage IE/Netscape specific bugs which then had to be turned into features because so much code existed in the wild that could be broken. Crockford is a scarred veteran of the spec wars. I'm sure that when he sees young people trying to game spec/implementation ambiguities, he thinks, "Never again! Not on my watch!" I think best practice is explicit, future-proofed code that doesn't tie the hands of spec authors or browser vendors. I know that Crockford's tool doesn't accept the current spec or browser behaviour, but his choice is informed by past experience and concern for the future. It's not just some random bug that he's too stupid or stubborn to fix.
- peregrine 15y agoReal question is... why not just use UglifyJS or any one of the other js minifiers? So what Crockford is opinionated about JS, we all know this. Don't use his products if you don't like his opinions.
- IsaacSchlueter 15y agoMy comment from the thread, buried under many pages of meme gifs: >>> @douglascrockford If TC-39 makes ! an infix operator, which causes \n to not terminate the statement, then that will be a syntax change that is incompatible with current code in the wild, which would be an insanely stupid move on their part. The fact of the matter is that JSMin isn't parsing JavaScript correctly. I thought the separation of concerns was that JSLint tells you about stupid code, and JSMin correctly parses JavaScript according to the ES standard and minifies it safely. >>>
- slantyyz 15y agoAm I missing something? Aren't Bootstrap and JSMin open source? Instead of focusing on coding philosophies, someone can simply fork JSMin's source and make the appropriate patch, or make a fork of Bootstrap that has JSMin friendly code. Regardless of our many diverse opinions, Crockford and Fat are entitled to maintain their own libraries in whatever fashion they desire. The fact that they made the libraries open source means "if you don't like my code or the way it works, here's my code, customize it and leave me alone".
- wpietri 15y agoUpdate: Bootstrap fixed their code as Crockford prefers. From fat's comment circa 11 am PDT: fwiw, this was patched in bootstrap way before i even encountered this issue - otherwise i wouldn't have closed it outright. Sorry for the confusion everyone. You can see the code here in 2.0.3: https://github.com/twitter/bootstrap/blob/2.0.3-wip/js/bootstrap-dropdown.js#L63 https://github.com/twitter/bootstrap/blob/2.0.3-wip/js/boots... I still maintain this is a bug in jsmin, but as others have pointed out - mark and I do our best to make bootstrap flexible with other great tools out there (like jsmin). This includes adding semicolons where necessary or changing minor stylistic things.
- dreamdu5t 15y agoI don't care what Crockford thinks. He's irrelevant and his opinions are often confused with expertise.
- alecperkins 15y ago“…Explicit is better than implicit… Readability counts… In the face of ambiguity, refuse the temptation to guess. There should be one—and preferably only one—obvious way to do it…” — The Zen of Python Ironically, the Zen of Python supports using semicolons in JavaScript. Also, both sides come off like children, but at least Crockford's opinion seems a little less selfish. It's like politics, with the difference being in their premises so they'll never agree. Also, why can't I (or anyone else) resist commenting on this rather pointless debate? I am disappointed in my weakness.
- noonespecial 15y ago"Be liberal in what you accept, and conservative in what you send." http://en.wikipedia.org/wiki/Robustness_principle http://en.wikipedia.org/wiki/Robustness_principle Its like the golden rule for software. It generally stops nonsense like this cold.
- MichaelGG 15y agoNo, it just makes things worse. If people are going to follow the spec, they should follow it and reject bad input. Otherwise, you get a mess of code that tries to guess at what to do. This leads to inconsistencies, possibly security bugs. Imagine if invalid HTML had been flat-out rejected by browsers since the beginning. Cross-browser compat would be, at least, somewhat easier due to less bad HTML surviving in the wild, since it simply would not have worked. In XML, for instance, I've never heard of the need to deal with invalidly formatted messages. There's enough problems interpreting semantics, why do folks want to add syntax to the problem, too?
- MichaelGG 15y agoNo, it just makes things worse. If people are going to follow the spec, they should follow it and reject bad input. Otherwise, you get a mess of code that tries to guess at what to do. This leads to inconsistencies, possibly security bugs. Imagine if invalid HTML had been flat-out rejected by browsers since the beginning. Cross-browser compat would be, at least, somewhat easier due to less bad HTML surviving in the wild, since it simply would not have worked. In XML, for instance, I've never heard of the need to deal with invalidly formatted messages. There's enough problems interpreting semantics, why do folks want to add syntax to the problem, too?