(no title)
paoda | 3 years ago
In service of this, even in Zig's current pre-1.0 state, adding a library can be as simple as something like the following in your project's build.zig:
// Argument Parsing Library
exe.addPackagePath("clap", "lib/zig-clap/clap.zig");
This and the language just having generics (which isn't necessarily the goal of all c-replacement languages i recently found out) suggests to me that the language as it currently stands encourages libraries to be written and reused.In Zig, allocators are "just another argument", functionally an interface so as a library author you have to pay less attention to whether your library can be used in hostile environments. I'm quite sure this idiom exists primarily to just make Zig libraries (like the stdlib) useful in more places.
Certainly, Zig doesn't have all the tools you'd expect in other languages to aid library authors and consumers. I personally would love to see proper interfaces in the language, rather than the interface-by-convention situation we have right now. It's a matter of tradeoffs, many of which I imagine will be addressed and reconsidered as the language matures.
No comments yet.