|
|
|
|
|
by eru
1348 days ago
|
|
Go's design always struck me as really hypocritical. At least it's initial design. Go's designers get to use tuple for their favourite use case: returning from a function. You as a user of the language don't get to use tuples for anything else. (And using tuples to indicate failure is really, really silly. You'd want algebraic datatypes for that. Ie a beefed up enum, not an ad-hoc struct.) Go's designers get to use generic functions and datastructures for their favourite use cases. Eg the infamous `make` is sort-of generic, and Go's arrays, maps and channels etc are generic. |
|
I wouldn't call multiple return values a "tuple". I understand where you coming from, since Python multiple return values are implemented with tuples, but still that point sounds like saying that passing multiple parameters to C functions is "a tuple".
That being said, Go's "simplicity" in design is not only about interface simplicity - it's a lot about implementation simplicity. I imagine that adding tuples would cause a whole lot of complexity that they'd have to deal with. Since Go doesn't have a concept of immutable data types (except consts), tuples would effectively be just variable-typed constant-size slices, which are already implementable as arrays of empty interfaces, but have a runtime overhead...
I hope you see where I'm getting. Creating a language is complex and has a lot of tradeoffs. Then again, I see where you're coming from. I suppose it's a question of whether or not the tradeoffs (the "hypocritical design") is worth the good parts (simplicity of language, which leads to fast compile times, fast runtime, etc.). For me, personally, it is.
Thanks for the input.