3 ms·
How do you make a custom, generic data structure without syntax overhead? In real-world code, the need for generic data structures is shockingly uncommon. It r
by personZ 12y ago
How do you make a custom, generic data structure without syntax overhead?
In real-world code, the need for generic data structures is shockingly uncommon. It really is. This requirement exaggeration comes about by people acting as language tourists, building amorphous code of uncertain purpose, where things like "I'm going to sum up a bunch of unknown objects" seems like a serious need.
For most people who find Go to be a compelling language, it excels for practical, real-world needs.
- gnuvince 12y agoNotice how you're not giving an answer to Daishiman's question, merely downplaying the importance of having general data structures, though I'm sure you're quite happy that slices, maps and channels can be parametrized by the type of data they contain. Saying that general data structures are uncommon in the "real world" sounds like an example of Sapir-Whorf. I use Java at work and OCaml for a personal project and in both of them, having data structures that can be parametrized is very helpful. For instance, writing an AST with a type parameter allows to go from a AST<String> (generated by the parser) where ids are strings to a AST<Symbol> where a node's id is now a symbol (generated during semantic analysis).
- deleted 12y ago[deleted]
- Daishiman 12y agoYou're not answering my question. I have a bunch of numeric code where I have dense matrices, sparse matrices, diagonal matrices, etc. I have heterogenous priority queues where I want to push in JSON data and plain strings, I have custom iterators, concurrent data structures, default dictionaries, etc. Seriously, look up Python's itertools and data structure modules and realize that there's a wealth of things that are useful and practical and, above all, reduce code size while preserving interface contracts and semantics. Go is completely unsatisfactory in this regard.