Earlier quoted context omitted.
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…
> I haven’t seen any meaningful adoption You must live in a different world. Go has been an immense success since its inception. Cloud, DevOps and SRE are nowadays unthinkable without it.
Generics enabled by default in Go tip
321–330 of 378 posts
Re: Generics enabled by default in Go tip
#322Earlier quoted context omitted.
There are certain things that just can’t be done without generics, though. Type safe higher order functions, type safe custom collections, etc. Of course, perhaps these are all just subjective to you, because you can still write any program you need without them. But not having this feature does constrain the set of type-safe programs you can write quite a bit.
I feel like it pretty much always turns out that the things you can't do without generics are, like, second-order things. Higher order functions, type safe custom collections, those are tools. What we care about mostly is what we actually build , and people build pretty much everything in every language, generics or not.
Re: Generics enabled by default in Go tip
#323Earlier quoted context omitted.
I feel like it pretty much always turns out that the things you can't do without generics are, like, second-order things. Higher order functions, type safe custom collections, those are tools. What we care about mostly is what we actually build , and people build pretty much everything in every language, generics or not.
Yeah, we should have kept using macro assemblers instead of needless abstractions.
Re: Generics enabled by default in Go tip
#324Earlier quoted context omitted.
If people can understand functions, they can understand generics. Nothing more complicated, generics are just functions on a few type arguments.
Here’s an example from this very thread that shows how complex generics get relatively quickly. https://news.ycombinator.com/item?id=28255738
What do you find confusing about that code?
Re: Generics enabled by default in Go tip
#325Earlier quoted context omitted.
Here’s an example from this very thread that shows how complex generics get relatively quickly. https://news.ycombinator.com/item?id=28255738
That example is essentially the most basic use of generics. There are much more complex examples that would support your argument better. What do you find confusing about that code?
A code base that makes heavy usage of generics takes more time to understand than one that doesn’t make heavy use of generics. The readability of go is what I love about it, amongst a few other things.
Re: Generics enabled by default in Go tip
#326Earlier quoted context omitted.
What good are top-level functions if they’re unreachable from any script interpreter or management RPC server or other languages’ FFI?
I fail to see what any of this has to do with reflection. > any script interpreter What are you even talking about. > or management RPC server I would very much expect RPC endpoints to be opted in explicitly and statically. > or other languages’ FFI? I fail to see why Go-level reflection would be involved in that in any capacity. > What good are top-level functions You can call them? From your go code? Are you saying…
Re: Generics enabled by default in Go tip
#327Earlier quoted context omitted.
Parametric polymorphism is a better fit for container types IMHO. There are some interesting notes here… In Go prior to generics, interface{} is an escape hatch less frequently needed but not necessarily much safer than void*. Post generics, interface{} is suddenly more useful and will be aliased by ‘any’. The way the std lib heap works in Go, an implementation doesn’t have to mention interface{}. Using the Go std li…
>not necessarily much safer than void* You can cast void* to anything you want. With interface{} you get a type check, either through an assertion or a panic. That is a big difference in safety.
I was thinking more about silence where someone expected a greater degree of compile-time type safety than they really had, or relatedly e.g. the subtleties in JSON encoding / decoding where there is silent data corruption that could fall through the cracks - mostly I feel like I avoid these things by not using interface{}; I certainly did not grasp that without some experience with the language.
Re: Generics enabled by default in Go tip
#328Earlier quoted context omitted.
Optimizing for people that are new to a codebase seems like a mistake to me: onboarding costs are relatively minimal and finite (per developer) whereas maintenance costs have no fixed bound: if generics let you exclude invalid states by design (and they do: this is one of the biggest advantages of parametric polymorphism vs. interfaces), they will be useful for keeping maintenance costs under control.
You definitely want to optimize for people who are new to a codebase. Over enough time, the codebase grows to a point where essentially _everyone_ is new to each area of the code, because nobody has touched that code in 2-3 years and the person who wrote it may not even be with the project anymore. Even for your own single-person projects - if you get fancy with the code, 6 months later you find it's a lot harder to…
Re: Generics enabled by default in Go tip
#329Earlier quoted context omitted.
Yeah, we should have kept using macro assemblers instead of needless abstractions.
If you believe that absolutely, the way you imply here, then we're all just chumps for not working in Haskell.
At the end of the day, whatever gets the product built is what matters. I just fail to see how generics could be a hindrance.
Re: Generics enabled by default in Go tip
#330That said, I think some of them may have a point that Go shouldn't actually try to tack on generics now. Consider that generics are only one piece of the puzzle when it comes to programming language power and abstraction capability. There are also ADTs, abstract types, pattern matching, immutability, lack of null, expression-oriented syntax, etc.
Go with generics would be only one step along that journey of abstraction power. It would help the set of people who desperately need it to solve their code repetition and type-casting issues. But it would solve these problems just to clear the way for them to reach the next set of problems on the journey of abstraction.