Hacker News new | ask | show | jobs
by BrannonKing 728 days ago
The article doesn't go into pointers to interfaces, which is a place of many footguns. It also leaves out generics. Suppose I have this structure:

  type State[TValue cmp.Ordered, TCost any] interface {
    TransitionTo(context Context[TValue, TCost], value TValue) State[TValue, TCost]
    ... other methods
where Context is also a generic interface. I should add a TContext generic type to State instead of casting it inside my State implementation. It definitely leads to a proliferation of generic types being required on all methods that touch these things. I used to use Go for its terseness. Generics make it much less terse, but I like what they enable.