Live data from Hacker News

Crockford on Bootstrap's semicolon omission: “insanely stupid code”

github.com

41–50 of 224 posts

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#41

Earlier quoted context omitted.

Is there any particular reason why you refuse to put in the semicolons in Javascript?

There'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.

Kind 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.

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#43
post #33

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? 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…

Whatever the next disruption is in software engineering, please dear God let it be immune-by-design to this type of distraction.

While your sentiment is positive, wouldn't this mean either designing things in a rigid, unambiguous manner (think C's semicolons) or changing human nature? Ambiguous choices plus human nature equals debates. An argument about semicolons does seem silly and your proposed outcome sounds nice, but how could we get there?

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#44
post #17

Earlier quoted context omitted.

Same reason people don't use semi-colons in Python, I imagine. Besides, I'm not willing to acknowledge any reasons for using semi-colons as significant. And without any significant reasons for it, I may as well not use them. Besides, it makes the code prettier :).

I always think of using semicolons like using parentheses when doing math in code. It makes the order of operations explicit rather than implied. For example, 1 + 2 * 3 Solves to 7, obviously. But I'll write it in code like this: 1 + (2 * 3) Just to make it clear that I know what I mean, and I mean do the operations in _this_ order. Similarly, using semicolons to end lines means I am saying loud and clear... this lin…

Amusingly, I agree with your premise but not really your conclusion. Adding a semi-colon is like adding parentheses. But I think redundant parentheses add visual clutter--unless I have a very complicated expression, I leave them off. (Maybe it's the Haskell code style rubbing off on me...)

So I actually think that 1 + 2 * 3 is better than 1 + (2 * 3). I usually find reading a line with less stuff easier, so I prefer the shorter between two equivalent expression.

Besides, adding a semi-colon is more like surrounding the whole expression with parentheses rather than just grouping. And you would never write (1 + (2 * 3)). And yet that also says, loud and clear, the same thing!

I've used some languages with optional semi-colons--Python and Haskell, for example. I've never thought that missing them made the code less readable--it's always been the opposite. Going back to Java and having to use semi-colons everywhere becomes increasing annoying as I grow more acclimated to languages without.

In short, I see where you're coming from but don't really agree.

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#45

Earlier quoted context omitted.

I always think of using semicolons like using parentheses when doing math in code. It makes the order of operations explicit rather than implied. For example, 1 + 2 * 3 Solves to 7, obviously. But I'll write it in code like this: 1 + (2 * 3) Just to make it clear that I know what I mean, and I mean do the operations in _this_ order. Similarly, using semicolons to end lines means I am saying loud and clear... this lin…

So in this case: var value = x + fn (y).burp() Is it obvious that there is a missing semi-colon at the end of line 1? The code is technically correct without it (not that I approve of it). You can assume it's wrong, but it's just a guess. If your code is in no-semi-colon style, there is no ambiguity, you can be 100% sure that this is a mistake: there always should be a semi-colon guarding that parenthesis, regardless…

I don't follow this argument. Putting a semicolon at the end of every statement, regardless of what follows, seems to be an even easier way to avoid making this bug.

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#46

Earlier quoted context omitted.

Sure the "raising the skill level" bit is just trolling. Omitting semi-colons is about removing ambiguity, and making it easier to spot inconsistencies. As a bonus, code looks cleaner. In this case, the minifier is breaking the code, regardless.

Can you parse this expression without parentheses? a && b && c || d || e + f > g && h The parser sure can. Do you have all the operator precedences memorized, or do you use superfluous parentheses because you're not always sure? It's true that the semicolon is not needed, and it's true that the minifier is breaking code. It may even be true that Crockford should fix it. But that doesn't change the fact that the omit-…

[deleted]

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#47
post #33

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? 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…

Why?

This unfortunate behavior is well described by Wadler's Law:

http://www.haskell.org/haskellwiki/Wadlers_Law

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#48

Earlier quoted context omitted.

So in this case: var value = x + fn (y).burp() Is it obvious that there is a missing semi-colon at the end of line 1? The code is technically correct without it (not that I approve of it). You can assume it's wrong, but it's just a guess. If your code is in no-semi-colon style, there is no ambiguity, you can be 100% sure that this is a mistake: there always should be a semi-colon guarding that parenthesis, regardless…

I don't follow this argument. Putting a semicolon at the end of every statement, regardless of what follows, seems to be an even easier way to avoid making this bug.

[deleted]

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#49
post #33

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? 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…

Jacob ("fat") comes off looking far worse than Crockford, to my eyes (and that Kit character seems to be 7 years old). It's the arrogance and stupidity of youth facing the crotchety crankiness of experience. Crockford has earned the right to have a strong opinion here IMO.

But it's not just bike-shedding. It's more pernicious than that. It's actually something that looks like bike-shedding to uninformed observers, but something that strongly affects cross-version compatibility. Javascript does automatic semicolon insertion by taking advantage of potentially ambiguous constructs that happen to be resolved in one way right now. But they may be actually ambiguous in the future - in the case where a unary prefix operator becomes a binary operator. Language extension usually works this way: a previously unambiguously wrong statement is made valid; but JS semicolon insertion often turns "wrong" statements into "correct" statements, so it leaves less "entropy" to be taken advantage of when increasing the power of the syntax. I think there's a strong case for JS to not insert semicolons here, and I agree with Crockford's position on not handling it in JSMin. It's the right thing to do.

Re: Crockford on Bootstrap's semicolon omission: “insanely stupid code”

#50
post #33

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? 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…

I would hardly call this an "argument" from Crockford. There is absolutely no back-and-forth. Crockford is told there is a bug (or perhaps, a missing feature) in his software. Crockford responds that he will not change his code, and that the first guy's code is bad. Other commenters then begin arguing, but Crockford does not.
Post reply on HN