Live data from Hacker News

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

github.com

31–40 of 224 posts

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

#31
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…

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 of intent:

    var value = x + fn
    ;(y).burp()
It's about removing ambiguity and visual clutter with a simple set of rules.

How many JS programmers know the difference between a function expression or declaration, and the semi-colon that should follow or not? You're dependent on a linter. Following the no-semi-colon rules makes your intentions clear in every case, without machine validation.

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

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

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

#37
post #20

Earlier quoted context omitted.

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

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-the-semicolons position is absurdly immature hipster posturing that serves no engineering purpose.

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

#38
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…

[deleted]

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

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

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

#40
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…

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.
Post reply on HN