Live data from Hacker News

Bootstrap's maintainer hates the semicolon

github.com

71–80 of 137 posts

Re: Bootstrap's maintainer hates the semicolon

#71
post #9

He wrote a blog post about this a while ago, I don't really get his reasoning but I guess he's happy with his decisions: http://www.wordsbyf.at/2011/10/31/i-dont-write-javascript/

This is utterly stupid. And the example he cites for why he prefers an odd function syntax doesn't cause errors..... if you use semicolons . JavaScript interpreters insert semicolons. If you abuse this, you'll end up with unpredictable results like his function example.

The results aren't unpredictable - they're specified exactly, which makes it safe to omit semicolons except where necessary.

You might not know that the return statement is a restricted production, but you do know when you shouldn't immediately follow it with a linebreak.

Similarly, if you see a line beginning with ( or [ which isn't a continuation of the statement on the previous line, stick a semicolon in front of it, or in the case of a wrapped function() {}, use one of the other means of telling the parser it's a function expression. There are other restricted productions, but you just solved every non return-followed-by-linebreak ASI issue I've ever seen in the wild.

Re: Bootstrap's maintainer hates the semicolon

#72
post #31
post #4

Thanks for drawing my attention to this. Currently, I maintain a separate branch simply for adding the missing semicolons so that I can link the individual bootstrap files with my project. It's been quite annoying and I now know that the annoyance may not go away anytime soon. I hate these ideologues. But this is the trouble with JS I guess. I actually love javascript because of the highly dynamic nature of it. But t…

> I don't know of any other language where people can CHOOSE to follow syntax. Your argument is incorrect. :) Omitting semicolons is perfectly valid and correct syntax. The spec is explicit about it being allowed and how the code shall be interpreted: http://es5.github.com/ It may be a good rule of thumb to use the semicolons, because you have to be careful without them, but in the end it's a choice based on team pre…

> If you are a very pertinent and careful type of person, and you don't have any rabid illiterates on your team, going without semicolons makes perfect sense.

Why does it make perfect sense? There's nothing wrong with including them, and I find it reduces the amount of thinking you need to do. JavaScript has C-like syntax; it should end its lines with semicolons and it's a mistake that it doesn't always require them.

Re: Bootstrap's maintainer hates the semicolon

#73
post #4

Thanks for drawing my attention to this. Currently, I maintain a separate branch simply for adding the missing semicolons so that I can link the individual bootstrap files with my project. It's been quite annoying and I now know that the annoyance may not go away anytime soon. I hate these ideologues. But this is the trouble with JS I guess. I actually love javascript because of the highly dynamic nature of it. But t…

> I don't know of any other language where people can CHOOSE to follow syntax.

You should check out Lisp macros ;)

Re: Bootstrap's maintainer hates the semicolon

#74
post #34

Check out the following issue, not just the matter of style.. https://github.com/twitter/bootstrap/issues/401

The reply seems immature from the perspective of project maintenance.

That seemed to be a trend in this project, that we briefly overcame: https://github.com/twitter/bootstrap/pull/266

Re: Bootstrap's maintainer hates the semicolon

#75
post #9

He wrote a blog post about this a while ago, I don't really get his reasoning but I guess he's happy with his decisions: http://www.wordsbyf.at/2011/10/31/i-dont-write-javascript/

Replying to myself because I decided I have more to say:

Imagine if a coder wrote a big huffy blog post declaring that he was only going to use single-character variables everywhere because it was more "minimalist" than using descriptive variables. He'd be hanged.

Obviously what "fat" is deciding to do with semicolons is less annoying than the strawman I just made up, but I don't think it's entirely dissimilar. The Javascript spec doesn't say that you must use descriptive variables, and using single character variables is certainly valid. However, it's an established convention that we just don't do that, because people find it irritating.

Basically this just comes down to "plays well with others".

Re: Bootstrap's maintainer hates the semicolon

#77

I wouldn't see any significant problem with a policy of omitting semi-colons when there's no risk of ambiguity, but turning the omission of semi-colons into a religion? That's enough to make me question what other nutty peculiarities exist in his coding philosophy, and therefore whether I'd dare risk my own projects using his library.

It's just embracing the ASI. Nothing wrong with it. On the contrary, the understanding necessary to use it implies good knowledge of the language.

Re: Bootstrap's maintainer hates the semicolon

#78
post #17
post #9

He wrote a blog post about this a while ago, I don't really get his reasoning but I guess he's happy with his decisions: http://www.wordsbyf.at/2011/10/31/i-dont-write-javascript/

This blog post accurately states the broken idea: > Each is perfectly valid. Each behaves the same. It’s just a matter of preference and finding the style that makes most sense to you. Part of being a good steward to a successful project is realizing that writing code for yourself is a Bad Idea™. If thousands of people are using your code, then write your code for maximum clarity, not your personal preference of how…

Leaving semi-colons out is not clever, it's just understanding where you need them instead of shooting blindly.

Re: Bootstrap's maintainer hates the semicolon

#79
post #9

He wrote a blog post about this a while ago, I don't really get his reasoning but I guess he's happy with his decisions: http://www.wordsbyf.at/2011/10/31/i-dont-write-javascript/

And possibly some reasons why leaving semicolons off can make his or others' lives a bit annoying: http://bonsaiden.github.com/JavaScript-Garden/#core.semicolo...

That's a part of JS Garden I don't agree with. Leaving semi-colons only changes behaviour if your code is wrong in the first place...

Re: Bootstrap's maintainer hates the semicolon

#80

Earlier quoted context omitted.

Maybe this kind of reasoning explains why their API is such garbage.

I agree. As some-one who has just finished with a large-ish project using bootstrap, I can say that one of the worst parts of it is its js api.

Can you unpack that? At a glance, it looks okay, but I haven't actually done anything with the JS API yet.
Post reply on HN