4 ms·
About generics, this is highly debatable. This is a design choice, it's not a decision made by accident. You'll surely gonna have boilerplate code in some cases
by gendoikari 11y ago
About generics, this is highly debatable. This is a design choice, it's not a decision made by accident.
You'll surely gonna have boilerplate code in some cases, but all the language will be a lot more readable, and simple.
Simplicity it's the most wanted feature of Go, from the designers perspective, I think.
In the long term it's preferable to have explicit and simple code, instead of complex magic.
This is a correct view? We'll see.
Honestly I'm starting to appreciate that. They may have a good point.
- moultano 11y agoWithout generics, you can never write a type safe datastructure. I can't imagine the hubris that thinks the language already contains all of the datastructures it needs.
- kyledj 11y agoThis isn't true. You can write a type safe data structure. It is simply for one type; you can't share it. That inability to share is the part that generics fixes, but saying you can't write type safe structures is inaccurate.
- mercurial 11y agoHow is code with generics more complex than without it?
- rbjorklin 11y agoThey're talking about the compiler and the language spec not Go code.
- mercurial 11y agoThat's not how I interpret parent's comment.
- gendoikari 11y agoFor example the C++ templates rules are themselves a turing-complete language. If by generics you meant some really basic features, I think you can do pretty well with interfaces. They're already in the language. If by generics you meant the full-package, i think you could end up with something pretty complex all the time.
- mercurial 11y agoMost generic implementations are not Turing-complete, and looking at C++, this doesn't sound like a particularly tempting proposition. And while I'm not particularly familiar with Go, I don't see how you can get a feature set equivalent to a simple implementation like Java's out of Go interfaces ("you can just cast" is not a good answer).
- gendoikari 11y agoI'm probably missing the use case. What is the problem that you are thinking of, you can't solve with a Go interface?
- mercurial 11y agoSay, a generic container.
- TuringTest 11y ago> all the language will be a lot more readable, and simple. Simplicity it's the most wanted feature of Go This is what Java designers thought as well. See where this has led them.
- deleted 11y ago[deleted]