Live data from Hacker News

Benefits of named return values in Go

blog.minio.io

131–140 of 146 posts

Re: Benefits of named return values in Go

#131
post #35

Earlier quoted context omitted.

I had a bit of a play around with it. It's pretty powerful being able to see in one line ( or possibly multi line ) It really hammers home the concept that a function is a transformation, and of what into what. And I think this syntax would probably encourage pure functions. And it's so useful to allocate the return in the top line. I really like go.

What language that has static types doesn't have the func, params, and return type in one line?

K&R C had implied type of 'int' for both arguments and return value, and didn't list the types of arguments on the line specifying function name, argument names and return type:

  int foo(x,y)
  {
     return baz(x,y);
  }

  bar(x,y,z)
  short x;
  int z;
  {
     return x+y+z;
  }

  baz(x,y,z)
  {
     return 42;
  }

Re: Benefits of named return values in Go

#132
post #107

Earlier quoted context omitted.

> /r/golang consensus is against using named values. /r/golang is a toxic subreddit and I wouldn't take anything said there for face value. Dave Cheney deleted his account there and the go team itself wanted to delete that subreddit. So no, /r/golang represents only /r/golang and certainly not the go community as a whole. /r/golang favorite pass time is to take some piece of code or a library and humiliate its author…

Dramatic much? There's nothing "toxic" about /r/golang. It's mostly boring content, and the criticism is rarely worse than what's going on in this very thread (which is itself mild by HN standards). The official rationale for why Dave and the Go team left has changed several times, but it has always been over-dramatic or vague (e.g., "We need to shut down /r/golang because the CEO of reddit might edit our posts like…

> There's nothing "toxic" about /r/golang

The fact that go maintainers themselves wanted to get rid of /r/golang actually proves otherwise. As for Dave Cheney, he left that sub long before any Trump drama on reddit.

Obviously the people who act in a toxic fashion don't think themselves as such and don't see the toxicity even when it blatantly exists.

But that's not my point. /r/golang is officially outside Go community since even go maintainers disowned it and want nothing to do with it. Whatever drama happening there is not representative of the go community, nor whatever /r/golang thinks as "idiomatic".

Re: Benefits of named return values in Go

#133

Earlier quoted context omitted.

Yeah, the article wasn't great. I think few supporters of named returns would even agree with that article. Like all language features, you're always going to get some individuals who will misuse them. The author there I definitely think is misusing named returns for something that really needs to be optimised in the compiler instead.

In defense of the article, I can see how anyone writing a lot of Go would start to get a bit desperate for shortcuts. It's a language that's relentlessly hard on prolific writers, putting their needs second in favor of minimizing the context required for any code. So I could see how things like having a alternative-providing validator chain take 5% fewer characters would feel intoxicating after using code generation…

One minute you're moaning that features need to be removed from Go, the next you're mocking it for not having enough features. Yet you dont even code in the language you're clearly very opinionated and highly critical over.

We all have our personal preferences, I get that. But why can't people just live and let live instead of trying to make out their personal preferences are measurably better than those they dislike? After all, if all programming languages were identical then the IT industry would be worse off for it.

For what it's worth, I've been writing software for nearly 3 decades now and have writing applications in well over a dozen different languages. Go might lack some of the expressiveness I'm used to but it's still one of the most rapid languages I've used to create software. And one of the most painless to deploy too. In fact ironically some of the "worst languages" in terms of developer chin stroking have been some of the easiest to work with; Visual Basic (pre .NET) is another example. But if I had my way we would be back to writing DOS programs in Turbo Pascal. This is why I get so fed up with people moaning about their tools. Frankly put, mocking any particular tool for not behaving like another particular tool just shows ones own limitation as a developer.

Re: Benefits of named return values in Go

#134

Earlier quoted context omitted.

In defense of the article, I can see how anyone writing a lot of Go would start to get a bit desperate for shortcuts. It's a language that's relentlessly hard on prolific writers, putting their needs second in favor of minimizing the context required for any code. So I could see how things like having a alternative-providing validator chain take 5% fewer characters would feel intoxicating after using code generation…

