4 ms·
there's nothing magic about generics. every time you make a channel or a map in go, you're using a generic function even if go people don't want you to call it
by baq 9y ago
there's nothing magic about generics. every time you make a channel or a map in go, you're using a generic function even if go people don't want you to call it that.
there's nothing magic about exceptions, too, it's that it's harder than necessary to use them correctly and that's why it's not as big of a deal to not have them in go - as evidenced by this thread.
- why-el 9y agoCurious, how is a map generic?
- concede_pluto 9y agoIf you declare a map[string]int, Go will guarantee that keys are always strings and values are always ints, and it's a compile-time error to pass it to someone expecting a map[string]float64. Without generics, the only way to do that is to generate and compile a MapStringInt struct and a MapStringFloat64 struct and a...
- wtfrmyinitials 9y agoI can sympathize with the dislike of exceptions. I very much prefer Rust's error handling model (return Result<T, Err>) The fact that Go has had this much success without generics is mind-boggling to me.
- pjmlp 9y agoBecause Google. Go is quite similar to Limbo, by some of the same authors, how much success did it have outside AT&T?
- fanf2 9y agoLimbo was not freely available.
- pjmlp 9y agoVita Nuova has it on an open source license since March 2000, which means it has been freely available for the last 17 years!
- koffiezet 9y ago> Because Google. No, it was adopted quickly because it's a simple, script-like language producing static binaries that didn't require any runtime, highly portable with built-in cross-compilation, requires very little resources, is able to perform pretty damn good and has an extensive standard library (although not perfect) supporting many modern technologies. That are a lot of boxes it ticks off. I remember wanting to start hobby projects with friends where the end-result would preferably be a native binary, and the limit was that I was the only-one with a C/C++ background. Now anyone with some scripting background can pick up Go in a few days, without having to worry too much about a build system, portability, cpu architectures, performance, memory leaks, ... Sure, Google was the initial push, but it only really took off once projects like Docker showed it's potential.
- Animats 9y agoYes, go has generics, or at least parameterized types, used for channels and maps. What it doesn't have are user-defined parameterized types.
- mmargerum 9y agoI think that's the point really. I think the average programmer like using generics, but rarely builds their own code with them. I've used them from time to time to great effect, but the use cases were pretty isolated. Maybe that makes me average? /shrug