Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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?


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.


Kind of funny that you say this, since CoffeeScript inserts semicolons.

The lack of semicolons is the one major thing in the Github style guide that I think is stupid. It seems silly to avoid using semicolons in Javascript because it actually takes a little bit more effort than just using them.


On my team we've decided to use semi-colons in JavaScript for this exact reason: It would actually take more effort to stop using them as our other major language is PHP. More effort for no benefit is pointless.


> I believe CoffeeScript is the culprit.

CoffeeScript removes semicolons from CoffeeScript, not JavaScript.


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


They're all hipsters.


Hey everyone, I've just learned to drive without wearing a seatbelt. It's possible! The laws of physics allow it!


Driving without a seatbelt would be perfectly reasonable if I had a written list of all possible accidents to drive around. The twist here is that the one and only grammar change that could break this code may actually happen soon. Until then, though, the code is valid and Crockford is intentionally leaving a bug in jsmin.


Because standard-compliant JavaScript implementations don't require them (ECMAScript describes a model of "semicolon insertion" that implementors are supposed to follow).


Not required doesn't necessarily mean it's a good idea.

If they were never needed I'd understand, but sometimes they are. I don't see the point in forcing the developer to make a conscious decision on whether to include a semicolon.

Omitting semicolons also means that the correctness of a line of code is determined by the unrelated lines that follow.


While the virtues of semicolon insertion are highly debatable, developers are permitted by the ECMAScript standard to write code that relies on it. A tool like JSMin should be aware of semicolon insertion. ricardobeat put it very well elsewhere in this thread: "It is a bug on JSMin. Minifying should never alter code behaviour."


Actually JSMin is aware of semicolon insertion and handles it correctly.

They just disagree on whether a semicolon gets inserted here.


Unfortunately for JSMin, browsers attempt to implement at least the ECMAScript specification, not just "the good parts."



in vim pressing A lets me change things at the end of the line, and semicolons get in the way of that


Like I said, there are many, many libraries that don't use them.

I used to prefer having semicolons in my javascript, then I started writing a bunch of Go. Now I wind up forgetting sometimes, though some part of me likes it, and so I continue using semicolons in my javascript.

That having been said, I think it's a matter of personal opinion (likely just what a given person is used to), and if it fits with the spec and the common usage, then you'd think a library that is expected to work with/on other libraries would try to be accommodating.

edit: To further clarify, Javascript's stance is silly, because you need to know how semicolon insertion works. It's extra knowledge you have to have. Thus, I think I agree with most here that it's easier to just use them. (Other languages have optional semicolons but they don't change the meaning of the syntax at all.)

edit2: This is GitHub, why is there not a fork already with this issue behind us?


uglifyjs and closure compiler seem to be totally safe.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: