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

Since my http://eloquentjavascript.net recommends always terminating statements with semicolons, I guess I'm being directly addressed by this.

The suggestion that 'I don't understand semicolon insertion' doesn't really hit the mark. I wrote a JavaScript implementation.

Yet still I recommend everyone to use explicit semicolons. Going over the proposed style on this page, it all sounds pretty good, and semicolon insertion is starting to look okay. Until you realize that he wants you to start every line that starts with [(+/-,.* with a semicolon. This is needed to prevent semicolon insertion from failing you.

I'm sure one can get used to such a style, but it is completely 'out there', radically disconnected from JavaScript's C parentage, and, though that's a question of taste, ugly and irregular. This solution is worse than the problem, I think.



I don't mind you telling people to end lines with semicolons.

I'd mind it if you told people that omitting semicolons causes cancer. (Or bugs.)

-- EDIT:

I just looked up your book to the point where you make this recommendation. You don't threaten any catastrophes, which is good. I disagree with the "complex and weird" conclusion, but it's certainly a valid decision to leave them out of the book if you'd rather not go into it.

My opinion of you: Not Evil. <3


Finally, somebody else who hates the largely gratuitous semicolons.

Example: http://roboprogs.com/devel/2010.06.html

It's a shame they didn't just make it fully line oriented (like BASIC, xBASE, shell-script, Python, Ruby, ...), with the customary backslash or ampersand to indicate an incomplete line. (but they didn't) I guess then Netscape would have had to call it FooScript (or something silly like echhh-muh-script).

The worst thing I hate about the "add semicolons!" religion is that it teaches people not to spot statements that are going to be terminated by a newline. So then, I have to see all the extra noise on each line :-(

Don't people test the crap they write?!?


"Until you realize that he wants you to start every line that starts with [(+/-,.* with a semicolon."

Good point, that isn't immediately clear.

To help me understand, the article listed an example where a line started with a [, what are situations where a line is likely to start with (+/-,.* ?


The immediate-function pattern starts with an open paren.

(function () {

}());


So you do this to nest temporary variables in another lexical scope inside of another outer function? (as vars have function scope rather than block scope)

I'm not sure I would use this much, though now that you have pointed it out, I had better well be able to read it when somebody else does it to me. Thanks, I think.


Most javascript modules are defined inside a similar pattern, I'm surprised you haven't seen it yet.

http://www.adequatelygood.com/2010/3/JavaScript-Module-Patte...

https://github.com/jquery/jquery/blob/master/src/ajax.js


Odd. I've usually just returned or assigned the function def without the outer parens. For some reason, the outer parens syntax looked like it was defining an anonymous function, and also calling it immediately, which is of course not what that turns out to do.

It's an interesting language, but I'm still at the dabbling stage. I'd like to think I'm past the voodoo stage (onfoo="whack()" attributes that call in-page functions with global variables), but maybe not.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

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

Search: