7 ms·
Apple JavaScript Coding Guidelines [pdf]
- Hovertruck 15y agoI find it strange that the "Global Scope Considerations" section uses Ruby-style inline comments (#) rather than actual JS inline comments (//).
- coyul 15y agoI find it strange that you refer to comments starting with # as Ruby-style comments.
- Hovertruck 15y agoOr any other language that denotes comments with an octothorpe, but I opted for brevity.
- chc 15y agoI'm pretty sure Ruby is bigger than Perl and sh put together now, at least in mindshare.
- mark_story 15y agopython and PHP also support # for making comments. It could be argued that python has just as much if not more mindshare than ruby. :)
- chc 15y agoI 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 15y ago[deleted]
- kreek 15y agoMost 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
- Apocryphon 15y agoOr just read this? http://javascript.crockford.com/code.html http://javascript.crockford.com/code.html I guess Crockford is like K&R for JS's conventions.
- Aqua_Geek 15y agoFor those who would prefer an HTML version: http://developer.apple.com/library/mac/#documentation/ScriptingAutomation/Conceptual/JSCodingGuide/Introduction/Introduction.html http://developer.apple.com/library/mac/#documentation/Script...
- scrod 15y agoOr the actual PDF itself, which lacks the Scribd™ value-added feature of banner ads on every page: http://developer.apple.com/library/mac/documentation/ScriptingAutomation/Conceptual/JSCodingGuide/JSCodingGuide.pdf http://developer.apple.com/library/mac/documentation/Scripti...
- superchink 15y agoI think the OP's link is actually to the PDF. HN adds the automatic Scribd link whenever someone posts a link to a PDF.
- scrod 15y agoWow, that's horrible.
- superchink 15y agoThe original announcement (2008): http://www.scribd.com/doc/50406482/Hacker-News-Integrates-With-iPaper-Scribd-Blog-3-11-08 http://www.scribd.com/doc/50406482/Hacker-News-Integrates-Wi...
- deleted 15y ago[deleted]
- omgtehlion 15y ago> Just as you used the new > 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...
- foobarbazoo 15y agoMan, what a piece of shit. Apple should pull this immediately.
- yalogin 15y agoGood that I saw this before reading the pdf. Can you point me to a better resource?
- adolph 15y agoAs seen elsewhere in the comments, Crockford's is very good: http://javascript.crockford.com/code.html http://javascript.crockford.com/code.html
- jarek-foksa 15y agoJavaScript Garden is the best collection of JavaScript best practices I have seen so far: http://bonsaiden.github.com/JavaScript-Garden/ http://bonsaiden.github.com/JavaScript-Garden/
- neimado 15y agoI agree. Also they aren't using 1TBS for the code examples, and that will naturally lead to noob javascript programmers running into trouble when they inevitably type return { hello:"world" } using 1TBS will naturally lead the programmer to type the correct javascript syntax return { hello:"world" } 1TBS is naturally a better fit for javascript programming.
- lucaswoj 15y agoI 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)
- jarek-foksa 15y agoFunction 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")
- lucaswoj 15y agoThe example in this document of using the delete operator on a function is wrong. http://perfectionkills.com/understanding-delete/ http://perfectionkills.com/understanding-delete/
- jmreid 15y agoTwo years old?
- Tomek_ 15y agoAlready discussed in http://news.ycombinator.com/item?id=1854783 http://news.ycombinator.com/item?id=1854783 with the same consensus, it's a terrible guide. Read Crockford, Stoyanov, Bolin instead.
- blahpro 15y agoIt’s shocking that this document refers to "classes". JavaScript doesn’t even have classes.
- encoderer 15y agoWhy is this comment deprecated? He's absolutely right, if a little late to the party. Shockingly bad document from Apple.