Was just testing latest gen LLM capabilities, and decided to give it goal of rewriting a small opensource project in Rust. (Should be noted: was not some tiny library, but an actually useful network service).
It completed the entire rewrite from typescript to rust in about 2 hours, ~600k tokens used. Worked perfectly on first try with no follow up changes required. Memory and CPU usage now a tiny fraction of TS version (obviously). Rust code was simple, easy to read, accurate test suite, etc.
I was pleasantly surprised.
Obviously bigger code bases with more complex business logic will likely struggle here, but there are some advantages to "RIIR" when performance matters, even security benefits aside. Rust can help squeeze more juice out of old hardware; reduced memory footprint especially helpful with current RAM prices.
For small services where operational cost matters, having LLMs "rewrite it in rust" might be worth the spend.
I’ve seen people do this and I’m always confused, do they believe they will never have to reason about the code ever again.
I suppose if it is like the Zig Rewrite where essentially all development is being done by Claude, I can imagine this making sense.
But in any other case, you had a codebase that presumably you wrote, you could reason about, you could refactor etc. and then you made it into a completely unintelligible code base, which even if written cleanly will take a long time to reason about. Typescript to Rust is not just syntax changes. It doesn’t make sense to me, unless you believe you will be completely out of the loop in managing this code in the future.
A small typescript util rewritten into rust is going to look so similar that I don't think this will be a problem. As the parent commenter said, maybe not for a larger project. But rust semantics are really close to typescript for the most part, at least the bits you'd use for a simple tool.
This wasn't a codebase I originally wrote or cared to reason about deeply. It's fairly straight-forward rust, so not hard to understand or follow. Again, this was originally just a test to see how well it would work (better than I expected).
Not something I need to maintain much going forward, so I have no reason to manage the code manually ever.
Comments
Small related anecdote:
Was just testing latest gen LLM capabilities, and decided to give it goal of rewriting a small opensource project in Rust. (Should be noted: was not some tiny library, but an actually useful network service).
It completed the entire rewrite from typescript to rust in about 2 hours, ~600k tokens used. Worked perfectly on first try with no follow up changes required. Memory and CPU usage now a tiny fraction of TS version (obviously). Rust code was simple, easy to read, accurate test suite, etc.
I was pleasantly surprised.
Obviously bigger code bases with more complex business logic will likely struggle here, but there are some advantages to "RIIR" when performance matters, even security benefits aside. Rust can help squeeze more juice out of old hardware; reduced memory footprint especially helpful with current RAM prices.
For small services where operational cost matters, having LLMs "rewrite it in rust" might be worth the spend.
I’ve seen people do this and I’m always confused, do they believe they will never have to reason about the code ever again.
I suppose if it is like the Zig Rewrite where essentially all development is being done by Claude, I can imagine this making sense.
But in any other case, you had a codebase that presumably you wrote, you could reason about, you could refactor etc. and then you made it into a completely unintelligible code base, which even if written cleanly will take a long time to reason about. Typescript to Rust is not just syntax changes. It doesn’t make sense to me, unless you believe you will be completely out of the loop in managing this code in the future.
A small typescript util rewritten into rust is going to look so similar that I don't think this will be a problem. As the parent commenter said, maybe not for a larger project. But rust semantics are really close to typescript for the most part, at least the bits you'd use for a simple tool.
This wasn't a codebase I originally wrote or cared to reason about deeply. It's fairly straight-forward rust, so not hard to understand or follow. Again, this was originally just a test to see how well it would work (better than I expected).
Not something I need to maintain much going forward, so I have no reason to manage the code manually ever.