3 ms·
I find that's only true so long as the problem you're solving fits well into Go's view of the world. If you want to make a data structure holding the equivalen
by josephg 5y ago
I find that's only true so long as the problem you're solving fits well into Go's view of the world.
If you want to make a data structure holding the equivalent of a parametric enum (or tagged union from C), go is very awkward to use compared with richer languages like Swift or Rust. Go is also awkward if you want to implement custom generic data structures.
Eg, this[1] code I wrote a couple years ago for doing text based operational transform became about 1.5x longer in Go compared to rust or typescript because its so awkward to express a parametric enum in go. And it was much harder to read & more buggy as a result. Sadly I lost the go version of the code. I'd be curious if someone with more go experience could do a better job, but I'm skeptical.
Hopefully the situation improves somewhat when generics land.
[1] https://github.com/josephg/textot.rs/blob/03c84b7c35a375ba7dbb9c3db38923aaced4cccc/src/lib.rs https://github.com/josephg/textot.rs/blob/03c84b7c35a375ba7d...
- throwaway894345 5y agoI agree that enums are the thing that Go is lacking. I would really like first-class enums perhaps even more than generics. Hopefully we get them.