Live data from Hacker News

Bootstrap's maintainer hates the semicolon

github.com

81–90 of 137 posts

Re: Bootstrap's maintainer hates the semicolon

#82
post #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 J…

I have to wonder if this is just some invented crisis so this guy can place himself into the tradition of the byte-counting olden days.

Re: Bootstrap's maintainer hates the semicolon

#83

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.

And is therefore more expensive to maintain.

Re: Bootstrap's maintainer hates the semicolon

#84
Not having to use semicolons sounds nice, but in practice it can have terrible effects. E.g.:

  var x = function() {
    // something
  }
  
  // avoid polluting global scope:
  (function() {
    // Some initialization.
  })()
This will call the function x with the anonymous function as its argument, and then call the result of that.

There are more examples to that point, and many of them really aren't all that straightforward. So don't rely on automatic semicolons.

Re: Bootstrap's maintainer hates the semicolon

#85
post #17

Earlier quoted context omitted.

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.

Does it hurt to have extra semi-colons? Maybe you have some empty statements. Does it hurt to have too few? Well, if you either do not know what you're doing, or someone maintaining doesn't understand what you did, etc., then yes.

Re: Bootstrap's maintainer hates the semicolon

#87
post #6

I don't get what the issue is. I run bootstrap js through the closure compiler (with minification and optimization) and it works just fine. I don't agree with the policy myself, I prefer semicolon, but I also prefer CoffeeScript. That said, if Fat wants to remove it, that is his choice, leave him alone. Update: Just read his blog posting. If Fat really wanted the minimalist approach, he'd use coffeescript and then pe…

I don't get what the issue is either. Are we forgetting that Bootstrap is free and open source?

Nobody's forcing anyone to use Bootstrap nor is anyone prevented from creating their own Bootstrap fork with semicolons.

Clearly, no good deed goes unpunished.

Re: Bootstrap's maintainer hates the semicolon

#88
post #84

Not having to use semicolons sounds nice, but in practice it can have terrible effects. E.g.: var x = function() { // something } // avoid polluting global scope: (function() { // Some initialization. })() This will call the function x with the anonymous function as its argument, and then call the result of that. There are more examples to that point, and many of them really aren't all that straightforward. So don't…

You can write this without any problem:

  var x = function() {
    // something
  }

  // avoid polluting global scope:
  !function() {
    // Some initialization.
  }()

Re: Bootstrap's maintainer hates the semicolon

#89
post #88
post #84

Not having to use semicolons sounds nice, but in practice it can have terrible effects. E.g.: var x = function() { // something } // avoid polluting global scope: (function() { // Some initialization. })() This will call the function x with the anonymous function as its argument, and then call the result of that. There are more examples to that point, and many of them really aren't all that straightforward. So don't…

You can write this without any problem: var x = function() { // something } // avoid polluting global scope: !function() { // Some initialization. }()

So now you've gone from a semicolon, which has the sole purpose of separating statements; to a bang, which doesn't make any sense in this context unless you know that it's replacing a semicolon.

Better or worse?

Re: Bootstrap's maintainer hates the semicolon

#90
post #89
post #88

Earlier quoted context omitted.

You can write this without any problem: var x = function() { // something } // avoid polluting global scope: !function() { // Some initialization. }()

So now you've gone from a semicolon, which has the sole purpose of separating statements; to a bang, which doesn't make any sense in this context unless you know that it's replacing a semicolon. Better or worse?

You could use anything which separates statements or ensures the function is treated as an expression. Two examples which are more in keeping with the intended use of the operators in question:

  ;function() {
    // Some initialization.
  }()

  void function() {
    // Some initialization.
  }()
Post reply on HN