3 ms·
They haven't said "No" to generics. What the developers want is for people to submit _actual_ problems that generics would solve, with examples. Because there
by theshrike79 9y ago
They haven't said "No" to generics.
What the developers want is for people to submit _actual_ problems that generics would solve, with examples. Because there are more than a few way to do it and they want to pick the right one.
- kmicklas 9y agoIt's simply astounding that the Google engineers working on Go lack the imagination to understand what problems generics would solve.
- sctb 9y agoWe've asked you twice before not to do this and now you're at it again, so we've banned the account like we said we would. If you would like to comment within the guidelines, we'd be happy to unban your account. https://news.ycombinator.com/newsguidelines.html https://news.ycombinator.com/newsguidelines.html
- erik_seaberg 9y agoThat's easy. Concurrent access to maps is unsafe. https://golang.org/pkg/sync/#Map https://golang.org/pkg/sync/#Map should be a drop-in replacement but due to the lack of generics it can't present a compatible or typesafe API.
- terminalcommand 9y agoI've run into concurrency problems using maps while writing an irc client. It was really frustrating for me, because it did not happen everytime I ran the program, but rather rarely. I had chosen Go for it's memory-safety and easy concurrency. But I felt like I could not vouch for my program's safety any more. I did not know about sync/map at the time, had I known, I would probably have used it. I think Golang has a fondness for magical (to me) special language constructs. For example if you want to use the RPC modules, you have to write your functions a certain way. Or as I've explained in a comment above, if you want to use an interface you just have to implement all it's properties. Or you can't have generics, but we have a special language construct called maps, where you kind of can mimick genericks but it is not safe and may break. Golang is a great language, but I think it expects all its users to think very rigidly in the same way their designers do. Basically, you have to explore the language's deficiencies yourself, read the designers' explanations, dive into the intrinsics of the language, understand it, make yourself believe and move on. I sometimes half-jokingly feel like Golang follows the principle of most obedience.
- kjksf 9y agoFor concurrency issues, -race flag is your friend. Don't blame the language for your buggy code. Unless otherwise stated, Go's data structures are not thread-safe. Maps are not thread safe. In that respect Go isn't different from any other mainstream language with pre-emptive threading (C++, Java, C#).
- wbl 9y agoBut I can't implement a drop in compatible concurrency safe map.
- coldtea 9y agoDon't blame the language for that: jump through BS hoops to create one such map /s
- coldtea 9y ago>Don't blame the language for your buggy code. No, DO blame the language if its the one that enables and allows for said buggy code when it could as well prevent it. Case in point: http://lambda-the-ultimate.org/node/3186 http://lambda-the-ultimate.org/node/3186
- hackerfromthefu 9y agoFair enough, in that case. However a common situation is that the language is supporting a wide range of uses, not just the use a particular developer has in mind at the time. I've seen this most commonly where a developer operating at a higher level of abstraction, without understanding low level details, complains that the language doesn't match his high level needs exactly. When in fact it supports lower level operations for maximum performance or flexibility, while allowing layering on top for higher level uses. In language design it's essential to support the lowest level use cases you are targeting, because you can build on top but not go lower than the language exposes (unless it supports embedded asm or another trick to go lower again). I'm using higher/lower here only to refer in the sense of the level of abstraction. It's a really common trap for someone working usually at one level of abstraction and not deeply understand other levels, to not understanding why a language or library is the way it is because if needs to support others users needs that are different to ones own - I've done it myself enough to detect the pattern, and seen lots of other people do it. Lurking on design committee discussions can be eye opening!