Live data from Hacker News

Generics enabled by default in Go tip

go-review.googlesource.com

261–270 of 378 posts

Re: Generics enabled by default in Go tip

#261

This is actually my first week using go (from years of C++/Swift/js/etc) and I’ve been very impressed with the module system and simplicity so far. I’d definitely encourage others to try it if they haven’t. As for generics, Go’s lack of function overloading and arg default values is really interesting. It ensures that a function is always easily found as it’s the only thing in the module with that name. I’ll be curio…

> As for generics, Go’s lack of function overloading and arg default values is really interesting. It ensures that a function is always easily found as it’s the only thing in the module with that name. I’ll be curious to see if generics are easier to follow without function overloading. There are already a number of langages with generics and without overloading (or defaults). Haskell, ocaml, rust, …

True of OCaml and Rust (and many others), but Haskell certainly has overloaded functions through type classes. In fact, once OCaml gets implicit modules, this won't be true anymore of OCaml either.

Re: Generics enabled by default in Go tip

#262
post #236
post #2

Wow, it's happening! For others completely out of the loop on that there was even an accepted proposal that is now being implemented: https://go.dev/blog/generics-proposal

As an outsider planning to eventually learn Go, I have two questions: 1. what's "Go tip"? 2. does this allow us to approximate when it could make it to one of Go's stable releases? I guesstimate it's something that would land not sooner than within a year, right?

The "tip" is the head of the development branch.

The plan is to have them available as a preview feature in the next stable release, which is scheduled in about 6 months time.

Re: Generics enabled by default in Go tip

#263

I've never used Go, and from the outside I take a lot of issues with its design choices. But even without having used it I always thought the lack of generics was very interesting and I could see how it was desirable. It's fascinating to me that Go has gotten as far as it has without them (proving that it's possible to), and the mindset shift people describe having around them seems like a really important thing to p…

> It's fascinating to me that Go has gotten as far as it has without them (proving that it's possible to), and the mindset shift people describe having around them seems like a really important thing to pay attention to.

Yes, the mindset of the people was certainly a key part of this, but another key part is that Go has interfaces, which are existential types, which are dual to universal types (colloquially called generics). If the type system is expressive enough (System Fω), you can express one in terms of the other. Of course, Go's type system wasn't expressive enough to realize the true duality, but it was expressive enough to express many things people would have used generics for in other languages.

Other languages which don't have generics don't have existential types either, and people see Go through that lens and don't understand how we got anything done. Well put on some existential glasses.

As an aside, one of the reason it was so hard to develop a good design for generics is that they inevitably interact with interfaces, precisely because of the duality above. Unfortunately, the non-language experts who complained on web forums about the lack of generics in Go for the past 11 years do not understand what that means, but that didn't stop them from complaining. Let me put it another way. There's a reason why Rust traits are not types, but Go interfaces are types.

Re: Generics enabled by default in Go tip

#264

Every HN thread about go: go is useless because it lacks generics. Go adds generics. HN thread: I don't want this. Good case study about the people drawn to comment on a topic.

I don’t know, at this point my guess is that most people just don’t care, so those that can be bothered to comment are a bit fringe.

When Go first came out, it seemed interesting, but when I checked it out it felt more like throwing out the baby with the bathwater than introducing anything of value. Not every idea since 1972 is bad. So I tried to force myself to use it for a project or two, got frustrated by exactly the things people were complaining about, and never looked at it again.

I haven’t seen any meaningful adoption, so my hypothesis is that by not having the features mainstream users want, Go missed its window of opportunity and the world moved on. It’s neat that they’re adding them now, but.. well.. let’s just say that I was an absolute die-hard Perl fan for a long time so I’m familiar with this pattern.

Re: Generics enabled by default in Go tip

#265

Language flamewars on internet forums are... strange. Why have we all so strongly coupled our identities as programmers to the language we use? Sense of community and a perceived need to defend it? I don't think Go needs generics, but I'm not about to invent obscure edge cases to justify for/against the idea. That's a recurring theme in all defenses of any language. It's not helpful. Use Go if you like the "clarity",…

Go has generics. They're just not (yet) available for you. So to some it feels like a Tantalus punishment.

If you're referring to map[K]V, that's not true. Go doesn't have generics, it uses some compiler magic under the hood specifically for the map type [0]. The generics proposal is being implemented from the ground up.

[0]: https://dave.cheney.net/2018/05/29/how-the-go-runtime-implem...

