Live data from Hacker News

Brendan Eich: The infernal semicolon

brendaneich.com

71–80 of 143 posts

Re: Brendan Eich: The infernal semicolon

#71
post #38

The key point: "ASI [“Automatic Semicolon Insertion”] is an error correction procedure. If you start to code as if it were a universal significant-newline rule, you will get into trouble."—Brendan Eich

I think the other thing that goes unmentioned is that a single semi-colon on a line in a file would pretty much end this debate. Perhaps I've worked too much in teams, but surely "path of least resistance" has to factor some , right? I mean, if the choice is add a semi-colon to a line in a file versus asking somebody else to rewrite the compiler to be able to accept it, surely common sense would just be to add the se…

No.

Sure it is the easier solution right now. But in the long run that would mean the Crockford would be able to dictate the style of Javascript to whatever the hell he wants.

Given how important Javascript is now (and will be in the future) we cannot allow any one person to retard the entire future.

Anyway use Googles closure compiler -- it can actually handle Javascript.

Re: Brendan Eich: The infernal semicolon

#72
post #64

The eternal fires of high level bike shedding: semi-colons, whitespace and curly braces, no programming discussion or language can escape all three. Be liberal in what you accept and conservative in what you send (i.e. just use semi-colons) and your systems will work and play well with others being interoperable.

well JavaScript was liberal in accepting statements separated by newlines and look what happened

True, but that is a language, products and implementations sometimes need to be more this way since they are the front lines/interface/api. Even falling back on broken standards or less clean implementations (url over version header on restful apis for one example) to work in some cases where absolutely needed but make it harder to do so.

Shipped software should try to work or be usable in the shipped format, get funky behind the product layer if you want.

Here the minified javascript that everyone uses, should just work with the current infrastructure. If it doesn't, provide the tool that fixes the problems for people to ship with.

Re: Brendan Eich: The infernal semicolon

#73

This whole argument is silly (the semicolon in JS argument, not this post itself). JavaScript was built for semicolon use, use them. If you don't want to use semicolons then at least make sure you aren't breaking major libraries that are in mass use. If it does break something many people use then work with the creator to fix it. If he refuses to fix it then ignore everyone using these libraries, provide a weird work…

Jsmin is broken if it can't handle missing semicolons.

Googles closure tools actually do parse the Javascript and can properly minify them better.

Re: Brendan Eich: The infernal semicolon

#74
post #33

Heh, I was waiting for this post. Coming in the next 24 hours: - "Why I use minimal semi-colons in Javascript" - "ASI is broken but I like it" Honestly I'm shocked at the defense of this practice (of ASI "abusage"). It speaks loudly to Jacob's (fat@githib) ranking of ego-stroking and showboating over creating readable code, particularly for a library "Designed for everyone, everywhere" [1]. I'm confounded that such a…

I really don't understand how a particular usage of semicolons and logical operators is indicative of ego-stroking, showboating, and "hipster", as if the word hipster even means anything at all. If fat _said_ something to make you use those words then that would make sense, but as it is I'm very confused.

Simple. Look at the other comments, and it becomes apparent there are downsides to relying on / abusing ASI, and no advantages. (The only claimed advantage is that the lack of semicolons is visually appealing, but this is nullified by the fact the rules are sort of confusing and not apparent to all contributors.)

Thus people are inferring this fat fellow is doing it only out of illogical, ego-based personal preference, because nothing else makes sense.

I’m not saying they are right — I couldn’t possibly know — but given the facts, it’s a reasonable assumption.

Re: Brendan Eich: The infernal semicolon

#75
post #71
post #38

Earlier quoted context omitted.

I think the other thing that goes unmentioned is that a single semi-colon on a line in a file would pretty much end this debate. Perhaps I've worked too much in teams, but surely "path of least resistance" has to factor some , right? I mean, if the choice is add a semi-colon to a line in a file versus asking somebody else to rewrite the compiler to be able to accept it, surely common sense would just be to add the se…

No. Sure it is the easier solution right now. But in the long run that would mean the Crockford would be able to dictate the style of Javascript to whatever the hell he wants. Given how important Javascript is now (and will be in the future) we cannot allow any one person to retard the entire future. Anyway use Googles closure compiler -- it can actually handle Javascript.

I think that's a visceral reaction based on his rudeness.

