News for hackers. Stuff that matters.
Re:Node.js Guide by nphase on Wednesday March 30, 2011 @05:06PM (#2389243)
I was afraid to read the style guide for fear of seeing K&R vs Allman indents/braces. As usual, it was hit on. However, to my amusement, the "Right" way of doing things actually has a syntax error:

  if (true) {
    console.log('winning);
  }
Re:Node.js Guide by pkteison on Wednesday March 30, 2011 @05:31PM (#2389334)
I have been personally screamed at for suggesting One True Brace Style over K&R in response to a request for feedback on an architecture standards document. That was when I learned that corporate architecture teams don't actually want to get feedback when they ask for it.

I find it odd that I have a strong opinion on the topic but have never seen a convincing argument that one way is actually better than another, it's just that one feels right to me and the others don't and I can't articulate but neither can anyone else I've seen.

Re:Node.js Guide by davej on Wednesday March 30, 2011 @05:57PM (#2389411)
I don't know about other languages but there are real practical reasons to choose 1TBS in Javascript, consider the following code:

    return {
        key: 'value',
        anotherKey: 'another value'
    }
This is fine and works as expected, now consider the following K&R/Allman style code...

    return
    {
        key: 'value',
        anotherKey: 'another value'
    }
In Javascript this is parsed as `return;` (notice the semi-colon), this is because Javascript does its dreaded automatic semicolon insertion magic.

So, I think that's a pretty good practical reason to prefer 1TBS in Javascript.

Re:Node.js Guide by glenjamin on Wednesday March 30, 2011 @06:37PM (#2389534)
I favour a mix of the two in javascript - 1TBS for object literals and anonymous functions, K&R for conditionals and named functions.
Re:Node.js Guide by pkteison on Wednesday March 30, 2011 @08:10PM (#2389823)
Thank you! I didn't actually know this and would have completely missed that bug.
Re:Node.js Guide by felixge on Thursday March 31, 2011 @03:25AM (#2390705)
Fixed. Sorry, I was typing most of this on my iPad.