Apple JavaScript Coding Guidelines [pdf](developer.apple.com)
developer.apple.com
Apple JavaScript Coding Guidelines [pdf]
http://developer.apple.com/library/mac/documentation/ScriptingAutomation/Conceptual/JSCodingGuide/JSCodingGuide.pdf
10 comments
Already discussed in http://news.ycombinator.com/item?id=1854783 with the same consensus, it's a terrible guide. Read Crockford, Stoyanov, Bolin instead.
For those who would prefer an HTML version: http://developer.apple.com/library/mac/#documentation/Script...
Or the actual PDF itself, which lacks the Scribd™ value-added feature of banner ads on every page:
http://developer.apple.com/library/mac/documentation/Scripti...
http://developer.apple.com/library/mac/documentation/Scripti...
I think the OP's link is actually to the PDF. HN adds the automatic Scribd link whenever someone posts a link to a PDF.
Wow, that's horrible.
The original announcement (2008):
http://www.scribd.com/doc/50406482/Hacker-News-Integrates-Wi...
http://www.scribd.com/doc/50406482/Hacker-News-Integrates-Wi...
[deleted]
I have a strong reason to suspect that this was written by an intern who was relatively new to the language. It seems to be written by someone in the C/C++/Java mindset (ie how they didn't list "function" as a primitive data type)
Function is not a separate data type in JavaScript, but they could probably list Object there (EcmaScript defines 6 types and 5 primitive values, I can't really find any definition of "primitive type")
Man, what a piece of shit. Apple should pull this immediately.
Good that I saw this before reading the pdf. Can you point me to a better resource?
As seen elsewhere in the comments, Crockford's is very good:
http://javascript.crockford.com/code.html
http://javascript.crockford.com/code.html
JavaScript Garden is the best collection of JavaScript best practices I have seen so far: http://bonsaiden.github.com/JavaScript-Garden/
The example in this document of using the delete operator on a function is wrong.
http://perfectionkills.com/understanding-delete/
http://perfectionkills.com/understanding-delete/
I find it strange that the "Global Scope Considerations" section uses Ruby-style inline comments (#) rather than actual JS inline comments (//).
I find it strange that you refer to comments starting with # as Ruby-style comments.
Or any other language that denotes comments with an octothorpe, but I opted for brevity.
I'm pretty sure Ruby is bigger than Perl and sh put together now, at least in mindshare.
python and PHP also support # for making comments. It could be argued that python has just as much if not more mindshare than ruby. :)
I agree. I think "Python-style comments" would be just as reasonable a term. My impression was that the comment I was responding to was objecting on historical grounds, since Ruby and Python borrowed that comment style from Perl, which in turn borrowed it from shell scripts.
[deleted]
Most of the examples use C style curly braces, maybe Crockford needs to do an "Apple Tech Talk".
http://www.youtube.com/watch?v=hQVTIJBZook
http://www.youtube.com/watch?v=hQVTIJBZook
Or just read this?
http://javascript.crockford.com/code.html
I guess Crockford is like K&R for JS's conventions.
I guess Crockford is like K&R for JS's conventions.
Two years old?
> operator to create an object, you should delete objects when you are finished withthem, like this:
> delete myObjectVariable;
What a bunch of crap? Have these guys even looked at the specs?
And chapter on inheritance really makes me cry...