Hasty Briefsbeta

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

9 days ago
  • #LLM
  • #Elixir
  • #NIF
  • The author built a cross-platform Elixir NIF in C to get on-demand disk-usage stats without relying on os_mon and its disksup service.
  • Initial C code and Makefile were generated by Grok 3, with iterative reviews by Gemini 2.5 Flash and GPT-5 to ensure cross-platform compatibility (Linux, macOS, Windows, BSDs).
  • The NIF provides functions to check disk space for a specific path, returning total, used, free, and available bytes.
  • The project highlights the strengths and weaknesses of LLMs in coding, emphasizing the need for human oversight.
  • The resulting Elixir package, DiskSpace, is available on Hex.pm and GitHub, with support for multiple OSs and Elixir/OTP versions.
  • Testing was conducted on various BSDs (NetBSD, FreeBSD, OpenBSD), with DragonFlyBSD being the exception due to Erlang/OTP version constraints.
  • The author reflects on the limitations of LLMs, noting overconfidence and occasional inaccuracies despite their utility in accelerating development.