Live data from Hacker News

Six years of Go

blog.golang.org

271–280 of 327 posts

Re: Six years of Go

#271
post #200

I wish the gdb support were better or that delve were more stable. I also had some weirdnesses using cgo on osx. Then I went into #go-nuts on freenode, and I got told I was wrong and there was no problem. Back in 2009 #go-nuts seemed to be a much different place. I write Go at work, and I admire many of the same things in Go I admire about Python. I still wish generics were part of the language and will say their exc…

`#go-nuts` is a very angry place.

I tried to go there to ask some questions while picking up the language, and what I got was RTFM, where manual includes the language specification, Effective Go book, and A Tour of Go. Apparently you're unfit to ask a question unless you know everything about the language already. Killed my excitement for learning the language.

Re: Six years of Go

#272
post #210

Earlier quoted context omitted.

I'm in the same boat. Go's simplicity is initially refreshing, then a huge pain once you find yourself writing the same thing over and over again. A good example is errors being values — which is a great idea. But then you realize every single function needs to be littered 1-10 cases of if err != nil { return nil, err } It's an extremely common pattern. It's tiring to write, over and over. Tiring to refactor, too: If…

> If you have "func bar() (MyStruct, error)", you cannot do "foo(bar())". You must always assign the result to an intermediate variable. You could embed the error in the MyStruct struct instead, but that goes against Go's grain. Chaining does work, but obviously the function needs the same signature as the return values, which limits things since most APIs don't accept errors as input. But within your code you can st…

> Or create wrappers to make your types chainable

It can't always be done. A generic wrapper only works for functions that return values. It would be nice to have a wrapper that can take any function, e.g. foo in:

  package main
  import "fmt"

  func foo(a ...interface{})interface{}{
    if len(a) == 0 {
      return nil
    } else if len(a) == 1 {
      return a[0]
    } else {
      return a
    }
  }

  func barbar() (a, b int) { return 1, 2 }
  func bar() (a int) { return 1 }
  func baz() { return }

  func main() {
    fmt.Println( foo(barbar()) ) // prints: [1, 2]
    fmt.Println( foo(bar()) )    // prints: 1
    fmt.Println( foo(baz()) )    // compile error: baz() used as value
  }
Instead of the compile error, it would be nice if foo accepted baz() as a argument, which would read the array length as 0 and here return nil.

Re: Six years of Go

#273

I have a bit of a love-hate relationship going on with Go. On one hand, it addresses many of the pain points I've experienced with other languages. It's easy to build and deploy, reasonably performant, and has a powerful and consistent standard library. On the other… developing in it feels like a total slog. It manages to be simultaneously far too anal and overly forgiving about syntax. Visibility definition using up…

I'm in the same boat. Go's simplicity is initially refreshing, then a huge pain once you find yourself writing the same thing over and over again. A good example is errors being values — which is a great idea. But then you realize every single function needs to be littered 1-10 cases of if err != nil { return nil, err } It's an extremely common pattern. It's tiring to write, over and over. Tiring to refactor, too: If…

It's odd, they've written that they were influenced by Pascal, which is where the operator " := " comes from. But it doesn't work quite right in golang...

In Pascal you would use := every time you wanted to assign a variable, and a single equals when testing, such as "if (x = 5) then...". It is slightly more like math than most languages, which I appreciated. But, golang only allows it on the first assignment, the reasoning perhaps that it is a declaration?

I don't feel that this third way of doing it with no advantage was a benefit, choosing one C of Pascal rules would have been better and less to think about.

Re: Six years of Go

#274

Earlier quoted context omitted.

I've found the standard library to be more than capable for most CRUD style apps. You can add in simple middleware chaining using a library such as Alice ( https://github.com/justinas/alice ) and for passing around request contexts between them, you can use something like xhandler ( https://github.com/rs/xhandler ). If you want more performant or flexible routing, httprouter ( https://github.com/julienschmidt/httprou…

That's the libraries I use, too. I really wish contexts were built into Go's HTTP library. Without contexts, you have to use global variables to accomplish things like per-request logging and access to configuration data. Not to mention that since goroutines cannot be forcibly terminated, it's the only way to control the lifetime of a handler (e.g. applying timeouts).

You may be looking for https://godoc.org/golang.org/x/net/context which is likely to make it into stdlib in the 1.7 timeframe from what I've seen in various channels. Doesn't quite solve the global logging problem though.

Re: Six years of Go

#275
post #274

Earlier quoted context omitted.

That's the libraries I use, too. I really wish contexts were built into Go's HTTP library. Without contexts, you have to use global variables to accomplish things like per-request logging and access to configuration data. Not to mention that since goroutines cannot be forcibly terminated, it's the only way to control the lifetime of a handler (e.g. applying timeouts).

