Live data from Hacker News

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

github.com

101–110 of 224 posts

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

#101

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

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

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

#102
post #98
post #85

Earlier quoted context omitted.

[deleted]

> But... surely that code is far more "insanely stupid[-looking]" than the first...? I don't think anyone is arguing that x\n!p is a good way to write code. Crockford is pointing out that ASI will not occur when ! is an infix operator.

[deleted]

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

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

I have never written a line of JS in my life, which hopefully qualifies me as an unbiased outsider, but I don't agree that that Crockford's position here on JSMin is the right thing to do.

Here is what I see:

@fat is not inserting "!" needlessly as a statement separator. The "!" is there for its proper purpose, as a "unary not" operation, which will short circuit the second operand of the "&&" when isActive is false.

Given that, @fat has left out a semicolon in a way that is perfectly legitimate based on this language specification, at least as described in the 5.1 version linked from here: http://inimino.org/~inimino/blog/javascript_semicolons).

Could @fat have written the code differently so that he would have been required to include the ";"? Perhaps -- but I don't see why that counterfactual has any particular bearing here.

Crockford's own page on JSMin http://www.crockford.com/javascript/jsmin.html> claims: "JSMin is a filter that omits or modifies some characters. This does not change the behavior of the program that it is minifying."

The fact is that @fat's code is legal code and JSMin is breaking it.

IMHO, Crockford is ignoring the technical matters at hand. @fat cannot be faulted for writing code that complies with the specification and for having a reasonable expectation that code minimizers will preserve the semantics of his legal code. Crockford (and others) may wish that the language specification did not include automatic semicolon insertion because it does hamper making changes in the language without breaking existing code -- but that does not make this piece of code "insanely stupid".

Yes, forward progress on the language would be better served if automatic semicolon insertion rules weren't in the specification. However, calling one particular piece of code that leverages those rules "insanely stupid" and refusing to acknowledge that JSMin is in fact breaking the semantics of the code is not productive. Refusing to fix this in JSMin does not somehow make the problem with the specification to go away.

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

#104
post #61

Earlier quoted context omitted.

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…

My point wasn't that arguments are avoidable altogether. It was simply that one would hope the arguments would evolve in complexity or at the very least change in specifics. Since that doesn't seem to be happening, and the same old tired topics keep coming up, I think it's important that designers of future software engineering tools consider how immune their systems are to the grab bag of arguments we've been hearin…

We already have something akin to that - Python (PEP 8 specifically). People still find things to argue about though, presumably because they enjoy it. On the upside, it happens less often!

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

#105
post #59

Example when a semicolon is required in non-minimized javascript. alert(1) // add semi-colon here to make this code work (function(){alert(2)})()

Someone should write a tool that automatically inserts that comment instead of a semicolon. LOL

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

#106
post #99
post #88

Earlier quoted context omitted.

[deleted]

No, we should not. We should look at principles, because principles are what guide us on judging specifics. If you don't understand why I take this approach, you will never understand my position.

[deleted]

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

#107

I think the stupidity here is entirely isolated to using JSMin.

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

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

#109
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 found the whole discussion quite sad, the stupid animated GIFs in particular. I became even more sad when I noticed the discussion is being held on GitHub, not Reddit or 4chan.

Scrolled through, won't participate. I'd much rather build interesting application.

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

#110

Earlier quoted context omitted.

! is already being discussed to be turned into an infix operator in a future version of JavaScript.

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

I shall wait until the future to write any more JavaScript.
Post reply on HN