4 ms·
I just want Zig with classes, Zig++. :(
by loxodrome 10mo ago
I just want Zig with classes, Zig++. :(
- Mond_ 10mo agoWhat exactly do you need that Zig doesn't have? Inheritance?
- cgh 10mo agoProper interfaces would be nice. I realize that eg tagged unions work for most cases but the syntactic sugar would reduce a bit of friction.
- smj-edison 10mo agoWhat 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.
- cgh 10mo agoEssentially 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.
- smj-edison 10mo agoThat'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.
- GoblinSlayer 10mo agoAllocator can be implemented as one function pointer - recallocarray, see https://man.openbsd.org/calloc.3 https://man.openbsd.org/calloc.3
- TSiege 10mo agoIsn't the whole point of zig that it eschews classes and object oriented programming?
- dnautics 10mo agoYou can bind functions to structs and first parameter is special cased when it's a pointer-to or a const version of the structs... What more do you want really besides inheritance (which is considered dangerous by many). In the era of LLMs do you really want that sort of "hidden action" that you force the LLM to inefficently reason through?
- F3nd0 10mo agoOr possibly Objective-Zig. :-)
- _ea1k 10mo agoI'd expect that to get swiftly replace by something else.
- fuzztester 10mo agoQuickLang?
- fuzztester 10mo agoI'm longing for Zig--. :( And also for Hype-- about all these newfangled langs.