Open source · Rust · seismology

Does the compiler help the agent?

Srdjan Sarikas · · 3 min read

I rarely see people discuss AI-assisted development in compiled languages, so I tried it myself. The task: a small library for reading wfdisc files, a workhorse format of many seismic systems. I built it twice, in C++ and in Rust, with the same coding agent. On purpose, I ran it on a mid-sized model (Sonnet) rather than the strongest one: the point was to find where it struggles.

What a wfdisc file is

A wfdisc is a catalogue: fixed-width text rows, one per waveform segment, each pointing at binary samples in another file and carrying station, channel, start time, sampling rate and calibration. Two schemas are in use (CSS 3.0 with 283 characters per row, NNSA KB Core with 287), nine binary sample encodings, and decades of exports that don’t quite follow either.

C++: chasing segfaults

In C++, the agent kept going down the same path: a segfault, a guess, another segfault. Progress was real, but hard to steer.

Rust: the compiler as a reviewer

In Rust, many of the same mistakes surfaced at compile time, with an error pointing at the line. The agent got a tight, precise feedback loop, and I could spend my attention on the format instead of on memory bugs.

A fair caveat: a frontier model (Opus) writes a library like this in C++ without much trouble. The difference showed up because I deliberately worked near the smaller model’s limits. My impression, from one experiment rather than a benchmark: the closer you work to those limits, the more the language matters, and the more a strict compiler pays for itself.

Checked against ObsPy

A faster build is worth nothing if the samples are wrong. The crate bundles ObsPy’s CSS test fixtures unchanged and checks its output against two independent references: the css2ascii tool that ships with those fixtures, and snapshots from ObsPy itself (start time, sampling rate, calibration, sample count, first and last samples, minimum, maximum and sum).

Real exports are messy, so the reader recovers common non-canonical rows by default, and offers a strict mode when only fixed-width rows should pass.

cargo add wfdisc

crates.io ↗ GitHub ↗ docs.rs ↗