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

https://news.ycombinator.com/rss Hits: 10
Summary

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. What set this off? I was working on my new book, Elixir File Browsing (readers of Northwind Elixir Traders : it’s not published yet), which is about developing an Elixir client for the undocumented REST API of File Browser . I had reached the point of developing the enough_space_to_download?/3 function that “gates” file downloads from the File Browser server based on whether there is enough space to actually store the file on a local path. Using Erlang’s os_mon After looking online for an Elixir function that does this, I found the Check disk space inside elixir thread on ElixirForum. The guidance therein is to use the disksup service of Erlang’s os_mon OS monitor application. It’s possible to use :disksup.get_disk_info/1 to get the total space, the available space, and the percentage of disk space used, but there are a few caveats: You have to add :os_mon to the :extra_application in mix.exs, so that you have access to :disksup.get_disk_info/1 . The default configuration of disksup is to check disk space e...

First seen: 2025-08-15 17:22

Last seen: 2025-08-16 03:24