Live data from Hacker News

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

github.com

151–160 of 224 posts

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

#151
post #132

I am not experienced with javascript, so I don't understand this argument. Can someone please confirm the following, or explain what's going on? Here is what I understand: 1. Javascript will add a phantom semicolon at the end of each line if it seems like you need it, for some definition of seems like. To me, it sounds like this is so that new HTML writers in '98 wouldn't see their pages blow up when they forgot a se…

For point 3, it might be worthwhile understanding what the ECMA standard says about automatic semi-colon insertion. It won't happen for the following:

  a = b
  ++c
This becomes:

  a = b;
  ++c;
and NOT:

  a = b++;
  c;
There are other, odd gotcha's, but this is the one being discussed.

I believe the issue with the bang (!) operator is that it's being considered as a binding de-reference of function objects. See here: https://mail.mozilla.org/pipermail/es-discuss/2010-July/0114...

Therefore, the problem with the code would be that an automatic semi-colon would not be inserted and the code, which is currently:

  clearMenus()
  !isActive && $parent.toggleClass('open')
Would become:

  clearMenus()!isActive && $parent.toggleClass('open');
Instead of:

  clearMenus();
  !isActive && $parent.toggleClass('open');
That was my understanding, at any rate.

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

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

While whether or not to use them when designing a language is bikeshedding, JavaScript already has so pitfalls caused by semicolon insertion, their use is a must.

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

#153
It is hard for me to understand how one could make so many things in a programming language completely arbitrary - I mean it is natural for a language designer to have some vision of how the language will be used by other people, how will the common structure of the programs look like, but JavaScript looks like such a vision never existed, there are often several ways of doing the most basic things (writing vs. omitting semicolons mentioned here, writing vs. omitting "var", but above all else 1000 of ways of doing OO, all with it's own problems) and no easy ways at all of doing other very basic things (modules/namespacing). As a result you can find 10 or 20 programs written in JavaScript where each looks like it was written in a quite different language. Maybe it was an attempt to make an "easy" language for non-programmers (I doubt even this goal was in the end achieved), but as a primary language for programming client-side applications it is a utter disappointment. Not that I necessarily blame the JavaScript creator, I am sure there were plenty of corporate pressures involved and other factors of corporate/economic nature.

I wish we could get some other programming language implemented in all the major browsers, then at least in the perspective of the next 10 years we could completely get rid of JavaScript, I am not sure if it possible to really improve the situation in a radical way just via incremental changes to the existing design.

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

#155
post #64

Earlier quoted context omitted.

This is great, thanks. The only logical conclusion is that engineers should be choosing tools that have the least syntactical surface area to argue over. :)

Assembler? ;)

Brainfk, clearly.

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

#156
The use of semicolon as best practice was sorted out years ago in the js community. Crockford has all his rights to tell these guys to sharpen up because that "fat" character is obviously a python smuch with no knowledge of JS history or respect for elders.

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

#158
post #132

I am not experienced with javascript, so I don't understand this argument. Can someone please confirm the following, or explain what's going on? Here is what I understand: 1. Javascript will add a phantom semicolon at the end of each line if it seems like you need it, for some definition of seems like. To me, it sounds like this is so that new HTML writers in '98 wouldn't see their pages blow up when they forgot a se…

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

That is a pretty good rundown of the rules. The only problem with not having semicolons is cases like this, where someone is using a bad tool to minify your code. None of the tools that currently do the best job will break on that code.

Post reply on HN