News for hackers. Stuff that matters.
Re:Write Elixir NIFs in Rust by jedisct1 on Sunday August 06, 2023 @04:44AM (#37020110)
There's also Zigler, that makes writing NIFs in Zig a breeze: https://github.com/E-xyza/zigler
Re:Write Elixir NIFs in Rust by veber-alex on Sunday August 06, 2023 @06:57AM (#37020742)
I am confused by the examples, do you actually need to write your code as a text string?
Re:Write Elixir NIFs in Rust by cassepipe on Sunday August 06, 2023 @07:12AM (#37020807)
Well it seems that those are two different approaches.

Rustler being a Rust library to write Rust NIFs for Elixir. So I guess you have to compile the NIF first and then use it.

On the other hand Zigler seems to be an Elixir library that you give a string of zig code and it probably offloads compilation to the zig compiler. Since Elixir is compiled to bytecode, if you don't modify it won't get unecessary recompiled I guess so the approach has merit I think.

Btw it's a sigil'ed string, that is the result of a function that takes a string and returns one rather than a string literal

Re:Write Elixir NIFs in Rust by alberth on Sunday August 06, 2023 @11:31AM (#37023002)
This is way less safe than Rust.

NIFs have a major downside in that it can take down the entire BEAM if they misbehave.

And a huge reason why people use Erlang, is its resiliency from outages.

With Rust memory protection, it gives people more confidence in using NIFs for exactly that reason.