Peter Alexander

Posted: • 13 min read

There’s a current trend of LLM-authored software moving away from programming languages designed for human ergonomics (e.g. Python) towards those with other upsides such as higher safety, performance, or iteration speed. From what I’ve seen, many people are rewriting various parts of the software stack in Rust for this reason (Bun, Pokémon Showdown, the TypeScript compiler): it produces fast, safe code and the usual frustrations around having to satisfy the borrow checker may matter less to AI agents. The agentic experience (AX) does not necessarily match the human experience, so we have to revisit our assumptions around what matters in language design.

I’ve been a long-time fan of the D programming language, so my natural inclination here is to look at how D fares as a language for agent engineering. I do believe it has the potential to be a great language for agents (fast, safe code, rapid compilation, powerful abstractions). I’ve been using D with Claude for a long time now and the vibes are good, but vibes are not data: how well does Claude actually work with D? Where does it trip up? How can D evolve to be better for agentic software development?

Fortunately, unlike with humans, it’s quite easy to run relatively large experiments with agents in a controlled manner. In this post, I’ll be exploring how Claude performs with D compared to Go on a set of synthetic problems from langbench.

The setup:

  • 40 synthetic real-world problems such as a JSON Schema validator library, or a card game simulator.
  • All using Claude Sonnet 5.5 in Claude Code.
  • Full test suite per problem available.
  • Asked to “structure it the way a well-maintained open-source D project of this kind would be” (or Go project), complete with unit tests.
  • Instructed not to use an existing library that solves the problem.

Overall, D does well, but does fall behind Go in terms of required output tokens and turns to produce a working solution. The difference is real and meaningful, but modest, and much of the difference is solvable.

D relative to Go: output tokens 1.13×, turns 1.38×, cost 1.19×, with 95% intervals

The rest of this post will get into details of where the differences are and what the D language and ecosystem can do about it.

D relative to Go

The ratios are computed by taking the median over repetitions of the same problem, dividing D by Go, and taking the geometric mean across all problems with a 95% bootstrap interval. Output tokens are the headline number here since they measure how much the agent had to write and think, independently of how it batches commands into turns. D took quite significantly more turns largely due to language-specific costs, but those tended to be cheap edit-build-test loops rather than e.g. significantly more thinking. Ultimately, D costs more because the agent was doing more edit-build-test loops.

D relative to Go Value
Output tokens (paired per problem, 95% CI) 1.13× (1.08–1.19)
Turns 1.38× (1.26–1.52)
Cost 1.19× (1.13–1.25)
Calls spent on language-specific costs D 290, Go 26

Where the extra calls go

The cause of the extra turns was identified via agentic reviewers reading the D and Go session transcripts side-by-side and categorising each tool call into one of four buckets:

  1. Productive work, e.g. writing code.
  2. Language-specific costs directly attributable to a language-specific papercut.
  3. Language-agnostic costs, e.g. wrong expectations in an agent’s own tests, shell slip-ups, etc.
  4. Discretionary work after the task was done.

The key takeaways are that while D does end up using extra calls for productive work, the majority of the difference is D-specific papercuts. Every D session hit at least one D-specific cost.

Tool calls by kind: D 894 productive, 290 language-specific, 293 any language, 154 discretionary (1,631 total); Go 785, 26, 259, 111 (1,181 total)

D’s specific costs

Within the language-specific costs for D, we further categorised them into 14 sub-buckets to understand common D-specific papercuts that agents were hitting. The top four account for nearly two thirds of D’s language-specific costs. Some were broad-and-shallow, affecting many sessions lightly, while others were narrow-and-deep, impacting a small number of sessions significantly.

Note: many of the issues are actually in the tooling rather than the language itself.

D-specific overhead in calls by category, with the number of sessions that hit each

Unit-test failures without values

By far the biggest issue is that, by default, D unit test failures only tell you that an assertion failed (e.g. assert(x == y)) and do not tell you what the values of the compared variables were that led to the failure. This caused the LLM to add extra print statements or grep output to find what actually happened. Not expensive, but it does cost an extra few turns and slows things down.

