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

Why, closed libs would just have a C interface.


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.


They only have to look into how Ada has figured it out for 40 years ago.


Does Ada have a stable ABI? Do you have to distribute an interface document like a header file with your binary libraries?

I'm curious how they solved generics in libraries. Can't find anything in the documentation, but maybe I'm looking in the wrong place.


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.


Right, but without generics




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

Search: