Using Rust with Elixir for code reuse and performance

This page summarizes the projects mentioned and recommended in the original post on

Our great sponsors
  • SonarQube - Static code analysis for 29 languages.
  • InfluxDB - Build time-series-based applications quickly and at scale.
  • - Download’s Tech Salary Report
  • Scout APM - Truly a developer’s best friend
  • cmark

    💧 Elixir NIF for cmark (C), a parser library following the CommonMark spec, a compatible implementation of Markdown.

    I wonder if they looked into using 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).

  • cmark

    CommonMark parsing and rendering library and program in C

    Yeah no doubt it, although in this case the C implementation has been a long running project that's under the official commonmark GitHub repo at

    But I think the most important thing here is an Elixir NIF already exists to use it. The blog post as is leaves readers having to implement ~100 lines of Elixir code to use the Rust version because the authors of blog post didn't include that in the article, or open source it as a library for others to use.

    So from a reader's POV, if your goal is to get a highly stable, fast and safe Markdown parser running in Elixir, the Elixir cmark library I linked in a parent comment solves that problem out of the box.

  • SonarQube

    Static code analysis for 29 languages.. Your projects are multi-language. So is SonarQube analysis. Find Bugs, Vulnerabilities, Security Hotspots, and Code Smells so you can release quality code every time. Get started analyzing your projects today for free.

  • pulldown-cmark

    Author here. I actually was not aware of cmark.ex - thanks for pointing it out.

    In this case the code reuse was more important than pure native speed. We already had a Rust library that used pulldown-cmark [1] with some custom tweaks that we wanted to duplicate. Maybe this behavior could have been copied using cmark.ex too (we thought about doing this in pure Elixir, as mentioned in the post), but given how straightforward Rustler made integrating our existing code, this seems like the better choice.


  • nimler

    Erlang/Elixir NIFs in Nim

    It's one reason I prefer lighter languages for NIF's. My personal preference is to use Nim and Nimler [1]. It generally compiles quicker than Rust while providing most of the same benefits. To be fair compiling a small Rust library doesn't take too much time. Especially compared to the performance numbers from those Rust NIFs!


NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts