News for hackers. Stuff that matters.
Re:Down the Golang Nil Rabbit Hole by latch on Tuesday March 30, 2021 @12:57AM (#26631389)
I think these two rightfully get highlighted, but I've found it difficult to organize complex Go code (though clearly some people manage), which I think is now my biggest issue with the language.

It's inability to deal with cyclic references, the lack of overloading, the lack of package-level visibility and the lack of static functions all contribute to a lot of ceremony.

You end up with functions like newUserWithPassword and NewRole (casing intentional), instead of User::new() and Role::new()

You could just have a NewUser that takes a NewUserOpts which exposes a fluent interface. But again, a lot of ceremony.

You can use a package per type, but still no overloading, and you'll need a 3rd package to bridge the two if the reference each other.

Re:Down the Golang Nil Rabbit Hole by kodah on Tuesday March 30, 2021 @01:02AM (#26631406)
> It's inability to deal with cyclic references, the lack of overloading, the lack of package-level visibility and the lack of static functions all contribute to a lot of ceremony.

After 4 years of Go, this is usually a design thing. Once I figured out how to separate and isolate domains of interest better, I stopped running into these issues entirely. My code, in and outside of Go, is much better for it. I also learned that much of "thread-safe" programming is taught this way, which makes sense.

Re:Down the Golang Nil Rabbit Hole by christophilus on Tuesday March 30, 2021 @06:45AM (#26633070)
F# has similar constraints, and gets similar complaints, and yet advocates (like I) think it’s a feature, not a bug. Most problems can be decomplected, and I like that Go enforces this particular constraint.
Re:Down the Golang Nil Rabbit Hole by wizhi on Tuesday March 30, 2021 @04:30AM (#26632304)
Do you possibly have any example projects you would be willing to share?

I've been getting into Go for the past couple of months, but I still struggle with this.