the true performance hog is like sand, spread across the system, a little bit in every place.
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, visualizations, logging, 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
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.
Oh, and they can be annoying to refactor later on.
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.
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.
Personally I think it’s a very good trade-off for vastly more businesses and services than actually practice it.
I suspect I may have seen more systems run into availability problems from unnecessarily distributed architectures than from hardware failure, and I’ve definitely seen costlier development due to it.
(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).
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.
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.
The choice of language determines the extent to which those things are possible. In case of Python using C libraries sometimes means that you pull data from somewhere, hold them in Python memory in very inefficient way, pay for transformation to another form that C library uses and then do the same in reverse at the end. Perhaps even more times if C doesn't handle everything. "Use C libraries" often works, but is not universal solution.
I'm not denying that domains exist where being I/O bound is a thing. For those cases Python can be a fine choice.
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 ;)
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.
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.
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.
The only JS-native answer is to use typed arrays, which is using a sledgehammer to crack a nut.
Developers rewrite code in rust for memory safety, not speed.
Py2many is an implementation of these concepts.
Rust itself had an understandability issue until LLMs came along and started speedrunning parts of the Rust development process, so this argument is language AND time immaterial.
And something tells me C# and Java could have gotten 90% of the improvement without any rewrite. I'll have to try later today.
Doesn't seem a recipe for success
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.
Most often, Python is enough.
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.
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.
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.
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.
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.
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.
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.
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 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.
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.
Rust's async situation is still a pain in many ways.
But throwing Rayon at something often results in very reasonable parallel performance gains without cluttering things much. It usually won't get you to an optimal solution, but it's good for 80% with 10% of the pain.
The port was pretty direct, function for function. It was even line for line where language and library differences didn't offer an easier way. I was just trying to see if Python was so slow that we couldn't consider using it in production, and this was the most speed critical batch we had.
I assumed the speed difference was a bug that was skipping work, but that seemed unlikely because the output was correct. It turned out to be a bug in the C++ code that was needlessly reproducing work (an issue with cache keys). The bug was extremely subtle. When I fixed the C++, there was very little difference in speed as the batch was I/O bound when the cache was working.
So, adding to your point, sometimes you can greatly improve speed by rewriting in a slower language, even without performance in mind.
But also technically I think your point still stands. Because rewriting it helped you find a defect in the original. Which did improve performance of the original.
It’s quite interesting the two implementations performance was so close in the end. Do you consider one implementation “better” for non-performance reasons? Maybe one type of dev is easier to find. Or one language is easier to create and maintain correctly behaving programs in your environment?