D has a solution to this with -checkaction=context but Claude didn’t find it on its own. A clear indication of how important defaults are!

In addition to missing context, each test module stops at its first failure, so working through N failures often takes N iterations. By comparison, Go’s test runner lists every failure.

D example (default):

core.exception.AssertError@tests/test_cpu.d(103):
  Assertion failure
----------------
??:? _d_assert [0x104f7d7ef]
…/tests/test_cpu.d:103 void
  test_cpu.__unittest_L100_C1()
??:? int rt.minfo.moduleinfos_apply(…)

D with -checkaction=context:

ca.d(2): [unittest] 3 != 4
1/1 modules FAILED unittests

Go example:

--- FAIL: TestMemoryOps (0.00s)
    chip8_test.go:156: BCD memory: 234 1 2
--- FAIL: TestFX1EAndFX29 (0.00s)
    chip8_test.go:167: I=0x10fe, want 0x10e
--- FAIL: TestTimerTick (0.00s)
    chip8_test.go:208: DT=7 ST=0, want 7 7
--- FAIL: TestDrawCollisionAndZeroRows (0.00s)
    chip8_test.go:244: VF=0 lit=2

dub’s unittest configuration

The prompt asked for “unit tests for the library, in files separate from the library source”. That is less common in D, where unit tests usually live alongside the code they test, but dub handles it fine, and the Go prompt asked for the same. What happened in just over half of the D sessions is that the agent built a unittest dub configuration that didn’t have a main, and then dub test failed with an undefined symbol error at link time for _main.

The fix is to use targetType "library", but it often took agents a few attempts to find it.

Undefined symbols for architecture arm64:
  "_main", referenced from:
      <initial-undefines>
Executable configuration "unittest" of package
sqlitefile defines no main source file

NaN-initialised floating point

A justified, but unusual, aspect of D is that floating point values are default initialised to NaN, e.g. with new double[n]. The idea is that if you forget to initialise then NaN is the most likely thing to cause your program to fail so that you learn quickly that you forgot and go back and properly initialise. Other languages either force explicit initialisation (which requires more sophisticated static checking), or default initialise to 0.0, which is often correct/expected, but sometimes just means that you forgot to specify the initial value and things just surprisingly worked with the default. It’s a deliberate but contentious decision that D makes.

Unfortunately, it is one that tripped up the agent in one task in particular. In all three SAT solver runs, the agent didn’t realise this, and the solver never finished, running until it hit the test suite’s 10-minute limit. Each time, it took quite a while to debug. It also caught out the SVG rasteriser, more briefly. Perhaps a niche case, but anecdotally it is something I’ve seen Claude hit in other contexts as well.

Attributes the agent adds itself

Claude likes to add @safe, pure, nothrow and @nogc in its D code. This is arguably a good thing, but it does then spend quite a few turns fixing the inevitable type checker failures. Self-inflicted, but this appears to be what Claude does with D.

The actual failures themselves were varied:

Smaller language frictions

There were also a number of smaller frictions:

  • const / immutable: const(Value) can’t become Value for concatenation, so the agent strips const across the codebase
  • rvalues to ref: resolve(Registry.parse(text)) where resolve takes ref const Registry. D compilers already accept this with -preview=rvaluerefparam.
  • Names that clash with the implicit object module or a package: capacity; a class named ModuleInfo, dozens of conflicting-symbol errors; function inflate in package inflate.
  • Keywords as names: macro is reserved but unused, and natural in a template engine; real() gives a parse error pointing elsewhere.
  • Runtime semantics: appending after shrinking .length reallocates every time, making a JSON parser quadratic, 6.22 s → 0.06 s once fixed; readText of an empty file returns null; deep-recursion tests overflow the unittest runner’s 8 MB stack with only exit code −11.
  • Phobos: to!double misrounds on arm64, so a shortest round-trip printer showed 0.3 for 0.1 + 0.2; relativePath returns relative paths unchanged.

A compiler bug, again