So long as he keeps building tools and utilities that people rely on, and that people use, he is at least influencing the direction of Javascript and, knowing that, I'd think one might take heed when Crockford says "this will break in the future", as he happens to have more insight into the language than most.

I understand that he wasn't polite, and I certainly understand the desire for the 'asshole' to be proven wrong. And maybe he is. Of course, that doesn't make him wrong, and it doesn't mean that he's "retarding the future" either, necessarily.

But the fact that jsmin is perhaps the most widely deployed JS minification utility does matter, whether anyone chooses to accept it or not.

And if you really think that he is retarding the future, the correct answer probably isn't to bicker about it on the internet, but to create a better compiler (or work on getting a better compiler accepted) as de facto.

At the end of the day though, Fat is the guy who has to deal with all the tickets talking about 'This doesn't compile in jsmin', and I'd think his life would ultimately be better off if he just added a semi-colon.

Of course, that's my opinion only, so take it for what it's worth.

Re: Brendan Eich: The infernal semicolon

#76
post #29
post #16

Earlier quoted context omitted.

You haven't been around for long enough or just aren'y cynical enough, I went to bed knowing that there would be at least 5 more posts about it in the morning

If it's anything like the "Email is dead" one, we've got some more coming. We need at least two arguing for Crockford (one with a liberal amount of "hipster" name-calling), someone arguing for @fat, and @fat eventually explaining himself (because it would be a cold day at Oracle before Doug Crockford said anything other than "you suck").

If I see people errantly slinging around "hipster" for any reason, let alone to pettily attack people who prefer a certain style, well, I'm going to be even more annoyed than seeing more god damned "email is(n't) (the best thing/going to screw your mother)" posts.

Re: Brendan Eich: The infernal semicolon

#77
post #14

Earlier quoted context omitted.

"Here is your new apartment. You must use a key to enter it. If you forget your key, you can buzz the superintendent during business hours, and if the super is home, (s)he will open the door for you.” If you try to take your key with you at all times, the super will save your bacon once in a blue moon when you forget your key. On the other hand, if you think of the door as only needing a key when you wish to have it…

That's a great analogy.

That's a terrible analogy. What's the analog for receiving a syntax error instead when you "forget your keys"? The analogy gives you bizarre and wrong choices and tradeoffs.

As usual, analogies do more harm than good, especially when understanding a relatively simple technical issue.

Re: Brendan Eich: The infernal semicolon

#78
post #40

Earlier quoted context omitted.

The difference is that if you forget your key, you know that you forgot your key, and you have to actively call the superintendent to have them "save your bacon." With ASI, you might never know that you had forgotten your key.

I agree that it would be nice to have something like "-Wall" that could warn you that you're doing things the "wrong way" but, uh, isn't that what JSLint is?

[deleted]

Re: Brendan Eich: The infernal semicolon

#79
post #75
post #71

Earlier quoted context omitted.

No. Sure it is the easier solution right now. But in the long run that would mean the Crockford would be able to dictate the style of Javascript to whatever the hell he wants. Given how important Javascript is now (and will be in the future) we cannot allow any one person to retard the entire future. Anyway use Googles closure compiler -- it can actually handle Javascript.

I think that's a visceral reaction based on his rudeness. So long as he keeps building tools and utilities that people rely on, and that people use, he is at least influencing the direction of Javascript and, knowing that, I'd think one might take heed when Crockford says "this will break in the future", as he happens to have more insight into the language than most. I understand that he wasn't polite, and I certainl…

But of course, we won't break existing code like those two lines from Bootstrap in the future (not per the promises/concurrency strawman, anyway). This was a point my blog took pains to make.

Doug may have forgotten the [no LineTerminator here] restriction, or he may not want it to the left of infix-! for promises, but I am certain that the whole of TC39 will not agree to such a breaking change.

Re: Brendan Eich: The infernal semicolon

#80
post #42

Is it me, or did the author tack on a new topic regarding the use of && and ||? The fact that they return the controlling operand is quite useful. Consider a situation where you want to check the property of an object, but don't know if that object is null: var foo = obj && obj.bar; I find this much more readable than: var foo = null; if (obj) { foo = obj.bar; } You can accomplish the same thing with a ternary operat…

[] as evaluated (an array literal) is truthy not falsy. Are you thinking of a context in which it is implicitly coerced to string?
Post reply on HN