-

@ mleku
2025-02-25 12:59:14
ok so they are just another silly name for interfaces, but trying to say they are not interfaces
you can do that now with interfaces with generic parameters in Go since 1.24, this "prototypes" thing
it's a relaxing of a rule that you can't define external (not in package) methods on a type, you can now define methods on a type alias
i barely even use generics in Go yet, mainly i just use it to make it so people can call my code with strings but my internal implementations remain in mutable bytes. they won't retract the mistake of making strings immutable
rust's immutable by default is exactly the opposite of how i think it should be done, and the immutables in Go are the biggest pressure on GC because you can't just make them into freelist buffers, they are immutable, they have to be disposed with the GC unless you want to dice with unsafe
also, in Go, effectively declaring a type is creating a prototype, because you can embed them in other types, you can alias them into new types, and now you can even declare new methods on the aliased type
Go lets you do all the things that you need, and rejects all the things you don't, in the overriding prime directive that no construct should be expensive to compile, or execute.