One minute you're moaning that features need to be removed from Go, the next you're mocking it for not having enough features. Yet you dont even code in the language you're clearly very opinionated and highly critical over. We all have our personal preferences, I get that. But why can't people just live and let live instead of trying to make out their personal preferences are measurably better than those they dislike…

> But why can't people just live and let live instead of trying to make out their personal preferences are measurably better than those they dislike? After all, if all programming languages were identical then the IT industry would be worse off for it.

I enjoy programming in Go about as much as I enjoy wearing shoes about 3 sizes too small. As a result, it's my goal to find very good arguments against its use in any of my projects. Should I feel bad about this? If so, can you come and stop people from powerdunking on me every time I talk about how Haskell is good at something?

I'm not mocking Golang here. It is what it is. I think it's an oddly designed tool based more around making Google's turnover easier to deal with rather than helping me as a software engineer. I am expressing frustration at people who want to laud its design as "good" or "progressive" or helpful when really, it's the language equivalent of a querty keyboard layout. Designed to be about as easy to learn as anything but prevent anyone from getting excessively good with it, because large skill gaps in a workforce with turnover are hard to manage around.

Re: Benefits of named return values in Go

#135
I like named returns and I like efficiency, nice!

An argument against named returns is that things become harder to track in longer functions or functions with a lot of branching, but if you're using gometalinter you'll be warned about both of those things anyway, so I don't see the concern there.

Re: Benefits of named return values in Go

#136
post #122

Earlier quoted context omitted.

The issue is that with the string/regex issue, there's a good reason that the string operation should be faster. Maybe a "sufficiently smart compiler" could optimize it in some cases of static regexes, but it's at least complicated. In cases where the regex is dynamically determined, even the sufficiently smart compiler probably can't optimize away the regex. In contrast, the case in this article seems like table sta…

When I've benchmarked regexes before (Ruby ISTR) there have been situations where the regex engine optimised the code to be comparable to string functions, I can't remember the details though. Just for fun I benchmarked =~ /\Asomething/ and start_with?("something"), a situation that seems could be optimisable by the regex engine, but the string function is still faster (Ruby 2.3.1): start_with: 5703143.1 i/s regex: 2…

My point of view is that if you're two equally good styles based on the compiler, it's contorting your code. One doesn't have to be better than the other, if you can't make that choice between semantically identical options, you're conforming to an arbitrary standard.

Re: Benefits of named return values in Go

#137
post #107

Earlier quoted context omitted.

> /r/golang consensus is against using named values. /r/golang is a toxic subreddit and I wouldn't take anything said there for face value. Dave Cheney deleted his account there and the go team itself wanted to delete that subreddit. So no, /r/golang represents only /r/golang and certainly not the go community as a whole. /r/golang favorite pass time is to take some piece of code or a library and humiliate its author…

Dramatic much? There's nothing "toxic" about /r/golang. It's mostly boring content, and the criticism is rarely worse than what's going on in this very thread (which is itself mild by HN standards). The official rationale for why Dave and the Go team left has changed several times, but it has always been over-dramatic or vague (e.g., "We need to shut down /r/golang because the CEO of reddit might edit our posts like…

Quite frankly, your post makes me think maybe /r/golang is in fact toxic.

You fight accusations of toxicity with examples of the community being great, not with defensive and vague posts.

Re: Benefits of named return values in Go

#138
post #107

Earlier quoted context omitted.

> /r/golang consensus is against using named values. /r/golang is a toxic subreddit and I wouldn't take anything said there for face value. Dave Cheney deleted his account there and the go team itself wanted to delete that subreddit. So no, /r/golang represents only /r/golang and certainly not the go community as a whole. /r/golang favorite pass time is to take some piece of code or a library and humiliate its author…