You may be looking for https://godoc.org/golang.org/x/net/context which is likely to make it into stdlib in the 1.7 timeframe from what I've seen in various channels. Doesn't quite solve the global logging problem though.

Yep, that's the context we (I and the grandparent comment) are using.

Re: Six years of Go

#276

Earlier quoted context omitted.

I'm in the same boat. Go's simplicity is initially refreshing, then a huge pain once you find yourself writing the same thing over and over again. A good example is errors being values — which is a great idea. But then you realize every single function needs to be littered 1-10 cases of if err != nil { return nil, err } It's an extremely common pattern. It's tiring to write, over and over. Tiring to refactor, too: If…

If there a paradigm for handling multiple potential errors in a function? I'm usually stuck using: reply, err := redis.Givemethevalue(key) if err != nil { return err } thing, err2 := postgres.getById(reply) if err2 != nil { return err2 }

I use

  var err error
at the beginning of the function if needed.

Re: Six years of Go

#277
post #251

Earlier quoted context omitted.

FUD. - Do all opensource projects require corporate sponsorship to be viable? - Do Python, Ruby, even Rust have corporate backers that cannot widthdraw support? - Does Java, being under the control of Oracle, present a better option? - Many business are using VB, C# and F#, which Microsoft owns. F# especially could be abandoned, but it continues to find new use. The Go code I write and compile today will continue to…

>FUD We're talking about decisions to adopt a language, so FUD and especially "uncertainty" is a very important factor to consider. This is not 1999 and Microsoft badmouthing Linux. > Do all opensource projects require corporate sponsorship to be viable? Not all of them, but a lot of them do. Especially languages. Even something like OCamL needs Jane Street and that french university a lot. Go is not setup as even a…

> all the core team for one

Not all (Yehuda and me, Huon), although both of us have been paid by Mozilla at some point in the past.

Re: Six years of Go

#278

I've used Go for a couple years but am only just writing my first production system in Go. I think one of the major complaints is that it's use-cases are ambiguous to beginners. Go, IMO, is a systems language and should not be the first thing you pull out when someone says "write a web app". I think Go has a very limited use case, but it is incredibly good for that use case. If I had to define it right now it would b…

Go started as a niche language and worked well for that niche, but like all niche techs that become dependencies, they tend to get bigger overtime. Go success is undeniable and is reaching a critical mass where there will be no going back.

There are alternatives but most of them aren't backed by a big corp like Google, so they will have to succeed in their respective niche before getting widely adopted. I wish that wasn't the case cause languages like D,Nim or Crystal are really good and way more enjoyable to write in my opinion. Out of all of these(including Go) one will be the next big language, no question as people move from dynamic or VM backed languages (for good reasons).

Re: Six years of Go

#279
post #233

Earlier quoted context omitted.

What language has ever died after having been used by more than a handful of programmers?

Most of the memory safe systems programming languages that were steam rolled by UNIX and C's adoption. dBase III derivatives. 4GL languages.

Just the good ones...

Re: Six years of Go

#280

I have a bit of a love-hate relationship going on with Go. On one hand, it addresses many of the pain points I've experienced with other languages. It's easy to build and deploy, reasonably performant, and has a powerful and consistent standard library. On the other… developing in it feels like a total slog. It manages to be simultaneously far too anal and overly forgiving about syntax. Visibility definition using up…

I'm in the same boat. Go's simplicity is initially refreshing, then a huge pain once you find yourself writing the same thing over and over again. A good example is errors being values — which is a great idea. But then you realize every single function needs to be littered 1-10 cases of if err != nil { return nil, err } It's an extremely common pattern. It's tiring to write, over and over. Tiring to refactor, too: If…

I felt very much the same way about Go's error handling; that, coupled with straight-line synchronous-style socket programming, made me feel like I was writing the same dumb C code I did when I was a teenager in the mid-90s.

I've come to believe that slicker error handling is a bit of a false economy, at least compared to other "informal" languages like Java, Ruby, and Python (all bets are off if you want to compare Go to Haskell; I concede everything in advance there).

I feel like a lot of Java and (especially) Python/Ruby code is easier to read... until it matures enough to handle errors properly, at which point its just as crudded up. It's much easier to start sketching out code in Ruby and wrapping everything in blanket try/rescue blocks. But that code always breaks and always gets trickier before it's ready to ship.

Lots of people I've talked to have had the same experience coming off C, Ruby, and Python as I have: when the Go compiler stops spitting out errors, your program tends to work --- usually not perfectly, but still far better than a first-run Ruby or C program does!

Also, when people think about Go error handling compared to Ruby and Python, they rarely factor in the density of unit tests required for the Ruby and Python code.

Post reply on HN