Live data from Hacker News

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

github.com

131–140 of 224 posts

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

#131
Excellent - 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".

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

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

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

#133
That'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/javascript... [2] https://github.com/styleguide/javascript

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

#135
post #12

Earlier quoted context omitted.

Why the hell people are refusing to use semicolons? I don't get it

I'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).

[deleted]

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

#136
post #12

Earlier quoted context omitted.

Why the hell people are refusing to use semicolons? I don't get it

I'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).

> raising the skill requirement to contribute (you have to know JS better than average to never use a semicolon, and do so correctly)

Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ~Martin Fowler

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

#137
post #55
post #39

Earlier quoted context omitted.

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

In the big picture, I agree that everything about the GitHub thread, meta or not, is terrible.

But any author of a language minification library will have to deal with corner cases. I see no easy way out. Would it be better for Crockford not to have started writing JSMin?

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

#138
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”

#140
post #64

Earlier quoted context omitted.

Why? This unfortunate behavior is well described by Wadler's Law: http://www.haskell.org/haskellwiki/Wadlers_Law

This is great, thanks. The only logical conclusion is that engineers should be choosing tools that have the least syntactical surface area to argue over. :)

Berners Lee's 'principle of least power'?
Post reply on HN