Live data from Hacker News

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

github.com

21–30 of 224 posts

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

#21
post #11

For a good explanation of why it's a good idea to always use semicolons in your JavaScript, take a look at: http://lucumr.pocoo.org/2011/2/6/automatic-semicolon-inserti...

The examples he gives are exactly the situations where you should use semi-colons, as understood by those who skip them. Take a look at http://blog.izs.me/post/2353458699/an-open-letter-to-javascr...

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

#23
post #17

Earlier quoted context omitted.

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

Same reason people don't use semi-colons in Python, I imagine. Besides, I'm not willing to acknowledge any reasons for using semi-colons as significant. And without any significant reasons for it, I may as well not use them. Besides, it makes the code prettier :).

I always think of using semicolons like using parentheses when doing math in code. It makes the order of operations explicit rather than implied. For example,

    1 + 2 * 3
Solves to 7, obviously. But I'll write it in code like this:

    1 + (2 * 3)
Just to make it clear that I know what I mean, and I mean do the operations in _this_ order.

Similarly, using semicolons to end lines means I am saying loud and clear... this line of code ends HERE.

Obviousness is a good thing, no?

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

#24

Earlier quoted context omitted.

Is there any particular reason why you refuse to put in the semicolons in Javascript?

There's a whole hipster movement going on right now around the idea of omitting semicolons from JavaScript code. I believe CoffeeScript is the culprit. Personally, I agree with Crockford -- it's dumb.

Meh, the real hipsters are just pushing comma-first.

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

#25

Earlier quoted context omitted.

Is there any particular reason why you refuse to put in the semicolons in Javascript?

There's a whole hipster movement going on right now around the idea of omitting semicolons from JavaScript code. I believe CoffeeScript is the culprit. Personally, I agree with Crockford -- it's dumb.

[deleted]

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

#27
post #20
post #12

Earlier quoted context omitted.

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 level to contribute That's insane. Good programmers need not know stupid tiny nits about Javascript (heck, I've worked on a Javascript JIT and I don't really know Javascript). That does not mean that they are not skilled. > aesthetic I don't understand how "you must carefully understand how the language parses to understand this line of code" is aesthetically pleasing when compared to unambiguity.…

Sure the "raising the skill level" bit is just trolling. Omitting semi-colons is about removing ambiguity, and making it easier to spot inconsistencies. As a bonus, code looks cleaner.

In this case, the minifier is breaking the code, regardless.

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

#28

Crockford's stance is annoying purely because it's pedantic and because there are many libraries that embrace this style. We use django_compressor and found bugs from the compressor that uses Jsmin. So I have to use something else to compress them before hand. Are there compressors that use the syntax tree rather than transforming the source?

Is there any particular reason why you refuse to put in the semicolons in Javascript?

http://blog.izs.me/post/2353458699/an-open-letter-to-javascr...

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

#30
post #16

> ! is not intended to be a statement separator. ; is. Which is why there is a line break there. He's far too stubborn to realize that JSMin is at fault for not being able to correctly parse JavaScript.

The line break will not help if ! becomes an infix operator.
Post reply on HN