News for hackers. Stuff that matters.
Re:Why Go gets criticized so much by innocentoldguy on Friday April 08, 2016 @11:08AM (#11455148)
The main problem with Go, and this is a deal breaker for me, is that it forces opening curly braces onto the same line, instead of putting them on a line by themselves. This is clearly wrong, and flies in the face of curly good taste.
Re:Why Go gets criticized so much by RodgerTheGreat on Friday April 08, 2016 @11:24AM (#11455312)
If it's clearly wrong, can you articulate a reason? There is at least one (mild) argument in favor of opening a curly brace on the same line: code takes up less vertical space, allowing a programmer to view more of their program on a given screen at once.
Re:Why Go gets criticized so much by kazinator on Friday April 08, 2016 @11:56AM (#11455604)
I use both styles in the same code:

  if (simple_condition) {

  } else {

  }

  for (long and stuffed;
       expressions;
       here)
  {
  }

  if ((complicated ||
       multi_line)
      && condition)
  {
  }

  void function()
  {
  }
In an if, all the "else if" and "else" clauses have to follow the same style. If any is braced, they all have to be.

By the way, is grandparent kidding about Go enforcing this?

The only language I can think of which enforces curly brace placement is Awk. (And only in its pattern-action pairs):

   BEGIN {
     function()
     {
        if (foo)
        {
        }
     }
   }

   /regex/ {   # can't move this curly to next line
     action
   }
Re:Why Go gets criticized so much by kazinator on Friday April 08, 2016 @12:10PM (#11455730)
RATIONALE: why the two styles? Why

  if (simple_condition) {
    code;
  }
but:

  if ((complicated ||
       multi_line)
      && condition)
  {
    code;
  }
?

Simple: it's because in both cases, the "code" follows a previous line from whose first non-whitespace character it indents by the indentation level:

  if (...
  [INDENT]code

  {
  [INDENT]code
This is just wacky:

  while (blah
         blah
         blah) {
    code
  }
"code" isn't "indenting off of" anything. It is not related to the indentation of "blah" in any way, but appears to be "deindenting" from it!

So, rather than dogmatically doing one thing or another, it's better to consider all the alternatives, their relative advantages and disadvantages, and integrate them into an elegant whole.

Re:Why Go gets criticized so much by kavehmz on Friday April 08, 2016 @08:54PM (#11459323)
One reason I love Go for it. Look, it will prevent the replies you got, while I am thinking about solving a problem. :)

Go forces one format. Although you definitely can ignore formatting your code and just compile it. It won't fail.

Re:Why Go gets criticized so much by infogulch on Friday April 08, 2016 @11:31AM (#11455363)
Many, many people disagree with your basic deal breaker, completely unrelated to Go. E.g. the Linux kernel uses this brace style.

Now I'm wondering if I've just been successfully trolled.