5 ms·
I wish Go had sum types too. But I like being able to write a mutable tree structure without first having to read a whole book on the subject and inventing a ne
by tptacek 1y ago
I wish Go had sum types too. But I like being able to write a mutable tree structure without first having to read a whole book on the subject and inventing a new system of pointers. Every language is tradeoffs.
- zerr 1y agoAs a C++ dev, such comments reinforce my hesitation to pick up either Go or Rust seriously :) It seems I already have the golden middle after all.
- allovertheworld 1y agoIf only C++ had a fully supported cargo system
- EnergyAmy 1y agoI like the language saying "it's not as easy as you think" when I'm about to do something ill-advised like roll my own mutable tree structure.
- bobbylarrybobby 1y agoI mean, it is as easy as you think in a GC language
- deleted 1y ago[deleted]
- tptacek 1y agoYou understand that tree structures aren't just lookup tables, right? I wouldn't roll my own red-black tree (Jesus how tedious would that be). That's not what I'm talking about.
- dilyevsky 1y agoIt is in fact not that hard when your memory is automatically managed
- p2detar 1y agoYes, the language does not have ADT support, but there are projects that enable this, like https://github.com/alecthomas/go-check-sumtype https://github.com/alecthomas/go-check-sumtype.
- ninetyninenine 1y agoPointers are orthogonal to sum types. They are completely different things and there is literally no tradeoff for the two things you describe. So you’re not making any sense.
- tptacek 1y agoNo, you simply misread the comment.