Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What form of interfaces would you want? Something trait-based? Rust's orphan rule has bitten me many times now, and it causes consolidation around certain libraries. Something like Go's interface, where the signature just needs to match? That would be nicer than the current situation with `anytype`, but I don't know if it's better enough to justify a full interface system. Curious to hear your thoughts.




Essentially enough syntactic sugar so you could write eg the Allocator interface without manually specifying the vtable and the opaque pointer.

But yeah, Go’s system is nice and simple. I am not sure, but I think the fact that Zig programs are a single compilation unit might have some bearing on the orphan rule. There is no concept of crates so “traits”/interfaces can be defined and implemented anywhere.


That's a good point that it's all a single compilation unit which removes the orphan rule problem, but it still has the issue that there could be multiple different implementations of a trait, each from a different dependency.

Though, I am seeing your point on a simple interface system that would be enough to have something like the allocater interface, or the hash map interface.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: