- Published on
Optimize Programming Languages for Verifying Code, Not Writing It
- Authors

- Name
- Gavin Ray
- @GavinRayDev
It seems increasingly unlikely that humans will be the primary authors of code for the rest of this century.
If the job of a software engineer changes from "write code" to "make sure generated code works", the design space of programming languages changes quite a bit.
Consider how much of what we've done in language design over the last few decades has been based on the fact that writing code is expensive (in terms of human time). We've made all sorts of tradeoffs in the interest of making code easier to write.
If writing an implementation is now the cheap part and establishing its correctness is the expensive part, a lot of those tradeoffs no longer make sense.
Back in August I wrote a short post about the utility of contracts and effect systems in the context of LLM-generated code. This is my attempt at putting to paper what I think the "ideal" programming language would look like, given this change in the way we develop software.
For what it's worth, I think Rust is most likely to "win". I find it unlikely that a new language will gain much traction at this point, and suspect instead that the closest existing language will evolve the bits it needs. There's also a bit of a chicken-and-egg problem with new languages now: the better an LLM is at writing code in a language, the more attractive that language is to use, and the languages LLMs are good at are largely the ones that already have a sizeable body of code.
These are the core tenets of what such a language would look like:
- Start from a Rust-like core
- Correctness should be machine-verifiable
- Specifications as a first-class language feature
- Dependent Types, Refinement Types
- Explicit Effects & Capabilities
- Unison-like content addressed code definitions
- Performance and resource consumption as specifiable properties
- Go-like stdlib, to reduce third-party dependencies
- Code should have a canonical structured representation
- Determinism and reproducibility wherever practical
- Small, formally specified, extensible language core
- Longevity via versioned semantics, independence from specific compilers/hardware
To give some idea of what this would look like in practice, here are imagined examples:
// "Verified" pure functions that are SMT-provable, with contracts
verified fn sort<T: Ord>(items: Vec<T>) -> Vec<T>
ensures is_sorted(result)
ensures multiset(result) == multiset(old(items))
{
// ...
}
// High level "Spec" descriptions, where implementation is auto-generated
spec fn binary_search<T: Ord>(
items: &[T],
target: T
) -> Option<usize>
requires is_sorted(items)
ensures match result {
Some(i) => i < items.len() && items[i] == target,
None => !items.contains(target)
}
// Refinement types
type Percentage = f64 where 0.0 <= self && self <= 100.0;
type NonEmpty<T> = Vec<T> where self.len() > 0;
// Capabilities constrain which resources a function can access.
fn read_config(fs: ReadOnlyDirectory, path: RelativePath)
-> Result<Config, Error>
! {Filesystem, Alloc};
// Dependent types: m and n can be runtime values.
fn read_matrix(src: &mut impl Read, m: usize, n: usize)
-> Result<Matrix<f64, m, n>, Error>
! {IO, Alloc};
// Resource constraints for systems code
fn process_packet(packet: &[u8]) -> Result<Packet, Error>
@no_alloc
@no_block
@bounded_stack(4096);
There isn't much in this post that's particularly novel by itself. Most of the features I've described exist in some form in:
Rust, Ada/SPARK, F*, Dafny, Lean, Idris, Koka, Unison, Haskell (Liquid Haskell), etc.
Some of the design decisions in these languages that made them unattractive to large portions of software engineers are the ones that become MORE attractive if you take the human out of the process of writing the implementation.
I'd really love to see Rust evolve in this direction. There's a decent amount of work happening already: Verus gives you requires/ensures and SMT-backed verification of Rust code, Kani gives you model checking, Flux gives you refinement types, and rustc has an experimental contracts feature on nightly. As it stands, these things aren't a coherent part of stable Rust, and they each have their own way of expressing specs.
If I could have Rust with first-class specs, an effect system, refinement types, and integrated formal verification, I'd be pretty content.
AI (Dis)use Disclaimer: No part of the prose was machine-generated. You will not find machine-written prose on this blog. I consider it deeply disrespectful.
Claude Opus 5.5 was used to generate the OpenGraph image for this post, and the frontmatter summary sentence