5 ms·
Nice. I thought that Zig would be a nice language for writing NIFs - but of course Rust would be good too. Cool!
by doctor_phil 3y ago
Nice. I thought that Zig would be a nice language for writing NIFs - but of course Rust would be good too. Cool!
- rubin55 3y agoZigler! https://github.com/E-xyza/zigler https://github.com/E-xyza/zigler
- deleted 3y ago[deleted]
- impulser_ 3y agoRust perfect for this because Rust code can be very reliable which is needed for NIFs in Erlang because a NIF can crash the whole VM. So using C and Zig libraries without fully understanding them can be a death trap while in Rust as long as it doesn't use unsafe code you can feel pretty good about using it.
- cybrox 3y agoThis has nothing to do with Rust itself. While the compiler does prevent a lot of common pitfalls, you can still write erroneous code with it. It's entirely the rustler project's effort (and goal) to wrap any kind of Rust program so that it will not bring down the BEAM under any circumstance, which they have done a great job achieving.
- filmor 3y agoIt's still to a large degree Rust itself. It's the language design which makes it possible to wrap the NIF C API in a safe fashion (e.g. using lifetimes, phantom data, etc.). The only additional safety feature we use is catch_unwind (https://doc.rust-lang.org/std/panic/fn.catch_unwind.html https://doc.rust-lang.org/std/panic/fn.catch_unwind.html) to prevent panics from unwinding into the BEAM (and killing it).