Live data from Hacker News

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

github.com

51–60 of 224 posts

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

#51

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.

I think the usual semi-colon-less style is to put a semi-colon in front of lines beginning with parentheses (and only those lines). This is the one potential problem area if you don't have semi-colons everywhere, so you can avoid almost all (or maybe actually all) problems just by prepending a semi-colon to those lines.

I think Ricardo's point is that this style (having a semi-colon only before parentheses at the beginning of the line) makes your intentions more explicit.

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

#52

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”

#53

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…

This is a silly example because it's so simple. E.g. You can just write 2*3+1, which is easier to read. Regardless, I'd wonder why you put the parenthesis there, as if it were some odd hack or workaround for some obscure bug.

Sure, it's a simple example. How about:

    destPoint.x + offset.x * diameter
vs

    destPoint.x + (offset.x * diameter)
The longer the variable names the harder it is to visually parse the order of operations. At least for my brain.

This whole thread is arguing about style, IMO. I'm just offering my explanation why this style makes more sense to me.

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

#54
post #51

Earlier quoted context omitted.

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.

I think the usual semi-colon-less style is to put a semi-colon in front of lines beginning with parentheses (and only those lines). This is the one potential problem area if you don't have semi-colons everywhere, so you can avoid almost all (or maybe actually all) problems just by prepending a semi-colon to those lines. I think Ricardo's point is that this style (having a semi-colon only before parentheses at the beg…

The full list is [(+*/-. (basically parenthesis, array/property acessor, and any math)

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

#55
post #39
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…

... 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 s…

I wasn't literally asking why is this happening. I was pointing out that it's sad that we live in a world where someone like Crockford is spending brain cycles talking about semicolons, regardless of the reason.

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

#56
post #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, bu…

Semi-colons aside, you never earn the right to be an ass.

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

#60

Earlier quoted context omitted.

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

Because standard-compliant JavaScript implementations don't require them (ECMAScript describes a model of "semicolon insertion" that implementors are supposed to follow).

Not required doesn't necessarily mean it's a good idea.

If they were never needed I'd understand, but sometimes they are. I don't see the point in forcing the developer to make a conscious decision on whether to include a semicolon.

Omitting semicolons also means that the correctness of a line of code is determined by the unrelated lines that follow.

Post reply on HN