from Hacker News

Using Rust with Elixir for code reuse and performance

by NiklasBegley on 8/19/21, 12:27 PM with 19 comments

  • by Zababa on 8/19/21, 4:57 PM

    > Unsurprisingly, Rust outperforms Elixir by 2 orders of magnitude.

    That seems very surprising to me. Is this a common result? I've heard that the BEAM is not the best for "number crunching" code, is this one of those scenarios? Is this really just the raw performance of the languages, or a difference in algorithms? There's also no mention of the version of Elixir and the OTP. Did the JIT change anything?

  • by nickjj on 8/19/21, 2:12 PM

    I wonder if they looked into using https://github.com/asaaki/cmark.ex which is an already made Markdown Elixir NIF written in C. No glue code needed since the package already exists.

    Back when I was writing Elixir, it's what I used to process Markdown and it was also substantially faster than the native Elixir Markdown library (Earmark).

  • by latch on 8/19/21, 4:36 PM

    One thing to keep in mind is that even the simplest Rust NIF will significantly slow your builds and increase your repo/artifact sizes.
  • by bb1234 on 8/19/21, 4:55 PM

    For someone who does not know much about NIFs, will it be a lot slower if the Rust service is coded as a command line application and then invoked using System.cmd? Is that a good alternative?