waseigo

waseigo

I let LLMs write an Elixir NIF in C; it mostly worked

This post documents how I built a cross-platform Elixir NIF in C to get on-demand up-to-date disk-usage stats without relying on os_mon and its disksup service. I had Grok 3 generate the initial C code and Makefile, then iterated through multiple code reviews by Gemini 2.5 Flash and GPT-5 to make it work on Linux, macOS, Windows, and the BSDs (except DragonFlyBSD).

Along the way, I ran into typical LLM hiccups that speak volumes about the breathless hyperbole often peddled by LLM vendors, compute providers, and over-enthusiastic consultants, middle managers and executives on LinkedIn. Nevertheless, the result is a working, cross-platform Elixir package on Hex.pm, plus a real-world case study in where LLMs shine, where they fail, and what “human-in-the-loop” can mean in practice.

Spoiler alert: the hype is exactly that; even so, we ended up with working code that is, at the very least, a solid starting point for further improvements by actual general intelligence.

Most Liked

krasenyp

krasenyp

It mostly worked means it didn’t work. Good job getting it there though.

dimitarvp

dimitarvp

Should have asked me in a DM, would have told you to use Rust from the get go. :smiley:

Now if I can only fix the strange out-of-memory in the GitHub CI runners, I’d be able to finally release my library… (It’s not because of Rust though, my tests so far have put it somewhere in the native building stack in a previous stage of the entire process, or a compile-time switch.)

If you have questions how to best work with Rustler, just ask.

waseigo

waseigo

Are you kidding me? After seeing the output of splint, I’m in awe at Linux, if anything :slight_smile: I’m not surprised. I’m very positively surprised by Rust though.

But I’ll stick with Elixir!

dimitarvp

dimitarvp

Why not actively use both, like me? :smiley:

Making stuff work with C is nearly the same as making stuff work with Python: it is working despite the language. Not because of it.

dimitarvp

dimitarvp

I love Elixir and so far to me it is irreplaceable (9.5 years after discovering it). It covers aspects that so many other languages / runtimes don’t even dare begin tackling (Rust and Go are exceptions but they just don’t take the problem seriously enough and as such kind of accidentally try to invent their own BEAM, badly).

I am saying that my attention can be on multiple things. Focus is hugely important and it’s been a lackluster part of my methods (one that I am actively fixing lately) but I also find it extremely important to have more tools in my bag so I can practice the “right tool for the job” confidently.

Where Next?

Popular in Blog Posts Top

marcelo
Long story short, over the past years we’ve been scaling our operation quite a lot at Unbabel. Most of our codebase is Python and some of...
New
paulanthonywilson
https://furlough.merecomplexities.com/elixir/otp/tdd/2021/03/18/test-driving-otp-creating-a-registry-with-expiring-entries.html Followin...
New
paulanthonywilson
All a bit meta, but this is a quick post on creating a Jekyll blog post from a Livebook page. Posted via Devtalk (see this thread for ...
New
New
lawik
Building on other people’s work I bashed things together and suddenly I can know when someone is speaking using Elixir and Membrane.
New
rrrene
In this series, we take a look at the different ways to organize, structure and execute a good “flow” in our Elixir programs. The latest...
New
stryrckt
Support for AlpineJS in LiveView was added in 0.13.3 and it works fabulously. I just wrote a blog article about it and plan another one s...
New
Paradox
Testing is an important part of any modern piece of software. But writing tests can quickly become an exercise in frustration, with tons ...
New
New
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New

We're in Beta

About us Mission Statement