3 ms·
> Though nix also just wraps the FFI unsafe blocks. So? How they provide safe APIs doesn't matter, what matters is that they are safe. If the C FFI API is alwa
by fluffything 7y ago
> Though nix also just wraps the FFI unsafe blocks.
So? How they provide safe APIs doesn't matter, what matters is that they are safe. If the C FFI API is always safe for all inputs, then wrapping it in an unsafe block is the right thing to do.
> but the interfaces they provide make it harder and less idiomatic to hook into libc.
The interfaces they provide are both safe and portable over pretty much all UNIX-like systems (MacOSX, Linux, FreeBSD, OpenBSD, NetBSD, DragonflyBSD, Solaris, ...). libc interfaces are platform specific.
- cyphar 7y agoI agree that unsafe { libc::foo() } is generally fine assuming the inputs are sane, but my point was more that nix is somewhat of a glorified unsafe wrapper that isn't always necessary. But my issue with nix wasn't portability, it's that quite a few of the APIs they provide are more-frustrating-than-necessary.