I would like to argue that one could make most codebases 50% faster if rewritten from scratch with performance in mind even in the same language.
Taking python as an example, one could use benefit of hindsight and make better decisions from the start ( offloading slow parts to C binaries, better DS decisions, eliminating bloat etc.. ) if they rewrite the same app in Python. This is kind of what happens when a program gets rewritten to another language ( Rust ) - better decisions are made from the start and less bloat is copied over.
Yes, obviously there are exceptions to this. But most of the time it is the choices we make that make the program slow and not the language itself.
It used to be that rewriting programs were almost always a dumb idea due to how much effort went into it - see: https://www.joelonsoftware.com/2000/04/06/things-you-should-... . But AI has made this argument less compelling imo. I now regularly rewrite big chunks of programs with various end goals given to the agent.
See uv - replacing pip with a rewrite in Rust was a good stunt, but the big performance gains came from eliminating dynamic features (uv doesn’t allow packages to execute code when installed) and I/O (better caching and parallelization).
I mean, it's definitely both. Of course there can be algorithmic improvements, but a like-for-like rewrite of Python code into Rust can often be 10x faster.
Don't forget 10x iteration time and deploy time due to building on large projects. Still can be worth it, but I highly recommend build costs (CPU, RAM, Disk, Time) are considered in a rust rewrite decision. I'd even architect around it from the start as it can really add up.
Depends on the application. Tbh the comparison btwn python and rust is kind of dumb. But for the sake of argument - I don't think most well-written Python codebases can get 10x faster by using Rust. Bit faster ? sure maybe. Remember Python uses C under the hood. Unless there is a shit ton of looping or weird unrealistic conditions i don't think this is true
"""If you're looking for the next win, you don't have a hotspot. The CPU profile might look even-Stevens across the board. Let me give you a really simple example of this, I used to work on the [Edge] browser and you could find yourself with a significant regression one week and you're using way more CPU, and you look what the functions are and it's the same functions as always. It's layout and it's style computation, and that code hasn't changed a byte. It's the same excellent layout engine, it's the same excellent style engine, and yet the profiler will tell you you're spending way more time in layout. What's happened?
Somewhere in your code is a little whammy where someone invalidated a bunch of tree nodes which took about 8 nanoseconds and caused the layout engine to now do tons of computation that it didn't have to do before. No profiler in the world is going to save you from this problem, it's going to tell you that the problem is in the layout code. Well duh, thanks for that, of course the compute is in the layout code, it's always in the layout code, all we do is layout and draw. So I have to find the 3 nanoseconds where somebody invalidated something that they have no business invalidating because it's wrong. And the way you fix that is [to have a sense of how to check that you're invalidating the right thing, regression testing, planning] and it could be literally 4 or 5 instructions dirtying the cache and that's not going to show up in a profile.
[paraphrasing; Casey: if you've developed the whole browser without caring about this, at the end you're going to find it very slow and not be able to squeeze any more performance out of the layout engine? Rico: Right, this is not something you can fix at the finish line, it needs a plan]"""
Exactly my experience. You can make Python code faster by profiling and improving the hotspots, but once you've done that it will still be 10x slower than C++/Rust at least, and that slowness is evenly spread through the whole program.
The number of use cases where you actually can move just a small part of the program to C++/Rust and that solves performance is actually really small. Basically highly numerical things like AI or SMT solving. Even supposedly IO bound things like Django tend to be quite slow in Python.
A lot of lost performance also comes from things like the architectural decisions and technical debt that would pile up over time. These considerations are also like sand in that they're coarse, rough, irritating, and they get everywhere in the codebase.
Oh, and they can be annoying to refactor later on.
Using the right data structures for the right usage later on is like half the battle. People get really annoyed when you show them a Python program that is faster and shorter than someone's C# program, merely because they used the wrong data structures for how it's being used.
It's also OK to rewrite in Rust because it's not just about performance. The fast part in other Python, Ruby, etc may be written in C/C++, or call an external library, and be the vulnerable part.
Genuine question, is this a common problem people see out in the wild? In my dayjob(s) I've basically never seen major slowness that comes from using something like nodejs / python, the bigger culprits have been network / db / bad architecture or code.
Python and Ruby are single-threaded (yesyes, there's noGIL python now), which in turn means they're deployed as multi-process services, which means they must be stateless, which means there is a lot less you can keep in-memory and need to offload to external stateful systems. And that's how you get your bad architecture.
And python being interpreted and dogslow means any heavy computation you write in pure python needs to be offloaded too instead of just putting it on a threadpool, again making your architecture more complicated.
Add in serverless functions, which need startup, and now something that should have taken microseconds will take seconds.
Node is JITed at least, but still no shared-memory multithreading, so it still encourages all the architectural bloat.
I recently built a small nextjs/node application that basically makes like $50 usd monthly. Initially built as a PoC, I wanted to place it in a vps so that I didn't have to maintain it in my home laptop, and also because I wanted to move it to a Europe location for better business performance [im in mexico and latency is high].
Thing is, the TS app weighted around 4GB overall and took 2s to do its thing. [A backend process, an http api and a static website generator].
I needed to decrease the size and increase performance dramatically,to be able to put it in a 2GB 2vcpu instance, which costs $12 monthly. Otherwise it would eat the profit.
Claude ported it to Rust, in around 2 days total. And it went down to 1.5Gb max, and 1/10 of the CPU usage. Now it sits in the aws europe zone making money.
Yeah, Python is one I where I find moderate amounts data can be a pain - I end up tempted to move CPU work to the database or precompute more things, and it’s hard to get the advantages of single binary programs (for deployment, startup time, etc).
(For big data you can use Python to drive some native code frameworks - it is good at that, for tiny data it’s irrelevant because there’s not much to do, but the moderate case gets awkward).
Performance is broader than just slowness; it’s also CPU and memory usage, things which will force you to scale horizontally (multiple machines) much sooner.
In mid-2013, NewsBlur described in some detail their deployment and statistics. Python/Django, 48 servers. I confidently calculated that, with implementation efficient, one would be sufficient, though with little headroom, and further vertical scaling might have started running into I/O limitations. (I doubt a single server would be possible any more.)
It’s popular to scale horizontally far earlier than you actually need to. And if you can commit to sticking with vertical scaling (single big machine), you can simplify (and further speed up) things enormously.
Maybe. When I stress test my JavaScript application I can push up to 6,000,000 WebSocket messages per second in Node (C++) but do experience some amount of memory instability. When I run the same application on Bun (Rust) it’s not as fast but it’s extremely stable.
In all fairness 6,000,000 messages per second across a single socket is likely an unrealistic scenario but application stability over multiple months pushing out message traffic across many sockets from many servers under a single application process is a realistic concern as is number of simultaneous open sockets.
Yes. Python is usually 10-100x slower than languages like C, C++ or Rust. If your program is CPU bound, this shows up very obviously. If it isn't, you may never notice at all.
Imagine being able to use only 1% of the machines you used to require, by migrating away from Python. This is very realistic for companies doing heavy computational work.
Libraries generally write hot code in languages like C, C++, or Rust and bind that to Python (PyTorch, etc.) or provide bindings/wrappers around libraries in those languages (SQLite, PostgreSQL, etc.).
As with anything performance related you need to profile the code with realistic data/workflows and identify the parts that are slow.
Typically, doing things like changing algorithms, data structures, careful use of caching, reusing calculations, etc. are more important to performance than the choice of language.
What you're saying is valid too; but, the post you're replying to implied most slowness is network (i/o bound) or bad architecture (accidental cpu bound, fixable by tech debt cleanup).
That post was also asking if other people have seen language mattering. In the places where I've worked programs are often CPU bound. Places like these are why compiled languages are still alive and kicking.
I'm not denying that domains exist where being I/O bound is a thing. For those cases Python can be a fine choice.
We all have different lenses on the makeup of the entire set of software out there, it's likely you're coming from that experience and the other post was coming from experience mostly with i/o bound software.
For cpu bound stuff the language makes potentially an enormous difference; but then you get to trade off: eg. if you're not gonna need a fast language you are free to choose based on other considerations.
I'd make the case that everything on a computer is CPU bound depending on scale, even your crud app. Half the time when somebody is saying that X is I/O bound, they actually mean that it's bound by the performance of their database - which wisely, in the real world, is not written in python.
edit: and, of course, things in python that would run terribly slow if written in python become primitives, which are written in C. Python is a C program.
In my experience memory issues are more common. The way JS stores objects in memory is fundamentally inefficient (though it’s deliberate, it’s why you can do object.propertyIJustMadeUp = true on anything, any number can be a float, etc) and if you’re moving a ton of data it can cause issues eventually.
The only JS-native answer is to use typed arrays, which is using a sledgehammer to crack a nut.
Mostly because anything that needed to be fast already was written in a language that allows that and most of web/app development focuses on shuffling small amounts of data around. Also pure Python is worse than node in this aspect. Still, there many non-trivial cases. There is a reason most of infrastructure moves to Rust. I've seen poetry spending 30min (!) on dependency resolution once. Test runners and some background/nightly data processing if often first place where you realize you may want to rewrite.
Yes. Most often with Python. People think performance isn't going to be a problem and by the time it inevitably is, it's far too late to use a better language. (At least before AI.)
I've seen this at almost every company I've worked at.
We took this route in a Python web framework I maintain: route matching, JSON encoding, request body parsing, compression and some other specific parts moved to Rust with PyO3, everything else stayed in Python.
For the parts that scale, yes. I build a CI step for measuring the performance with Callgrind since last pure-python release, and we achieved good numbers: matching the last of 200 routes dropped to about half the cycles and serializing a large JSON to about 25% less. So it pays off for work that grows with the input.
Hell no. Rust is easier to read, write, maintain and reason about.
Way more people know Rust than Python/Python internals/Numba interactions.
Numba will either get you relatively low gains with little effort,
or push into territory very you write code few people will understand, because reasoning about its performance requires deep knowledge of Numba and Python internals. Rust gives a lot more ROI and looks more like Python.
Not my experience, actually. Numba and other such techniques (like having some hot paths in C/Rust/whatever) works, but eventually just allocating and deallocating Python objects starts to become a measurable problem. Especially if you have any kind of fancy metaclasses, descriptors, etc. "So don't"--ok, so give up Python's dynamic features? Why bother at that point. Now it is so cheap to write code anyway, why bother with Python at all? Have a design document in actual English.
I'm... not so sure why you need a repo for that. It's almost 2027. You can literally just type "profile this app and find out the performance bottleneck" then "rewrite it in rust" in your agent TUI...
I recently discovered that one can apparently distribute Rust projects on npm by compiling to wasm. action-validator used to do this. Had been thinking about something like this.
This cope was common 20 years ago with Python. It rarely worked out. It's rare that 5% of your program is taking up that large a percentage of your execution. It's usually much more spread out than that.
Also, we have LLMs now. Rust should be the default for many things.
"Also, we have LLMs now. Rust should be the default for many things." ...
Or C Or Go Or ... Its like people can not look past one language, to understand that with LLMs, a ton of languages gotten way more easy.
Personal experience that running a few subagents parallel with Rust, just slows everything down to a crawl, even wit ccache and a ton of other tweaks. As long as your codebase is a few 100k lines, Rust is ok. But start going in the 500k, 1 million... starting to get C++ flashbacks where your spending more time waiting on the compile jobs, that fight each other for resources then actual testing.
Until Rust can fix their slow and resource munching compiler, its been off the menu for me. Ended up having everything in C and the difference was very noticeable.
What does %LANGUAGE% have anything to do with the goal? Totally same principles apply for any other lower level language: Zig, C.
While Rust is awesome, a lot of times the only apparent reason to chose Rust over C is virtue signaling.
Update: like I said, Rust is awesome and has so many advantages over C it's not worth a discussion really. But again I see that many projects are choosing Rust not because of merits but simply because it's a fashion.
> the only apparent reason to chose Rust over C is virtue signaling
If you'd said another memory safe language I might have been on board, but C? We've seen a complete collapse in the ability of software to go un-hacked and un-exploited. Not all of that is down to poor memory safety of course, but it's a category of vulnerability that is massively increased in both surface and risk by choosing to write C.
Choosing Rust alone might be virtue signalling, but choosing a memory safe language is just pragmatic.
In this particular topic (performance) Rust matters because it will deliver excellent performance. You could write a container -> map -> map -> container flow in fifty memory safe languages, but probably it would be a bit slower than the nasty hack you'd write in C to convert the data in place. Rust isn't, if you're intrigued you will discover that Rust 1) figured out that the two containers must be the same size in memory so it can re-use the original container and 2) did the in-place conversion even though that wasn't what you wrote, because it's faster.
So magically the Rust was just as fast, but much more readable and when a junior (or an LLM) modifies it slightly so that the output container is bigger it won't suddenly segfault due to that scary in-place conversion loop now being a bounds miss, the Rust won't attempt the in-place conversion now that it can't work.
You've received downvotes, but I'll do you the kindness to actually answer you.
Firstly the obvious, LLMs aren't perfect yet, they still make mistakes.
But even if they could achieve safe C by asking them to "Write Safe C, Make no mistakes", there would still be a significant benefit to achieving safety by using Rust or a memory safe language.
LLMs work best when they have a combination of clear objective functions and guardrails. In this case, the compiler acts as a guardrail to keep it safe while trying to solve the problem that needs solving.
Having a compiler step prevents the LLM taking a "shortcut". Despite models improving, they will still take shortcuts, sometimes absurd ones, to meet some definition of a "job done".
The other massive benefit is cost and speed. Having an LLM analyze and reason about the safety is expensive and wasteful. Having this done at compile time is cheaper and quicker. The earlier in the feedback loop, the cheaper it will be.
Save your tokens for "real" work, not stuff you can check at compile time.
Rust protects you from a whole class of bugs (borrow checker) and lets you enforce almost as many invariants as you chose, through the type system.
LLM are just as bad as humans at enforcing/tracking ownership and invariants.
We maintain two code bases; one is TS and the other Rust.
Both are by now written foremost by agents (since August 2025, I'd say).
We had numerous non-(business)-logic bugs in the TS code base over this period.
Zero such bugs in Rust.
Because the compiler catches them for us.
All bugs we had in that code where actual logic bugs. I.e. the spec already had the bug or contained an oversight.
Zero.
We have since started rewriting the TS code base in Rust and will likely switch over in the next three months.
Seems like just virtue to me. The guy who volunteers every week to pick up garbage from the beach isn't virtue signalling, he's just virtuous. The guy who came once, with a film crew and left once they'd got the shots they wanted - that is virtue signalling. They're both shown in the film, but only one of them actually does the signalled virtuous activity when the cameras aren't rolling.
You could argue that RIIR was conducted as virtue signalling if what we saw was one of those translations smeared in unexplained unsafe blocks, with rats nest logic that no human is going to untangle. But that doesn't seem to be the case here.
> a lot of times the only apparent reason to chose Rust over C is virtue signaling.
Quite the opposite. Outside of a couple of very specific kind of cases (for example working with microcontrollers not supported by Rust toolchain), there is no good reason to choose C when you could choose Rust.
Choosing C over Rust means throwing away the memory safety features that Rust gives you for free. And for what? There is just no upside to choosing C in the vast, vast majority of cases.
Today I added Rust checked arithmetic which detects and protects math bugs such as integer addition overflow and division by zero.
Rust checked arithmetic is built into Rust's standard library (std) via explicit methods on primitive integer types (such as checked_add, checked_sub, checked_mul, and checked_div), which return Option<T> and evaluate to None on overflow. There's a known tradeoff of some speed, which is fine for my purposes because I need reliability more than raw speed.
I'm longtime C coder so I know how to do this in C. Rust strong types and static analysis make it so much easier to do correctly.
That's actually why we chose Rust over C at my new company, Virtual Signaling as a service™. We rewrite anything in Rust for companies looking to virtue signal.
I would like to argue that one could make most codebases 50% faster if rewritten from scratch with performance in mind even in the same language.
Taking python as an example, one could use benefit of hindsight and make better decisions from the start ( offloading slow parts to C binaries, better DS decisions, eliminating bloat etc.. ) if they rewrite the same app in Python. This is kind of what happens when a program gets rewritten to another language ( Rust ) - better decisions are made from the start and less bloat is copied over.
Yes, obviously there are exceptions to this. But most of the time it is the choices we make that make the program slow and not the language itself.
It used to be that rewriting programs were almost always a dumb idea due to how much effort went into it - see: https://www.joelonsoftware.com/2000/04/06/things-you-should-... . But AI has made this argument less compelling imo. I now regularly rewrite big chunks of programs with various end goals given to the agent.
See uv - replacing pip with a rewrite in Rust was a good stunt, but the big performance gains came from eliminating dynamic features (uv doesn’t allow packages to execute code when installed) and I/O (better caching and parallelization).
Yes exactly, I think this article explains it well :- https://nesbitt.io/2025/12/26/how-uv-got-so-fast.html
I mean, it's definitely both. Of course there can be algorithmic improvements, but a like-for-like rewrite of Python code into Rust can often be 10x faster.
Don't forget 10x iteration time and deploy time due to building on large projects. Still can be worth it, but I highly recommend build costs (CPU, RAM, Disk, Time) are considered in a rust rewrite decision. I'd even architect around it from the start as it can really add up.
Depends on the application. Tbh the comparison btwn python and rust is kind of dumb. But for the sake of argument - I don't think most well-written Python codebases can get 10x faster by using Rust. Bit faster ? sure maybe. Remember Python uses C under the hood. Unless there is a shit ton of looping or weird unrealistic conditions i don't think this is true
neat, but in my experience bottlenecks that you could solve this way are low hanging fruits and optimized away quickly.
the true performance hog is like sand, spread across the system, a little bit in every place.
"""If you're looking for the next win, you don't have a hotspot. The CPU profile might look even-Stevens across the board. Let me give you a really simple example of this, I used to work on the [Edge] browser and you could find yourself with a significant regression one week and you're using way more CPU, and you look what the functions are and it's the same functions as always. It's layout and it's style computation, and that code hasn't changed a byte. It's the same excellent layout engine, it's the same excellent style engine, and yet the profiler will tell you you're spending way more time in layout. What's happened?
Somewhere in your code is a little whammy where someone invalidated a bunch of tree nodes which took about 8 nanoseconds and caused the layout engine to now do tons of computation that it didn't have to do before. No profiler in the world is going to save you from this problem, it's going to tell you that the problem is in the layout code. Well duh, thanks for that, of course the compute is in the layout code, it's always in the layout code, all we do is layout and draw. So I have to find the 3 nanoseconds where somebody invalidated something that they have no business invalidating because it's wrong. And the way you fix that is [to have a sense of how to check that you're invalidating the right thing, regression testing, planning] and it could be literally 4 or 5 instructions dirtying the cache and that's not going to show up in a profile.
[paraphrasing; Casey: if you've developed the whole browser without caring about this, at the end you're going to find it very slow and not be able to squeeze any more performance out of the layout engine? Rico: Right, this is not something you can fix at the finish line, it needs a plan]"""
- Rico Mariani, interview: https://youtu.be/48Rig6v-xYU?t=3615
Exactly my experience. You can make Python code faster by profiling and improving the hotspots, but once you've done that it will still be 10x slower than C++/Rust at least, and that slowness is evenly spread through the whole program.
The number of use cases where you actually can move just a small part of the program to C++/Rust and that solves performance is actually really small. Basically highly numerical things like AI or SMT solving. Even supposedly IO bound things like Django tend to be quite slow in Python.
A lot of lost performance also comes from things like the architectural decisions and technical debt that would pile up over time. These considerations are also like sand in that they're coarse, rough, irritating, and they get everywhere in the codebase.
Oh, and they can be annoying to refactor later on.
Using the right data structures for the right usage later on is like half the battle. People get really annoyed when you show them a Python program that is faster and shorter than someone's C# program, merely because they used the wrong data structures for how it's being used.
It's also OK to rewrite in Rust because it's not just about performance. The fast part in other Python, Ruby, etc may be written in C/C++, or call an external library, and be the vulnerable part.
Better yet, stop writing large codebases in lenguajes that will have performance troubles.
Genuine question, is this a common problem people see out in the wild? In my dayjob(s) I've basically never seen major slowness that comes from using something like nodejs / python, the bigger culprits have been network / db / bad architecture or code.
Python and Ruby are single-threaded (yesyes, there's noGIL python now), which in turn means they're deployed as multi-process services, which means they must be stateless, which means there is a lot less you can keep in-memory and need to offload to external stateful systems. And that's how you get your bad architecture.
And python being interpreted and dogslow means any heavy computation you write in pure python needs to be offloaded too instead of just putting it on a threadpool, again making your architecture more complicated.
Add in serverless functions, which need startup, and now something that should have taken microseconds will take seconds.
Node is JITed at least, but still no shared-memory multithreading, so it still encourages all the architectural bloat.
I recently built a small nextjs/node application that basically makes like $50 usd monthly. Initially built as a PoC, I wanted to place it in a vps so that I didn't have to maintain it in my home laptop, and also because I wanted to move it to a Europe location for better business performance [im in mexico and latency is high].
Thing is, the TS app weighted around 4GB overall and took 2s to do its thing. [A backend process, an http api and a static website generator].
I needed to decrease the size and increase performance dramatically,to be able to put it in a 2GB 2vcpu instance, which costs $12 monthly. Otherwise it would eat the profit.
Claude ported it to Rust, in around 2 days total. And it went down to 1.5Gb max, and 1/10 of the CPU usage. Now it sits in the aws europe zone making money.
Yeah, Python is one I where I find moderate amounts data can be a pain - I end up tempted to move CPU work to the database or precompute more things, and it’s hard to get the advantages of single binary programs (for deployment, startup time, etc).
(For big data you can use Python to drive some native code frameworks - it is good at that, for tiny data it’s irrelevant because there’s not much to do, but the moderate case gets awkward).
Performance is broader than just slowness; it’s also CPU and memory usage, things which will force you to scale horizontally (multiple machines) much sooner.
In mid-2013, NewsBlur described in some detail their deployment and statistics. Python/Django, 48 servers. I confidently calculated that, with implementation efficient, one would be sufficient, though with little headroom, and further vertical scaling might have started running into I/O limitations. (I doubt a single server would be possible any more.)
It’s popular to scale horizontally far earlier than you actually need to. And if you can commit to sticking with vertical scaling (single big machine), you can simplify (and further speed up) things enormously.
I don’t know about now, but five years ago HN ran on a single server <https://news.ycombinator.com/item?id=28479595>, though with a standby machine also present since 2017ish.
Maybe. When I stress test my JavaScript application I can push up to 6,000,000 WebSocket messages per second in Node (C++) but do experience some amount of memory instability. When I run the same application on Bun (Rust) it’s not as fast but it’s extremely stable.
In all fairness 6,000,000 messages per second across a single socket is likely an unrealistic scenario but application stability over multiple months pushing out message traffic across many sockets from many servers under a single application process is a realistic concern as is number of simultaneous open sockets.
Yes. Python is usually 10-100x slower than languages like C, C++ or Rust. If your program is CPU bound, this shows up very obviously. If it isn't, you may never notice at all.
Imagine being able to use only 1% of the machines you used to require, by migrating away from Python. This is very realistic for companies doing heavy computational work.
Libraries generally write hot code in languages like C, C++, or Rust and bind that to Python (PyTorch, etc.) or provide bindings/wrappers around libraries in those languages (SQLite, PostgreSQL, etc.).
As with anything performance related you need to profile the code with realistic data/workflows and identify the parts that are slow.
Typically, doing things like changing algorithms, data structures, careful use of caching, reusing calculations, etc. are more important to performance than the choice of language.
What you're saying is valid too; but, the post you're replying to implied most slowness is network (i/o bound) or bad architecture (accidental cpu bound, fixable by tech debt cleanup).
That post was also asking if other people have seen language mattering. In the places where I've worked programs are often CPU bound. Places like these are why compiled languages are still alive and kicking.
I'm not denying that domains exist where being I/O bound is a thing. For those cases Python can be a fine choice.
We all have different lenses on the makeup of the entire set of software out there, it's likely you're coming from that experience and the other post was coming from experience mostly with i/o bound software.
For cpu bound stuff the language makes potentially an enormous difference; but then you get to trade off: eg. if you're not gonna need a fast language you are free to choose based on other considerations.
Might still both pick the same language though ;)
This conversation is pointless. The answer to whether some people see actual problems in the real world© with using very slow interpreted languages is "yes."
I'd make the case that everything on a computer is CPU bound depending on scale, even your crud app. Half the time when somebody is saying that X is I/O bound, they actually mean that it's bound by the performance of their database - which wisely, in the real world, is not written in python.
edit: and, of course, things in python that would run terribly slow if written in python become primitives, which are written in C. Python is a C program.
The easiest way to have an I/O bound workload is to use fast languages.
In my experience memory issues are more common. The way JS stores objects in memory is fundamentally inefficient (though it’s deliberate, it’s why you can do object.propertyIJustMadeUp = true on anything, any number can be a float, etc) and if you’re moving a ton of data it can cause issues eventually.
The only JS-native answer is to use typed arrays, which is using a sledgehammer to crack a nut.
Mostly because anything that needed to be fast already was written in a language that allows that and most of web/app development focuses on shuffling small amounts of data around. Also pure Python is worse than node in this aspect. Still, there many non-trivial cases. There is a reason most of infrastructure moves to Rust. I've seen poetry spending 30min (!) on dependency resolution once. Test runners and some background/nightly data processing if often first place where you realize you may want to rewrite.
Yes. Most often with Python. People think performance isn't going to be a problem and by the time it inevitably is, it's far too late to use a better language. (At least before AI.)
I've seen this at almost every company I've worked at.
This looks very AI-generated.
We took this route in a Python web framework I maintain: route matching, JSON encoding, request body parsing, compression and some other specific parts moved to Rust with PyO3, everything else stayed in Python.
How do you feel about your decision now that this has been done? Was it worth it or not?
For the parts that scale, yes. I build a CI step for measuring the performance with Callgrind since last pure-python release, and we achieved good numbers: matching the last of 200 routes dropped to about half the cycles and serializing a large JSON to about 25% less. So it pays off for work that grows with the input.
Note that this strategy only works if 5% of your software is the problem - because of Amdahl's law.
Funny that this codebase is 62% Rust, 9% Python. And I'm a huge Rust proponent.
Why is that funny? He rewrote the slow 9% in Python.
Or just rewrite in Numba.
Most often, Python is enough.
Hell no. Rust is easier to read, write, maintain and reason about. Way more people know Rust than Python/Python internals/Numba interactions. Numba will either get you relatively low gains with little effort, or push into territory very you write code few people will understand, because reasoning about its performance requires deep knowledge of Numba and Python internals. Rust gives a lot more ROI and looks more like Python.
"Easier to read" is really doing a lot of work in this statement. Highly debatable.
Harder to read, easier to understand.
Not my experience, actually. Numba and other such techniques (like having some hot paths in C/Rust/whatever) works, but eventually just allocating and deallocating Python objects starts to become a measurable problem. Especially if you have any kind of fancy metaclasses, descriptors, etc. "So don't"--ok, so give up Python's dynamic features? Why bother at that point. Now it is so cheap to write code anyway, why bother with Python at all? Have a design document in actual English.
No language will save you from inefficient memory allocation patterns.
But if you can optimize C, most often you can also optimize Python.
I have a SLAM implementation in pure Python+Numba where all points/keyframes are kept in a single flat table, no allocation.
The results section feels a bit like a joke. They rewrote C and C++ to Rust for performance?
And something tells me C# and Java could have gotten 90% of the improvement without any rewrite. I'll have to try later today.
It looks like it finds hot paths, rewrites them into Rust so you can just insert them into Python code vs rewriting everything into C# or Java.
I'm... not so sure why you need a repo for that. It's almost 2027. You can literally just type "profile this app and find out the performance bottleneck" then "rewrite it in rust" in your agent TUI...
reminded me of :- https://x.com/karpathy/status/2116980174667583602
This way the trickiest parts of the codebase get reweritten in a language you don't even know...
Doesn't seem a recipe for success
Nah. Do it in Swift.
Hah, pretty neat!
I recently discovered that one can apparently distribute Rust projects on npm by compiling to wasm. action-validator used to do this. Had been thinking about something like this.
Doesn't that kind of defeat the purpose? Compiling to WASM is going to erase any speed advantage you'd get from native Rust.
wasm compiled to native is only ~62% slower (LLVM) and only 3% slower for non memory bound operations.
This cope was common 20 years ago with Python. It rarely worked out. It's rare that 5% of your program is taking up that large a percentage of your execution. It's usually much more spread out than that.
Also, we have LLMs now. Rust should be the default for many things.
"Also, we have LLMs now. Rust should be the default for many things." ...
Or C Or Go Or ... Its like people can not look past one language, to understand that with LLMs, a ton of languages gotten way more easy.
Personal experience that running a few subagents parallel with Rust, just slows everything down to a crawl, even wit ccache and a ton of other tweaks. As long as your codebase is a few 100k lines, Rust is ok. But start going in the 500k, 1 million... starting to get C++ flashbacks where your spending more time waiting on the compile jobs, that fight each other for resources then actual testing.
Until Rust can fix their slow and resource munching compiler, its been off the menu for me. Ended up having everything in C and the difference was very noticeable.
Didn’t you know that rust is the awesomest most ultimate language ever!?!
What does %LANGUAGE% have anything to do with the goal? Totally same principles apply for any other lower level language: Zig, C.
While Rust is awesome, a lot of times the only apparent reason to chose Rust over C is virtue signaling.
Update: like I said, Rust is awesome and has so many advantages over C it's not worth a discussion really. But again I see that many projects are choosing Rust not because of merits but simply because it's a fashion.
> the only apparent reason to chose Rust over C is virtue signaling
If you'd said another memory safe language I might have been on board, but C? We've seen a complete collapse in the ability of software to go un-hacked and un-exploited. Not all of that is down to poor memory safety of course, but it's a category of vulnerability that is massively increased in both surface and risk by choosing to write C.
Choosing Rust alone might be virtue signalling, but choosing a memory safe language is just pragmatic.
In this particular topic (performance) Rust matters because it will deliver excellent performance. You could write a container -> map -> map -> container flow in fifty memory safe languages, but probably it would be a bit slower than the nasty hack you'd write in C to convert the data in place. Rust isn't, if you're intrigued you will discover that Rust 1) figured out that the two containers must be the same size in memory so it can re-use the original container and 2) did the in-place conversion even though that wasn't what you wrote, because it's faster.
So magically the Rust was just as fast, but much more readable and when a junior (or an LLM) modifies it slightly so that the output container is bigger it won't suddenly segfault due to that scary in-place conversion loop now being a bounds miss, the Rust won't attempt the in-place conversion now that it can't work.
In the age of machine-generated code, why not ask LLMs to write "safe C"?
You've received downvotes, but I'll do you the kindness to actually answer you.
Firstly the obvious, LLMs aren't perfect yet, they still make mistakes.
But even if they could achieve safe C by asking them to "Write Safe C, Make no mistakes", there would still be a significant benefit to achieving safety by using Rust or a memory safe language.
LLMs work best when they have a combination of clear objective functions and guardrails. In this case, the compiler acts as a guardrail to keep it safe while trying to solve the problem that needs solving.
Having a compiler step prevents the LLM taking a "shortcut". Despite models improving, they will still take shortcuts, sometimes absurd ones, to meet some definition of a "job done".
The other massive benefit is cost and speed. Having an LLM analyze and reason about the safety is expensive and wasteful. Having this done at compile time is cheaper and quicker. The earlier in the feedback loop, the cheaper it will be.
Save your tokens for "real" work, not stuff you can check at compile time.
That's a pile of bollocks.
Rust protects you from a whole class of bugs (borrow checker) and lets you enforce almost as many invariants as you chose, through the type system.
LLM are just as bad as humans at enforcing/tracking ownership and invariants.
We maintain two code bases; one is TS and the other Rust.
Both are by now written foremost by agents (since August 2025, I'd say).
We had numerous non-(business)-logic bugs in the TS code base over this period.
Zero such bugs in Rust. Because the compiler catches them for us. All bugs we had in that code where actual logic bugs. I.e. the spec already had the bug or contained an oversight.
Zero.
We have since started rewriting the TS code base in Rust and will likely switch over in the next three months.
> virtue signaling
Seems like just virtue to me. The guy who volunteers every week to pick up garbage from the beach isn't virtue signalling, he's just virtuous. The guy who came once, with a film crew and left once they'd got the shots they wanted - that is virtue signalling. They're both shown in the film, but only one of them actually does the signalled virtuous activity when the cameras aren't rolling.
You could argue that RIIR was conducted as virtue signalling if what we saw was one of those translations smeared in unexplained unsafe blocks, with rats nest logic that no human is going to untangle. But that doesn't seem to be the case here.
> a lot of times the only apparent reason to chose Rust over C is virtue signaling.
Quite the opposite. Outside of a couple of very specific kind of cases (for example working with microcontrollers not supported by Rust toolchain), there is no good reason to choose C when you could choose Rust.
Choosing C over Rust means throwing away the memory safety features that Rust gives you for free. And for what? There is just no upside to choosing C in the vast, vast majority of cases.
Today I added Rust checked arithmetic which detects and protects math bugs such as integer addition overflow and division by zero.
Rust checked arithmetic is built into Rust's standard library (std) via explicit methods on primitive integer types (such as checked_add, checked_sub, checked_mul, and checked_div), which return Option<T> and evaluate to None on overflow. There's a known tradeoff of some speed, which is fine for my purposes because I need reliability more than raw speed.
I'm longtime C coder so I know how to do this in C. Rust strong types and static analysis make it so much easier to do correctly.
This is in the C23 standard library as well, just without nice sum types sadly.
That's actually why we chose Rust over C at my new company, Virtual Signaling as a service™. We rewrite anything in Rust for companies looking to virtue signal.
Rust's incredibly strict and detailed static analysis, while a huge headache for human developers, is really useful with LLMs.
> While Rust is awesome, a lot of times the only apparent reason to chose Rust over C is virtue signaling.
That seems like an extremely dubious claim.
Rust is just a lot more pleasant to work with in every possible way. C has the abstractive capabilities of a deaf-blind toddler.