Re: Generics enabled by default in Go tip

#266
post #250

I like Go very much, a huge role plays its simplicity. In my career, I have been much more often bitten by having to deal with the complexity of a language then by not being able to do things, because a language feature is missing. That is, why I like Go so much. It strikes a great balance between important high-level features (GC, first class functions and closures) and still being a simple language (like Scheme is,…

I used to really hate Go's attitude to generics and type system features in general. I still do, but I appreciate that it's a matter of taste, and that different people have different tolerances for language complexity. People who like simplicity can use Go and people who like type systems can use Rust.

Re: Generics enabled by default in Go tip

#267
post #250

I like Go very much, a huge role plays its simplicity. In my career, I have been much more often bitten by having to deal with the complexity of a language then by not being able to do things, because a language feature is missing. That is, why I like Go so much. It strikes a great balance between important high-level features (GC, first class functions and closures) and still being a simple language (like Scheme is,…

I roll my eyes when someone claims "I learned Go over the weekend". It's one thing to learn basic syntax, and completely another to learn the customs of your new environment so most can understand what you are doing.

Go is one of the hardest languages to learn. First of all, some concepts in it are very different from "mainstream" languages, and it takes a while to get used to them.

Simple things that exist in almost every other ecosystem can be absent in Go. Want to run setup code before your test suite? You on your own, buddy. And, oh yeah, 2/3 of your code will be `if err` statements, because exceptions are passé.

I learned it by seeking out good Go codebases, which are incredibly rare. Hashi's Terraform comes to mind.

Infamously, the early Kubernetes code was a nightmare because it lifted and shifted Java idioms and that was at the company that invented the Language.

Or at Uber, where they passed on Go's native goroutines and channels in favor of homegrown concurrency, for SOME reason: https://eng.uber.com/go-geofence-highest-query-per-second-se...

All this to show that Go is not a simple language to do well, so let's dispense with that myth.

It has its uses, but having done it, I would never recommend Go for a greenfield project in my place of work - there are very few rules that come with it, and it requires tons of coordination and discipline among a team. And if you have to work with 2 or 3 other people who have strong opinions on how to do things in Go, watch out.

Re: Generics enabled by default in Go tip

#268
post #227
post #221

Earlier quoted context omitted.

Google have alternatives to k8s already. So it's more about making a market.

I've heard multiple times that Google Cloud has the best support for k8s, and that people moved to it because of that. Is that what you meant by making a market?

That and open sourcing it.

Re: Generics enabled by default in Go tip

#269
post #267
post #250

I like Go very much, a huge role plays its simplicity. In my career, I have been much more often bitten by having to deal with the complexity of a language then by not being able to do things, because a language feature is missing. That is, why I like Go so much. It strikes a great balance between important high-level features (GC, first class functions and closures) and still being a simple language (like Scheme is,…

I roll my eyes when someone claims "I learned Go over the weekend". It's one thing to learn basic syntax, and completely another to learn the customs of your new environment so most can understand what you are doing. Go is one of the hardest languages to learn. First of all, some concepts in it are very different from "mainstream" languages, and it takes a while to get used to them. Simple things that exist in almost…

I have not claimed you can "learn Go over the weekend". Not in a deeper sense where you could expect to design large projects and take the right decisions.

But you can get a pretty good basic Go intro in a few days and be pretty productive after that. It isn't that different from most languages and has a rather small core. Of course, it helps if you have Scheme experience, to understand all the power of high order functions etc.

Re: Generics enabled by default in Go tip

#270

Language flamewars on internet forums are... strange. Why have we all so strongly coupled our identities as programmers to the language we use? Sense of community and a perceived need to defend it? I don't think Go needs generics, but I'm not about to invent obscure edge cases to justify for/against the idea. That's a recurring theme in all defenses of any language. It's not helpful. Use Go if you like the "clarity",…

When I started programming in Go after a decade of Java[1], I found it painful to not code without generics but then over the past couple of years I've become used to it.

I understood the philosophy of Go and why it didn't have generics or may be I'm just convincing myself of that because I'm invested in it. I think when you accept the philosophy of something you already get coupled into it.

I don't really have an opinion about Go bringing in generics, I would use every time saving feature available in a programming language. On the other hand I really hope additions like these doesn't become a point of friction among those who really have an opinion, Especially those who have been contributing to Go and end up forking Go.

[1] https://abishekmuthian.com/i-had-to-let-go-of-java/

Post reply on HN