HeadlinesBriefing favicon HeadlinesBriefing.com

LLMs Write Rust Code Faster Than State-of-the-Art Libraries

Hacker News •
×

In January 2025, the author tested whether LLMs could iteratively improve code by repeatedly asking them to "write better code." While Claude Sonnet 3.5 added features rather than optimizing, the hypothesis evolved: could agentic LLMs write high-performance Rust code, bridged to Python via PyO3, surpassing established libraries? After months of testing with Claude Opus 4.5 and subsequent frontier models, the author confirms modern agents can produce Rust implementations 2x-20x faster than state-of-the-art approaches, given proper guardrails (e.g., forbidding `unsafe` code, using criterion for statistical benchmarking).

The primary test case was UMAP, a dimensionality reduction algorithm that scales poorly in Python. Instead of forking existing crates like `umap-rs`, the agent wrote the algorithm from scratch with minimal dependencies to enable low-level optimization. Opus 4.5 generated benchmarks across input sizes, iteratively refining the implementation based on criterion output.

This "benchmaxxing" approach leverages Rust's memory safety and WASM compilation potential. The author emphasizes this is not speculative: prompts and benchmark results are included, demonstrating that iterative agentic optimization now yields production-grade, high-performance systems code.