Dramatic much? There's nothing "toxic" about /r/golang. It's mostly boring content, and the criticism is rarely worse than what's going on in this very thread (which is itself mild by HN standards). The official rationale for why Dave and the Go team left has changed several times, but it has always been over-dramatic or vague (e.g., "We need to shut down /r/golang because the CEO of reddit might edit our posts like…

"and the criticism is rarely worse than what's going on in this very thread (which is itself mild by HN standards)."

I'll echo that. If /r/golang is "toxic" this HN conversation is outright radioactive. This is far worse than any day-to-day thread on /r/golang.

As I understand it, the basic reason the Golang authors themselves decided to leave wasn't the "golang" part of "r/golang", but the "r" part; Brad Fitzpatrick, having run LiveJournal, was incredibly and IMHO justifiably offended by the revelation that Reddit admins had been editing people's posts, because of his personal experiences and ethics. It also turned out that the Golang people had not started the community, but accidentally thought they owned it none-the-less, which IMHO puts a new light on how the /r/golang community reacted when the Go authors attempted to lay down rules on how it works. Of course the community reacted poorly to what amounted to people just dropping by and asserting tons of ownership over the community they hadn't created and only marginally participated in. Nobody should expect that to just go swimmingly. But at the core it was all a misunderstanding as to who owned the community, which has since been resolved.

Re: Benefits of named return values in Go

#139
post #132

Earlier quoted context omitted.

Dramatic much? There's nothing "toxic" about /r/golang. It's mostly boring content, and the criticism is rarely worse than what's going on in this very thread (which is itself mild by HN standards). The official rationale for why Dave and the Go team left has changed several times, but it has always been over-dramatic or vague (e.g., "We need to shut down /r/golang because the CEO of reddit might edit our posts like…

> There's nothing "toxic" about /r/golang The fact that go maintainers themselves wanted to get rid of /r/golang actually proves otherwise. As for Dave Cheney, he left that sub long before any Trump drama on reddit. Obviously the people who act in a toxic fashion don't think themselves as such and don't see the toxicity even when it blatantly exists. But that's not my point. /r/golang is officially outside Go communi…

Good to know. Thanks for sharing this, as it's helpful for other folks who now have Go to deal with.

Re: Benefits of named return values in Go

#140
post #132

Earlier quoted context omitted.

Dramatic much? There's nothing "toxic" about /r/golang. It's mostly boring content, and the criticism is rarely worse than what's going on in this very thread (which is itself mild by HN standards). The official rationale for why Dave and the Go team left has changed several times, but it has always been over-dramatic or vague (e.g., "We need to shut down /r/golang because the CEO of reddit might edit our posts like…

> There's nothing "toxic" about /r/golang The fact that go maintainers themselves wanted to get rid of /r/golang actually proves otherwise. As for Dave Cheney, he left that sub long before any Trump drama on reddit. Obviously the people who act in a toxic fashion don't think themselves as such and don't see the toxicity even when it blatantly exists. But that's not my point. /r/golang is officially outside Go communi…

It doesn't "prove" anything. It only proves that the maintainers are intolerant of the community, for whatever reason.

> Obviously the people who act in a toxic fashion don't think themselves as such and don't see the toxicity even when it blatantly exists.

Maybe I "act in a toxic fashion" or maybe your standards for "toxic" are just extremely low. Fortunately, we don't have to agree on the absolute threshold for toxic, we can make relative comparisons; as /u/jerf stated, if /r/golang is toxic, this thread is radioactive. Anyway, it's rude to make unfalsifiable implications about other people, or to speak as though your own subjective thresholds are absolute ("...toxicity even when it blatantly exists"); and it's foolishness when your own standard for "toxic" is so much lower than the common use.

> /r/golang is officially outside Go community since even go maintainers disowned it and want nothing to do with it.

You're confusing the Go community with the various subcommunities under the maintainers' moderation. You have to provide a better rationale for why /r/golang is an invalid sampling of Gophers for the purpose of named returns; "because the maintainers don't like it" is not very compelling.

Post reply on HN