Hacker News new | ask | show | jobs
by faitswulff 2673 days ago
For the curious, xb95 was kind enough to tell me how they call Rust from Elixir - it's via Native Implemented Functions:

http://erlang.org/doc/tutorial/nif.html

> As a NIF library is dynamically linked into the emulator process, this is the fastest way of calling C-code from Erlang (alongside port drivers). Calling NIFs requires no context switches. But it is also the least safe, because a crash in a NIF brings the emulator down too.

Sounds like a pretty good use for Rust!

2 comments

Wonder if they use rustler [0], which claims it cannot crash the BEAM. Looks pretty good.

[0] https://github.com/hansihe/rustler

We do indeed. Rustler is very cool!
Sonny Scroggin of Bleacher Report gave a talk about writing NIFs in Rust (using Rustler) at last year's Code BEAM SF conference -- the video's on YouTube:

https://www.youtube.com/watch?v=F86JXaCPowo