> How does Zig handle the monomorphization problem for generics in library APIs?
From the article:
> Cannot distribute binary-only libraries with generic interfaces … Zig doesn’t have this constraint because Zig is designed around whole-program compilation from the start …
So no proprietary (EDIT: (closed)) libs built with Zig, I guess.
Proprietary is a licensing thing, and doesn’t really have to have much to do with the form of the files comprising the software. Plenty of proprietary software gets written in Javascript, for example.
You're going to lose a lot of zig safety and type tracking features that way. I think it's possible that there will somehow be an exportable library abi in zig, but it is not at all on the roadmap. In any case, I don't believe there are obvious ways (I do know sneaky ways to do this) to ship post-compiled-only libraries this any of the programming languages I use on a day-to-day basis and even with venerable C, the "single header library" is all the rage these days
I can even imagine a tool that picks a zig interface and transforms it into a C interface to export it from your closed-source library, and a shim that exposes the nice zig interface that talks to the uglified C interface.
That would be helpful not just for intetfacing closed zig code, but also for dynamic libraries in zig.
I'm only afraid that in many cases that would require doing the monomorphisation step...
You have to be able to export a binary interface of some sort to be able to write operating system components. As Zig is intended for system programming, the Zig implementers will surely figure this out eventually.
No it doesn't, it is just like most compiled languages, the ABI is the compiler version.
Ada packages, just like most module based languages have the necessary metadata on the libraries themselves, no need for header files.
Just like C doesn't have a stable ABI per se, there is some overlap with code produced by C compilers with the OS ABI, when the OS happens to be written in C, and that is about it.
> So no proprietary (EDIT: (closed)) libs built with Zig, I guess.
And frankly, that's a good thing. Working with libraries that are only distributed as a binary blob and header files is a pain in C++ and even C, even something as simple as different compilation settings may introduce all sorts of weird problems. If distributing your plain source code is an issue, then use a code obfuscator. That's just as "safe" as distributing binary blobs, but still much easier to integrate into a project.
> How does Zig handle the monomorphization problem for generics in library APIs?
From the article:
> Cannot distribute binary-only libraries with generic interfaces … Zig doesn’t have this constraint because Zig is designed around whole-program compilation from the start …
So no proprietary (EDIT: (closed)) libs built with Zig, I guess.