3/21/2026 at 12:03:41 AM
Something not unlike this happened to me when moving some batch processing code from C++ to Python 1.4 (this was 1997). The batch started finishing about 10x faster. We refused to believe it at first and started looking to make sure the work was actually being done. It was.The port had been done in a weekend just to see if we could use Python in production. The C++ code had taken a few months to write. 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.
A couple of us worked together for a day to find the reason for the speedup. Just looking at the code didn't give us any clues, so we started profiling both versions. We found out that the port had accidentally fixed a previously unknown bug in some code that built and compared cache keys. After identifying the small misbehaving function, we had to study the C++ code pretty hard to even understand what the problem was. I don't remember the exact nature of the bug, but I do remember thinking that particular type of bug would be hard to express in Python, and that's exactly why it was accidentally fixed.
We immediately started moving the rest of our back end to Python. Most things were slower, but not by much because most of our back end was i/o bound. We soon found out that we could make algorithmic improvements so much more quickly, so a lot of the slowest things got a lot faster than they had ever been. And, most importantly, we (the software developers) got quite a bit faster.
by rented_mule
3/21/2026 at 4:16:20 AM
My experience is the exact opposite.This was particularly true for one of the projects I've worked with in the past, where Python was chosen as the main language for a monitoring service.
In short, it proved itself to be a disaster: just the Python process collecting and parsing the metrics of all programs consumed 30-40% of the processing power of the lower end boxes.
In the end, the project went ahead for a while more, and we had to do all sorts of mitigations to get the performance impact to be less of an issue.
We did consider replacing it all by a few open source tools written in C and some glue code, the initial prototype used few MBs instead of dozens (or even hundreds) of MBs of memory, while barely registering any CPU load, but in the end it was deemed a waste of time when the whole project was terminated.
by ameixaseca
3/21/2026 at 10:34:59 AM
Ditto for me. I had gotten so used to building web backends in Ruby and running at 700MB minimum. When I finally got around to writing a rust backend, it registered in the metrics as 0MB, so I thought for sure the application had crashed.Turns out the metrics just rounded to the nearest 5MB
by czhu12
3/21/2026 at 8:05:43 AM
> but in the end it was deemed a waste of time when the whole project was terminated.The main lesson of the story. Just pick Python and move fast, kids. It doesn’t matter how fast your software is if nobody uses it.
by wiseowise
3/21/2026 at 8:27:01 AM
This is it. Getting something on the table for stakeholders to look at trumps anything else.by stephantul
3/21/2026 at 3:41:41 PM
It would have taken the same time, if not less, given the extra time for mitigations, trying different optimization techniques, runtimes, etc.One of the reasons the project was killed was that we couldn't port it to our line of low powered devices without a full rewrite in C.
Please note this was more than a decade ago, way before Rust was the language it was today. I wouldn't chose anything else besides Rust today since it gives the best of both worlds: a truly high level language with low level resource controls.
by ameixaseca
3/21/2026 at 8:32:18 AM
[flagged]by shevy-java
3/21/2026 at 11:09:59 AM
You can use Go and get the best of both worlds.by Aeolun
3/21/2026 at 1:10:30 PM
One of the slowest, most ineficient code bases I've ever worked on was in Go.The mentality was "the language is fast, so as long as it compiles we're good"... Yeah that worked out about as well as you'd expect.
by nickserv
3/21/2026 at 3:40:16 PM
But that has nothing to do with the language.by zeroc8
3/21/2026 at 7:53:12 PM
Absolutely, and it's a good language when used properly. This was more of a problem with the hype surrounding it.by nickserv
3/21/2026 at 6:47:48 PM
> Just pick Python and move fast, kids. It doesn’t matter how fast your software is if nobody uses it.The reason nobody uses your software could be that it is too slow. As an example, if you write a video encoder or decoder, using pure Python might work for postage-stamp sized video because today’s hardware is insanely fast, but even, it likely will be easier to get the same speed in a language that’s better suited to the task.
by Someone
3/21/2026 at 6:59:29 PM
Learning that it’s too slow takes users.by wiseowise
3/22/2026 at 7:18:04 AM
In some cases, common sense of developers can do that, too.by Someone
3/22/2026 at 12:53:43 AM
They were the users and it was too slow for them so they switched to python. Not C++ of course, what they meant was "the libraries we wrote in C++ were too buggy and slow that using them was slower than if we just used Python."by casey2
3/22/2026 at 7:58:27 AM
Terrible advice. Really.Most the the business I do is rewriting old working python prototypes to C++. Python sucks, is slow and leaks. The new C++ code does not leak, meets our performance requirements, processes items instead of 36 hour in 8 hours, and such.
We are also rewriting all the old python UI in typescript. That went not so easy yet.
And when there are still old simple python helpers, I rewrite them into perl, because this will continue to run in the next years, unlike python.
by rurban
3/21/2026 at 8:37:24 PM
if input() == "dynamic scope?": defined = "happyhappy" print(defined)I'd rather not use python. The ick gets me every time.
by bjoli
3/22/2026 at 6:29:58 AM
It killed ny formatting if input() == "dynamic scope?":
defined = "happyhappy"
print(defined)
by bjoli
3/21/2026 at 3:43:17 PM
I would agree except for the python part. Sure, you gotta move fast, but if you survive a year you still gotta move fast, and I’ve never seen a python code base that was still coherent after a year. Expert pythonistas will claim, truthfully, that they have such a code base but the same can be said of expert rustaceans. I would stick to typescript or even Java. It will still be a shitshow after a year but not quite as fucked as python.by lowbloodsugar
3/21/2026 at 4:03:37 PM
https://github.com/polarsource/polar/tree/main/serverIf you're writing FastAPI (and you should be if you're doing a greenfield REST API project in Python in 2026), just s/copy/steal/ what those guys are doing and you'll be fine.
by miki123211
3/21/2026 at 10:03:43 AM
And this is why pretty much all commercial software is terrible and runs slower than the equivalent 20 years ago despite incredible advance in hardware.by littlestymaar
3/21/2026 at 4:56:25 PM
For lots of software there wasn't an equivalent 20 years ago because there wasn't a language that would let developers explore semi-specified domains fast enough to create something useful. Unless it was visual basic, but we can't use that, because what would all the UX people be for?by philipallstar
3/21/2026 at 6:32:48 AM
Another anecdote, the team couldn’t improve concurrency reliably in Python, they rewrote the service in about a month (ten years ago) in Go, everything ran about 20x faster.by serial_dev
3/21/2026 at 2:24:04 PM
He struggled with the algorithms, you struggled with the runtime.You are not the same.
by Traubenfuchs
3/21/2026 at 12:42:42 PM
> just the Python process collecting and parsing the metrics of all programs consumed 30-40% of the processing power of the lower end boxes.Just write the parsing loop in something faster like C or Rust, instead of the whole thing.
by naasking
3/21/2026 at 1:12:05 AM
> After identifying the small misbehaving function, we had to study the C++ code pretty hard to even understand what the problem was. I don't remember the exact nature of the bug, but I do remember thinking that particular type of bug would be hard to express in Python, and that's exactly why it was accidentally fixed.Pure speculation, but I would guess this has something to do with a copy constructor getting invoked in a place you wouldn't guess, that ends up in a critical path.
by asveikau
3/21/2026 at 2:01:52 AM
Given the context, I'm thinking bad cache keys resulting in spurious cache misses, where the keys are built in some low-level way. Cache misses almost certainly have a bigger asymptotic impact than extra copies, unless that copy constructor is really heavy.by andrewflnr
3/21/2026 at 2:07:09 AM
I'm just remembering a performance issue I heard of eons ago where a sorting function comparison callback inadvertently allocated memory. It made sorting very slow. Someone said in a meeting that sorting was slow, and we all had a laugh about "shouldn't have used the bubble sort!" But it was the key comparison doing something stupid.by asveikau
3/21/2026 at 11:54:17 AM
My guess would be bad hashing, resulting in too many collisions.by branko_d
3/21/2026 at 1:15:48 AM
good ol' shallow-vs-deep copyby NooneAtAll3
3/21/2026 at 6:17:05 AM
Ome advantage of python is that it is so slow that if you choose the wrong algorithm or data structure that soon gets obvious. And for complicated stuff this is exactly where I find the LLMs struggle. So I make a first version in Python, and only when I am happy with the results and the speed feels reasonable compared to the problem complexity, I ask Claude Code to port the critical parts to Rust.by tda
3/21/2026 at 6:51:11 AM
The last part is really interesting. It feels like the whole world will soon become Python/JS because thats what LLMs are good at. Very few people will then take the pain of optimizing itby rabisg
3/21/2026 at 9:11:20 AM
The LLMs are pretty good at optimising.Not because they are brilliant, but because they are pretty good at throwing pretty much all known techniques at a problem. And they also don't tire of profiling and running experiments.
by eru
3/21/2026 at 4:09:23 PM
If there's one thing LLMs are really, really good at, it's having a target and then hitting / improving upon that target.If you have a comprehensive test suite or a realistic benchmark, saying "make tests pass" or "make benchmark go up" works wonders.
LLMs are really good at knowing patterns, we still need programmers to know which pattern to apply when. We'll soon reach a point where you'll be able to say "X is slow, do autoresearch on X" and X will just magically get faster.
The reason we can't yet isn't because LLMs are stupid, it's because autoresearch is a relatively new (last month or so) concept and hasn't yet entered into LLM pretraining corpora. LLMs can already do this, you just need to be a little bit more explicit in explaining exactly what you need them to do.
by miki123211
3/22/2026 at 4:41:24 AM
> The reason we can't yet isn't because LLMs are stupid, it's because autoresearch is a relatively new (last month or so) concept [...]I'm not so sure. People have been doing stuff like (hyper) parameter search for ages. And profiling and trying out lots of things systematically has been the go-to approach for performance optimisation since forever; making an LLM instead of a human do that is the obvious thing to try?
The concept of 'autoresearch' might bring with it some interesting and useful new wrinkles, but on a fundamental level it's not rocket science.
by eru
3/21/2026 at 5:47:50 PM
I've not tried this yet, but doesn't it use up loads of tokens? How do you do it efficiently?by philipallstar
3/22/2026 at 4:40:11 AM
It uses a lot of minutes on your computer(s), since you need to run lots and lots of experiments.I'm not sure if it's particularly token hungry.
by eru
3/21/2026 at 10:00:47 AM
Not just profiling, but decoding protocols too.Recently I tried Codex/GPT5 with updating a bluetooth library for batteries and it was able to start capturing bluetooth packets and comparing them with the libraries other models. It was indefatigable. I didn't even know if was so easy to capture BLE packets.
by elcritch
3/22/2026 at 8:30:50 AM
Could you ask the LLM to do a write-up on the process and post it? (Or you can write a blog post by hand. Like a caveman. ;)by eru
3/21/2026 at 11:57:51 AM
Wireshark would do that. But you need to understand low level tools because in case on some BGP attack you all LLM developers will be fired in the spot.Flakey internet connection: most of current 'soy devs' would be useless. Even more with boosted up chatbots.
by anthk
3/22/2026 at 4:37:16 AM
> Flakey internet connection: most of current 'soy devs' would be useless.We used to make the same jokes about Googling Stackoverflow since before many users on this site were born.
by eru
3/22/2026 at 9:49:57 AM
And it's partially true. Offline documentation should be mandatory everywhere. Networks can be degraded tomorrow in the current 2nd Cold War we are living. And, yes, the states and goverments have private backbones for the military/academia/healthcare and so on, but the rest it's screwed.When the blackout the only protocols which worked fine where IRC, Gopher and Gemini. I could resort to using IRC->Bitlbee to chat against different people of the world, read news and proxy web sites over Gemini (the proto, not the shitty AI). But, for the rest, the average folk? half an our to fetch a non-working page.
That with a newspaper, go figure with the rest. And today tons of projects use sites with tons of JS and unnecesary trackers and data. In case of a small BGP attack, most projects done with LLM's will be damned. Because they won't even have experience on coding without LLM's. Without docs it's game over.
Also tons of languages pull dependencies. Linux distros with tons of DVD's can survive offline with Python, but good luck deploying NPM, Python and the rest projects to different OSes. If you are lucky you can resort to the bundled Go dependencies in Debian and cross compile, and the same with MinGW cross compiling against Windows with some Win32, SDL, DX support but that's it.
With QT Creator and MinGW, well, yes, you could build something reliable enough -being cross platform- and with Lazarus/Free Pascal, but forget about current projects downloading 20000 dependencies.
by anthk
3/21/2026 at 1:40:34 PM
Not in my experience. They're pretty good at getting average performance which is often better than most programmers seem to be willing to aim for.by mirsadm
3/22/2026 at 5:59:18 AM
What kind of 'average' is this, if it's better than what seems to be typical?by eru
3/21/2026 at 1:35:30 PM
> JS because thats what LLMs are good at.That has not been my experience. JS/TS requires the most hand-holding, by far. LLMs are no doubt assumed to be good at JS due to the sheer amount of training data, but a lot of those inputs are of really poor quality, and even among the high quality inputs there isn't a whole lot of consistency in how they are written. That seems to trip up the LLMs. If anything, LLMs might finally be what breaks the JS camel's back. Although browser dominance still makes that unlikely.
> Very few people will then take the pain of optimizing it
Today's LLMs rarely take the initiative to write benchmarks, but if you ask it will and then will iterate on optimizing using the benchmark results as feedback. It works fairly well. There is a conceivable near future where LLMs or LLM tools will start doing this automatically.
by 9rx
3/21/2026 at 3:16:56 PM
My experience is from trying to get the React Native example to work with OpenUI. Felt Sonnet/Opus was much better at figuring out whats wrong with the current React implementation and fixing it than it was with React NativeBut yes I see what you mean and I think people are trying to solve it with skills and harnesses at the application layer but its not there yet
by rabisg
3/21/2026 at 12:30:41 AM
Fun story! Performance is often highly unintuitive, and even counterintuitive (e.g. going from C++ to Python). Very much an art as well as a science.Crazy how many stories like this I’ve heard of how doing performance work helped people uncover bugs and/or hidden assumptions about their systems.
by asa400
3/21/2026 at 5:53:45 AM
It doesn't come off as unintuitive by my read. They had a bug that led to a massive performance regression. Rewriting the code didn't have that bug so it led to a performance improvement.They found that they had fewer bugs in Python so they continued with it.
by staticassertion
3/21/2026 at 7:52:41 AM
I think a lot of people (especially those who are only peripherally involved in development, like management) don't really consider performance regressions at all when thinking about how to get software to go faster.Meanwhile my experience has been that whenever there has been a performance issue severe enough to actually matter, it's often been the result of some kind of performance bug, not so much language, runtime, or even algorithm choices for that matter.
Hence whenever the topic of how to improve performance comes up, I always, always insist that we profile first.
by harpiaharpyja
3/21/2026 at 7:56:02 AM
My experience has been that performance bugs show up in lots of places and I'm very lucky when it's just a bug. The far more painful performance issues are language and runtime limitations.But, of course, profiling is always step one.
by staticassertion
3/21/2026 at 3:50:16 PM
> We soon found out that we could make algorithmic improvements so much more quicklyIt's true that writing code in C doesn't automatically make it faster.
For example, string manipulation. 0-terminated strings (the default in C) are, frankly, an abomination. String processing code is a tangle of strlen, strcpy, strncpy, strcat, all of which require repeated passes over the string looking for the 0. (Even worse, reloading the string into the cache just to find its length makes things even slower.)
Worse is the problem that, in order to slice a string, you have to malloc some memory and copy the string. And then carefully manage the lifetime of that slice.
The fix is simple - use length-delimited strings. D relies on them to great effect. You can do them in C, but you get no succor from the language. I've proposed a simple enhancement for C to make them work https://www.digitalmars.com/articles/C-biggest-mistake.html but nobody in the C world has any interest in it (which baffles me, it is so simple!).
Another source of slowdown in C is I've discovered over the years that C is not a plastic language, it is a brittle one. The first algorithm you select for a C project gets so welded into it that it cannot be changed without great difficulty. (And we all know that algorithms are the key to speed, not coding details.) Why isn't C plastic?
It's because one cannot switch back and forth between a reference type and a value type without extensively rewriting every use of it. For example:
struct S { int a; }
int foo(struct S s) { return s.a; }
int bar(struct S *s) { return s->a; }
If you want to switch between reference and value, you've got to go through all your code swapping . and ->. It's just too tedious and never happens. In D: struct S { int a; }
int foo(S s) { return s.a; }
int bar(S *s) { return s.a; }
I discovered while working on D that there is no reason for the C and C++ -> operator to even exist, the . operator covers both bases!
by WalterBright
3/22/2026 at 2:18:26 AM
Well clearly there is use for these - how do you distinguish what you are accessing in smart-pointer-like types.by garaetjjte
3/22/2026 at 4:16:11 AM
You'd still use the "." operator. Value, reference, or smart pointer use the same syntax. This means you can refactor them easily.by WalterBright
3/21/2026 at 4:44:27 PM
I ported Python to C++ one time and it ran 10c faster with 10x less memory usage with no architectural changesby zeroonetwothree
3/22/2026 at 12:48:02 AM
This is the difference between scripting and programming. If you use C++ as a scripting language you're gonna have a bad time.Of course a scripting language is faster for scripting! That doesn't mean you go full Graham and throw away real programming languages, it just means you aren't writing systems software.The usual strategy is to write a script then if it's slow see how you could design a program that would
The usual strategy in the real world is to copy paste thousands of lines of C++ code until someone comes along and writes a proper direct solution to the problem.
Of course there are ideas on how to fix this, either writing your own scripting libraries (stb), packages (go/rust/ts), metaprogramming (lisp/jai). As for bugs those are a function of how you choose to write code, the standard way of writing shell it bug prone, the standard way of writing python is less so, not using overloading & going wider in c++ generally helps.
by casey2
3/21/2026 at 12:29:58 AM
[flagged]by DaleBiagio
3/21/2026 at 3:37:08 AM
This comment comes from a bot account. One of the more clever ones I’ve seen that avoids some of the usual tells, but the comment history taken together exposes it.I hit the flag button on the comment and suggest others do too.
by Aurornis
3/21/2026 at 3:18:18 AM
Thanks, Programming History Facts BotI was not actually sure this one was a bot, despite LLM-isms and, sadly, being new. But you can look at the comment history and see.
by furyofantares
3/21/2026 at 3:09:07 AM
Until at some point in a language like python all the things that allowed you write software faster start to slow you down like the lack of static typing and typing errors and spending time figuring out whether foo method works with ducks or quacks or foovars or whether the latest refactoring actually silently broke it because now you need bazzes instead of ducks. Yeah.by samiv
3/21/2026 at 2:06:26 AM
I don't think the better software part is playing outby apitman
3/21/2026 at 2:33:53 AM
There’s a lot of really great software out there right now, and a lot that’s terrible and I think powerful abstractions enable both.by ch4s3
3/21/2026 at 2:36:19 AM
you're thinking of the programs in low-level langs that survived their higher-level-lang competitors; if you plot the programs on your machine by age, how does the low quartile compare on reliability between programs written in each groupby remexre
3/21/2026 at 12:28:58 AM
[flagged]by envguard
3/21/2026 at 9:07:04 AM
AI accountby sincerely
3/21/2026 at 8:31:05 AM
> We immediately started moving the rest of our back end to Python. Most things were slower, but not by much because most of our back end was i/o bound.Would be kind of cool if e. g. python or ruby could be as fast as C or C++.
I wonder if this could be possible, assuming we could modify both to achieve that as outcome. But without having a language that would be like C or C++. Right now there is a strange divide between "scripting" languages and compiled ones.
by shevy-java
3/21/2026 at 12:02:37 PM
@dang this is an ai slop account, check his other commentsby nubg
3/21/2026 at 8:42:48 AM
I suspect that you used highly optimized algorithms written for python, like the vector algorithms in numpy? You will struggle to write better code, at least I would.by peter_retief
3/21/2026 at 8:59:22 AM
Python 1.4 would be mid-late 90s long before numpy and vector algorithms would have been available.I suspect it’s more likely to be something like passing std::string by value not realising that would copy the string every time, especially with the statement that the mistake would be hard to express in Python.
by masklinn
3/21/2026 at 9:57:05 AM
Everything is new to the uninitiated. :Pby johnisgood