We also managed to hit an LDC-specific compiler bug that cost some turns. In certain scenarios, an exception can escape a catch incorrectly (only tested on arm64 macOS):

class E1 : Exception { this() { super("e1"); } }

void gen(int op)
{
    if (op == 0)
        throw new E1;
    try
        gen(0);
    catch (E1 e)
    {
    }
}

void main()
{
    import core.stdc.stdio : puts;
    try { gen(1); puts("ok: swallowed"); }
    catch (E1 e) puts("BUG: escaped");
}
$ ldc2 bug.d && ./bug
BUG: escaped

By problem

Compared to Go, there was notable variation across different problems in terms of number of turns. SAT was an outlier due to the NaN issue, and a handful required fewer turns than Go.

Tool calls summed over each problem's runs, D minus Go, for all 40 problems

What would make D cheaper for agents

Based on these results, we can make a few suggestions to the D ecosystem for how to make Claude more effective at writing D:

Change Where Calls Sessions Discussion
-checkaction=context under dub test; report every failure dub, druntime 71 29 dub#2296, forum, dmd#19992, dmd#19576
Executable unittest configuration without a main dub 42 31 dub#1270, dub#2060
Catch reads of NaN-initialised floats compiler, D‑Scanner 38 4 forum (2012), forum (2026)
Infer attributes for non-template functions compiler 37 23 DIP idea
Rvalues to ref by default (-preview=rvaluerefparam) language 12 9 DIP 1016, dmd#22078
Let explicitly imported names take precedence over the implicit object module (capacity, ModuleInfo); un-reserve macro language, druntime ~20 ~15 forum (macro)
LDC exception-escape bug; arm64 to!double LDC, Phobos 16 2 ldc#4433 (to!double)

In the short term, as a mitigation, it is likely that some simple Skills that remind agents of these papercuts could meaningfully help their effectiveness.

How this was measured

  • Run: D (LDC 1.41.0, dub 1.40.0) and Go 1.27.1. All 40 langbench problems, with ten of them (bigint, buildsys, chip8, datalog, depresolve, jq, regex, sat, toml and webhooks) run three times: 120 sessions total, 60 per language. After the run, three problems (mime, fulltext, svgraster) had test data replaced for licensing reasons, and their six sessions were rerun; the effort numbers above use the reruns.
  • Agent: Claude Sonnet 5.5 at high effort in Claude Code; one headless session per task in a private sandboxed workspace; no personal settings, memory or MCP servers; the same prompt apart from the language’s name and toolchain.
  • Correctness: each project rebuilt from a clean copy of its sources and run against the public tests, plus held-out tests (never shown to agents) for the five large problems.
  • Classification: all 2,812 tool calls of the original 120 sessions (before the six reruns) labelled by eight reviewers with shared instructions, reading D and Go sessions of the same problem side by side; large incidents rechecked against transcripts; the compiler bug reproduced.
  • Limits: one model, one harness, one platform (Apple Silicon/macOS). The productive/overhead boundary is uncertain by about one call per session; categories under five calls are anecdotes. Most problems ran once, so per-problem numbers are noisy.
  • Earlier run (different prompt, agents in a personal environment): D-specific costs were 62% of the gap then and 59% now, with the same causes recurring. Both prompts asked every language for unit tests in separate files.

Conclusion

I’m excited that we’re entering an era of software development where we can answer empirical questions more accurately and easily, where we once had to rely on anecdotes or small, often flawed, studies. I’d certainly not consider this run at the calibre of empirical quality that I’d like, but it’s a good starting point.

Some things I may pursue next:

  • Try different models, effort levels, harnesses.
  • Even larger problems, perhaps on established code bases with >100kLOC.
  • Timed measurements that also account for build time, run times.
  • Test out the impact of Skills that mitigate known issues.
  • Try different prompting strategies to guide agents in different directions, e.g. “keep things simple”, or “efficiency is important”.
  • Use a harness like this for evaluating new language features: wouldn’t it be nice if a language proposal came with an “if implemented, agents use X% fewer tokens in benchmark B”?