Hacker News new | comments | show | ask | jobs | submit login
Doug Crockford Talk on JavaScript (felixcrux.com)
23 points by alec on Nov 2, 2009 | hide | past | web | favorite | 9 comments



I didn't see any links to videos - here is one from his Google tech talk in February: http://www.youtube.com/watch?v=hQVTIJBZook. He also has a number of videos on YUI Theater (http://developer.yahoo.com/yui/theater/).

I also recommend checking out the javascript page on his website, plenty of javascript related material to keep you busy for hours: http://www.crockford.com/javascript/


I would love to hear an argument FOR "semicolon insertion" for a change. I only ever hear arguments against it. Personally I would prefer to avoid unnecessary line noise if the interpreter can figure it out for me given the context.


There is no good argument for semicolon insertion except to be newbie friendly. And, as pointed out in the article, semicolons can be inserted in unexpected places causing hard to find bugs. In the end, that isn't friendly to anyone including newbies.


I disagree. I consider an interpreter that can figure things out on your behalf to be a more intelligent interpreter. It requires me to type less. The "hard to find bugs" pointed out in the article are a (acceptable imo) trade-off for a terser syntax.


You have to be precise when programming; A statement needs to have one and only one meaning. It's possible to design a language that doesn't require semicolons (Basic, for example) or just be more terse than JavaScript. But a language who's grammar changes based on very subtle context is not acceptable.

When it comes to JavaScript, you'll find most people put the semicolons in even when they don't have to. It's just a highly ineffective feature. Now if they didn't have semicolons at all and designed the language appropriately, that would be different.


You speak as if your words are law but really it is just your opinion. Modern languages are still being designed this way. For example semicolons are optional in Scala.


Yes, and Scala doesn't have the same problems as JavaScript. There's nothing wrong with having a language where semicolons are optional (as I already said). But in JavaScript, semicolons aren't optional in the same sense as Scala. They're essentially required but the interpreter "helpfully" inserts them for you if you "miss one" and potentially changes the meaning of your program. That's a huge difference.

I actually agree with your statement "I consider an interpreter that can figure things out on your behalf to be a more intelligent interpreter" -- I'm not arguing against smart interpreters. I'm merely arguing against semicolon insertion which is actually an incredibly dumb way of handling this situation.


Fair enough. I just fail to see the distinction between "semicolon insertion" and optional semicolons. Sounds to me like semicolon insertion is just a stupid way to implement an interpreter where semicolons are optional -- something that can be changed without affecting client code


A language has to be designed around optional line terminators -- you just can't take a language like JavaScript or C and remove the semicolons, they convey meaning to the program. Something like Scala doesn't have the ambiguity that a C or JavaScript program has without line terminators.

So semicolon insertion is just a hack that happens before parsing. It's not that the semicolons are optional, they aren't, but it puts them in automatically according to a set of rules. Unfortunately that means you can't just put a return on a line by itself -- a semicolon will always be inserted.




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

Search: