Simon Willison Compares C vs Rust for Writing SQLite Extensions
Simon Willison used Claude to investigate writing a custom SQLite parse_number() extension in both C and Rust, comparing implementation complexity, file size, and performance. The experiment revealed that while initial Rust extensions were faster than standard C implementations, an optimized C function ultimately outperformed Rust. This exploration offers practical insights into the performance and overhead trade-offs between C and Rust when building database extensions with AI assistance. It highlights how modern AI coding assistants can rapidly prototype, benchmark, and refine code across different programming languages. The initial Rust extensions sized around 298 KB to 321 KB, whereas the naive C extension was only 14 KB. However, after tuning the C implementation to replace standard library parsing functions, the new C code drastically outperformed all Rust variations across mixed data, integers, and decimals.
## BACKGROUND
SQLite allows developers to write custom loadable extensions that add new scalar functions, aggregates, or virtual tables to the database engine. These extensions are typically written in C for maximum compatibility and minimal overhead, though memory-safe languages like Rust are increasingly explored using specialized frameworks.