4 ms·
Go tools support code generators. So just use those for advanced data structures. As auto-generated it can support more features than even an advanced generics
by fpoling 11y ago
Go tools support code generators. So just use those for advanced data structures. As auto-generated it can support more features than even an advanced generics could provide.
For me the big minus of Go is that it is memory unsafe language when it runs with GOMAXPROCS>1 (default since 1.5). It is not that bad like in C as opportunities for bugs are not common, still this is an issue as consequences of such bugs is arbitrary code execution.
Another problem is lack of union types leading to poor code practice when those are emulated through (foo, err) or similar return types.
- pcwalton 11y ago> As auto-generated it can support more features than even an advanced generics could provide. No, it can't. There are patterns that no monomorphization strategy (including code generation) can express. For example: func MakeList<T>(x T) List<T> { ... } func Foo<T>(x T) { if ... { Foo(MakeList(x)) } } This is a contrived example, but this shows up from time to time in functional data structures.
- fpoling 11y agoCode generation can do type erasure starting, for example from List<List<SomeConcreteType>>.