But, sometimes you are. As a well known example, someone rewrote http/urllib in Python as requests and urllib3. Better on perhaps every single metric, often substantially. Ban rewrites and it wouldn’t exist.
My own example, a recent modernization of an ETL project. Original code was a rickety, amateurish, impenetrable mess written in Java transcribed into Python. Loops over loops over loops ten layers deep—would often get lost tracing a bug. Author didn’t understand argparse or logging but used them everywhere. Author didn’t understand absolute paths so there were a dozen and a half custom path join functions sprinkled around the codebase because std path.join didn’t work with relative paths starting with a slash.
For new feeds, over two years I built a brand new streamlined (half the code), dare I say elegant replacement, with tons of quality of life and efficiency features. Like shell completion, syntax highlighting for interactive logs, and conditional download (304) handling. Headline feature, encapsulation of the entire model update process with a single manager method that does almost everything that took bespoke code written forty separate times in the old classes.
As the old feeds are going away all the crap is inching towards /dev/null. Can’t wait for the celebration. Gonna crank Kool and the Gang, I tell ya. :-D