November 16, 2025
OCaml vs C smackdown
Linux mode setting, from the comfort of OCaml
Dev drives Linux screens with OCaml; comments ask: comfy or chaos
TLDR: A developer made an OCaml tool to control Linux display settings interactively. The crowd split between curious 'is OCaml comfy?' questions and classic language wars, with praise for REPL tinkering and skepticism from C loyalists and 'why not Rust?' hecklers.
Linux’s display controls just got a glow-up: a developer wrapped the clunky C interface in an OCaml library, letting you poke your screens from a live coding prompt. It’s called libdrm-ocaml, and the demo walks through listing hardware, flipping a bitmap, and even a tiny 3D animation. Acronym decoder: KMS means Kernel Mode Setting (the low-level display knobs), and a REPL is an interactive prompt where code runs as you type. You can try it with Nix or opam, two ways to install stuff. The post promises a friendly intro even if OCaml feels mysterious.
And the comments? Absolute popcorn. The top vibe: 'Is OCaml comfy?' with readers reminiscing about the OCaml-made Orpie calculator while wondering if this language is cozy or quirky. Then the language wars light up: OCaml fans cheer REPL magic, C traditionalists grumble 'verbose means control,' and Rust onlookers ask, inevitably, 'why not Rust?' Package drama shows up: Nix vs opam sparks jabs over setup pain versus polish. Wayland folks peek in, terminal purists clutch pearls, and jokesters whisper, 'Press ;; to brick your monitor.' It’s nerdy chaos, memes, and sincere curiosity about making low-level graphics feel human.
Key Points
- •The article introduces libdrm-ocaml, an OCaml interface to Linux’s KMS API for interactive display configuration.
- •Setup can be done via Nix (git clone, nix develop, dune utop) or via opam (opam install libdrm utop; #require "libdrm";;).
- •Device discovery is demonstrated with Drm.Device.list, which scans /dev/dri and uses /sys to gather PCI metadata.
- •Primary vs render nodes are explained; the primary node is opened with Unix.openfile to configure monitors.
- •KMS resources are listed with Drm.Kms.Resources.get, and driver details are retrieved via Drm.Device.Version.get (amdgpu).