9 ms·
Learnings from 100K lines of Rust with AI (2025)
- staszewski 5mo agoIt's almost guaranteed with agents you could do the same job with less than half of 100k lines. I don't know whats impressive in lines of code generated by agent.
- ndr 5mo agoIt just an anchor. If it were 50k would you say the same down to 25k? And if so how many more times would it apply? The interesting thing is that it was manageable solo (in many ways it's _more_ manageable solo+AIs than with coworkers+(their)AIs), and in such a short amount of time.
- rimliu 5mo agothe interesting thing is how fast it becomes unmanagable.
- ndr 5mo agoAlso that, I suspect that's correlated to how practical is to have multiple people (with their agents) iterating on it.
- kikimora 5mo agoOriginal RSL library is 36k LoC. And this is C++. Rust should be like 50% smaller, that is, 18k LoC. This library is so big that I bet the author has no idea if it works or not. 1300 test generated by AI say nothing about actual quality. In the end it is just a lot of unmaintainable code quickly generated by AI.
- ndr 5mo agoThis is uncharitable, but makes a prediction. I imagine you'd bet the author won't be successfully using this, at MS/Uber or wherever they are, in a year time? Rust makes no promise of being terser than C++, and RSL does less than this considering the optimization. Also it's only 45/50k LOC so not so very from the 36k LOC.
- kikimora 5mo agoYes, I would bet it won't go anywhere. The blog post mentioned the project is 130k LoC multiple times. Where 45/50k LoC comes from? >Rust makes no promise of being terser than C++ True, but Rust has no header files, this alone is a great LoC saver.
- ndr 5mo ago50k LOC wouled be the rust code without tests. But it's not apples to apples because they seem to have done much more performance work though, this is far from code golfing.
- kikimora 5mo agoRSL’s 36k LoC includes tests and should be compared with 130k LoC, not 50. Having 90k LoC of tests for 50k LoC codebase also a problem. At least in my experience LLM generate too many tests. It does not evolve test suite but throws more code into it as development happens. Unless I aggressively refactor tests I quickly end up with a test suite that I don’t understand. Then LLM modifies tests to “make code work” and I have no idea if this is a legit edit or LLM cheats. I wonder if the same thing is happening or about to happen with this codebase.
- zahlman 5mo agoHas Rust code generally been found shorter than C++ in practice? I don't see an obvious reason for it.
- pjmlp 5mo ago
- ashirviskas 5mo ago> It's almost guaranteed with agents you could do the same job with less than half of 100k lines. That's great, non-test code is only ~47k lines of code.
- sreekanth850 5mo agoFor a startup with limited funding, building a product is no more a bottleneck. every one doesn't have the same access to funding!
- torben-friis 5mo ago>Testing is the first layer of defense. My system now includes 1,300+ tests — from unit tests to minimal integration tests (e.g., proposer + acceptor only), all the way to multi-replica full integration tests with injected failures. See the project status. I know LOC is a silly metric, but ~1300 tests for 130k lines averages out to a test per 100 lines - isn't this awfully low for a highly complex piece of code, even discounting the fact that it's vibecoded? 100 LOC can carry a lot of logic for a single test, even for just happy paths.
- risyachka 5mo agoI may have missed it but are those tests written by person or generated? Otherwise how do you know they even test anything (like actually test, not appear to test)
- sashank_1509 5mo agoIt’s all written by AI and you can’t tell for sure if the tests are good. You can eyeball some but eyeballing 50k lines of code takes a lot of time. You just trust AI and YOLO, find errors later
- flossly 5mo agoAsk AI to find the weakest tests. :) No joke: it works for me. I have a 45kLOC prod code (just code, no comments, no blanks), tested by a 30kLOC test code containing 1600 tests (that run in 30secs). I helped with the test infrastructure/architecture. Sometimes I had to write the first few tests of a particular kind, but now Claude TDDs for me. A fair share of my CLAUDE.md instructs in how I like my tests, when to write them (first), different types of tests (unit, faked-services, db, e2e, etc.) Asking Claude to find weak tests has helped a lot in getting here. I also do review AI-gen'd code, pretty much line-by-line, before accepting it.
- kawogi 5mo agoIIUC only 50k LoC are non-test code, which improves the metric. Whether that's enough tests still depends on the code. If most are getters and setters, the coverage might be ok.
- nilirl 5mo agoIs the idea of the runtime contracts similar to the idea of runtime validation? Or are they different in some way?
- pramodbiligiri 5mo agoIt is described in the "Code Contracts" section of the article: "Code contracts specify preconditions, postconditions, and invariants for critical functions. These contracts are converted into runtime asserts during testing but can be disabled in production builds for performance". The .NET framework article that he links to: https://learn.microsoft.com/en-us/dotnet/framework/debug-trace-profile/code-contracts https://learn.microsoft.com/en-us/dotnet/framework/debug-tra...
- nilirl 5mo agoAh, I missed the reference. Thanks a lot!
- andai 5mo agoIs this basically what Dijkstra was saying? I've been thinking how his approach was considered impractical, but may eventually become necessary for security/stability reasons the way things are going. (Seems like new zeroday on HN front page every day now.)
- pramodbiligiri 5mo agoThere was a good blog post recently along these lines: https://aybabt.me/blog/correctness-agentic-world https://aybabt.me/blog/correctness-agentic-world
- jdw64 5mo agoI'm also shifting to an vibe coding workflow, but I have a genuine question: whenever I use AI for Rust, it makes an insane amount of lifetime errors. I have no idea how people are churning out so many lines of code so quickly. Honestly, despite all the hype around Rust in the community, the fact that AI can't handle lifetimes reliably makes me reluctant to use it. The AI constantly defaults to spamming .clone() or wrapping things in Rc, completely butchering idiomatic Rust and making the output a pain to work with. On the other hand, it writes higher-level languages better than I do. For those succeeding with it, how exactly are you configuring or prompting the AI to actually write good, idiomatic Rust
- dijit 5mo agoThe feedback loop is the interesting part, if you use standard software engineering practices (modularise, test/document your interfaces, etc) then I find things like Claude Code do an exceptional job: since they can actually run cargo check/test themselves and can validate the tests too.
- hydra-f 5mo agoA lefthook: format: glob: ".rs" run: cargo fmt -- --check lint: glob: ".rs" run: cargo clippy -- -D warnings tests: run: cargo test audit: run: cargo audit + hooks that shove the lefthook automatically in the ai's face --- rustfmt.toml: edition = "2021" newline_style = "Unix" use_small_heuristics = "Max" max_width = 100
- vermilingua 5mo agoThe irony of the machines having no mechanical sympathy is just too good
- faangguyindia 5mo agoRust code generation consumes lot of token Go is much better target, i've observed rails/ruby code is also much easier for AI to spit out. And Haskell flies with AI
- jgilias 5mo agoYes, but it comes with much better “built-in” guardrails to rein in the autocomplete. Especially if compared to something runtime-surprise-prone-if-lovable like Ruby.
- faangguyindia 5mo agoThis is why I suggested Go. Rust doesn't add anything over Go for LLM coding.
- jgilias 5mo agoBut it does. A whole class of runtime errors you can trivially produce in safe Go — null pointer dereferences, unchecked type assertions, missed enum cases — are unrepresentable in safe Rust. Also, the type system is a lot more expressive, so more invariants can be encoded in it, leading to more business logic bugs being caught at compile time rather than in production.
- pjmlp 5mo agoFor that I would chose neither, rather go with Haskell, OCaml, F#, Lean, Dafny, FStar, Scala, Kotlin,...
- icemanx 5mo agoHow many of those tests have you actually read yourself if all of them are generated by AI (also when you're sleeping) ? This is from 2025 - I would like to see an update now how that system turned out to be after the vibe hype
- ramon156 5mo agoI feel like there's very little blogs that actually follow up on their experiment. It's just dopamine city.
- bharxhav 5mo agoRust is about abstractions more than code. You can ask AI to "Optimize/Test/Clarify" but at the end of the day you should be willing to blindly agree to it's output or spend more time reviewing someone else's code.
- danbruc 5mo agoPaxos is certainly non-trivial in the sense that tiny changes can break it, but in terms of functionality it is not that big. 50 KLOC just seems like a lot of code to me.
- 10g1k 5mo agoLessons. There's no such thing as learnings.
- criddell 5mo agoLearnings is irritating to me. The way kids use the word aesthetic is irritating too. I wonder if I might be that old man shaking his fist at the clouds, but I have gotten over begs the question, and literally, so maybe not yet...
- tskj 5mo agoA lesson would be a specific learning activity happening at a specific place and time, administered by a person more knowledgeable than you; like a teacher or mentor "giving a lesson". If you're fine with the generalized form "learned a lesson", then surely "learnings" is fine too. There's no point in trying to police a completely normal and sensible use of language.
- esafak 5mo agoSo when you cause an incident because you did not pay attention and "learn your lesson" who's the mentor?
- tskj 5mo agoThe universe. Anyway, I accept this usage of the word "lesson", so I also accept "learnings". My point was one of hypocrisy, not policing people in how they can use the word "lesson".
- zahlman 5mo agoI understand the instinct, but that's a bit too prescriptive for me. https://en.wiktionary.org/wiki/learnings https://en.wiktionary.org/wiki/learnings
- chemex 5mo agoHow are you keeping the requirement, design, and tasks docs in sync as the code evolves? I'm curious if anyone's landed on a good workflow for this.
- uptodatenews 5mo ago[dead]
- chadd 5mo agoWe're working on a large Rust codebase, heavily assisted development with Claude and Codex, and one critical workflow is after you have written a spec, have the other LLM critique it thoroughly. This back and forth will take quite a while, but the resulting implementation plan will be 10x better than the original. You can automate this by giving Codex a goal, and a skill to call Claude to review the implementation spec until they both agree it's done. Then, for critical code, have them both implement the spec in a worktree, then BOTH critique each other's implementation. More often than not, Claude will say to take 2 or 3 pieces from it's design over to Codex, but ship the Codex implementation.
- motoboi 5mo agoI strongly believe you don’t need to call another model for that. The same model can do result fine. Just not as part of the same context. I mean that if you ask codex on gpt 5.5 to submit to a plan reviewer subagent that uses gpt5.5, this is enough to have a very good reviewing and reassessment of the plan. My hypothesis is that it’s even better than opus. The reason why submitting the product of one LLM to another to review is that you need a fresh trajectory. The previous context might have “guided” the planer into some bias. Removing the context is enough to break free from that trajectory and start fresh.
- dimitrismrtzs 5mo ago[dead]
- ai_fry_ur_brain 5mo agoI hate how seriously people take the output of an LLMs or how reliable they think it is. Have Claude produce that spec 10 times, use the same prompt and same context. Identical requests, but you'll get 10 unique answers that wil contradict each other with each response seeming extermely confident. Its scary how confident you people are in these outputs.
- CrazyStat 5mo agoIf you ask 10 different humans to produce the spec with the same information (prompt and context) they will also produce 10 unique answers that will contradict each other and (depending on who you asked) may be just as confident. There are real decisions to be made when going from a vague prompt to a spec. It's not surprising that an LLM would produce different specs for the same work on different runs. If the prompt already contained answers to all the decision points that come up when writing the spec then the prompt would already be the spec itself.
- kikimora 5mo agoThis is great example of AI slop and a big problem with AI coding. Original RSL library has 36 KLoC across C++ source and headers files. Rust supposed to be more expressive and concise. Yet, AI generated 130k LoCs. I guess nobody understands how this code works and nobody can tell if it actually works.
- jmpeax 5mo agoAll unit tests can pass if you don't assert anything. Just have to make sure to read through all 130k lines of code to check.
- misja111 5mo agoTo me, the real question after reading this, is: Is your new implementation of Azure’s RSL now being used? If it is, and it works well, then to me this is far more meaningful than the fact that AI wrote 130K lines of code.
- sltr 5mo agoContrarian view: Why English will never be a programming language. https://www.slater.dev/2026/05/why-english-will-never-be-a-programming-language/ https://www.slater.dev/2026/05/why-english-will-never-be-a-p...
- bio-s 5mo agoI have Tarpaulin code coverage check and everytime that it drops below the treshold Claude gives up quickly and just lowers the threshold. I don't know how to overcome it. CLAUDE.md neither AGENTS.md help but the LLM always finds its way.
- galaSerge 5mo ago[flagged]
- valcron1000 5mo agoWhere can we read the code?
- galaSerge 5mo ago[flagged]
- gertlabs 5mo ago[dead]
- wren6991 5mo agoI've found Rust's safety guarantees to be less useful for slop-generated code because LLMs can always fight their way through the borrow checker by spamming enough Arc<Mutex<Arc<Mutex<...>>>> and clone() everywhere. Rust only gives you safety properties, not liveness. Interior mutability is a fantastic tool for turning safety failures into liveness failures. Remember kids: deadlock is a safe outcome. It works for humans because when we get a borrow-check failure, we take a step back and think about the global shape of our code and ownership. LLMs path straight to the goal. Problem: code doesn't compile. Solution: more clone()
- jsLavaGoat 5mo agoI am having a different experience than a lot of other commenters here vibe coding with Rust. I am not a Rust programmer or evangelist. I have implemented a drop-in Bash replacement/clone in Rust that passes the upstream Bash test suite and a whole battery of its own. It is a tiny bit faster than Bash itself but consumes a bit more memory. But Codex and Claude both did a great job with it. I also had it implement a wasm geodesic calculator in Rust and it's amazing and in my use case is better than geodesiclib using the same updated algorithm. I'm a "C-nile" Rust folks love to hate and did my first hacking in C Deep Blue C on Atari 8-bits. But I'm very impressed with these products and with the ability to leverage some features of Rust with them. (e.g. audit every unsafe instance and define its invariants, etc.) I also agree with the commenter who said these LLMs are today, at the present moment, good at Go. The only language I notice it seems to be really good above and beyond others at is javascript, I assume because there's so much of it.
- dxxvi 5mo agoThe thing that impresses me most is that the author knows everything (from the high level architecture to the small details) of "multi-Paxos consensus engine" (I have no idea what it is, but it must be very complicated) and can write everything out for AI to read (or did he/she use an app to convert speech to text)?
- pjmlp 5mo agoThe moment a language is the output of a natural language compiler, the language itself is kind of irrelevant. Change the skills, ask the agent to do exactly the same in something else. I am slowly focusing on agent orchestration tools, which make the actual programming language as relevant as doing SOA with BPEL.
- throw-the-towel 5mo agoThe language may be irrelevant, but the hard guarantees it offers are not. Agents are still very stochastic, they need something deterministic constraining their output.
- pjmlp 5mo agoThat is where formalisms come into play. Also it is kind of interesting that there is so much enthusiasm to use Claude and Claw all over the place, yet lack of vision on how much the whole infrastructure will improve. Even when it finally bursts and we get into another AI Winter, what was already achieved isn't going away.
- implexa_founder 5mo ago[flagged]
- max_unbearable 5mo ago[flagged]
- digitaltrees 5mo agoCool post. I don’t fully understand what a code contract is but appreciate the advice. I have settled on a similarly light weight /agile folder when I keep my roadmap.md with epics and sprints.
- 3836293648 5mo agoIt's a set of asserts that are a part of the type signature. Requires are asserts on the inputs, ensures are asserts on the outputs. Depending on your backend you either ignore them, check them all of the time, some of the time, or have SMT-solvers prove that if you uphold the first one all else must follow. If you're interested in the last one, have a look at Dafny[0] [0] https://dafny.org/ https://dafny.org/
- deleted 5mo ago[deleted]
- JulianSmith1 5mo ago[flagged]
- soloto 5mo agoSeriously, "Learnings"? Learn you an English.
- andrewstuart 5mo agoWe MUST get programming languages and LLMs that do not ever change or break comments. You can’t have contracts defined in comments in code because there’s no guarantee they won’t be deleted or changed. Even better, we need the ability to embed directives to LLMs which are NOT comments, but a type of programming construct specifically for this purpose.
- lol-lol-lol-2 5mo ago[flagged]
- cold_harbor 5mo agowith Rust the failure mode isnt wrong code, it's unidiomatic code. .clone() everywhere will compile fine but you'll feel it later
- l1ng0 5mo agoRead this as "Lemmings from..." Was disappointed. Also: showing my age.