hckrnws
One of my best commits was removing about 60K lines of code, a whole "server" (it was early 2000's) with that had to hold all of its state in memory and replacing them with about 5k of logic that was lightweight enough to piggyback into another service and had no in-memory state at all. That was pure a algorithmic win - figuring out that a specific guided subgraph isomorphism where the target was a tree (directed, non cyclic graph with a single root) was possible by a single walk through the origin (general) directed bi-graph while emitting vertices and edges to the output graph (tree) and maintaining only a small in-process peek-able stack of steps taken from the root that can affect the current generation step (not necessarily just parent path).
I still remember the behemoth of a commit that was "-60,000 (or similar) lines of code". Best commit I ever pushed.
Those were fun times. Hadn't done anything algorithmically impressive since.
this kind of commit doesn't show up often. deleting 60k lines and replacing with 5k isn't cleanup, it's more of a system rethink.
the old in-memory server probably had its own lifecycle, metrics, odd bugs, maybe dedicated infra gone. replaced with a stateless walk that folds into an existing path. classic elimination.
but that move isn't free. old code might've handled more edge cases, had debug affordances, cleaner isolation. once logic folds into another service, boundaries blur. tighter coupling, tighter mental load. the only way it works is if the new shape fits in your head. most teams don't go there.
this commit worked because the author re-asked the core question: do we even need to store this? most infra solves for better state handling. this avoided state entirely.
this maynot be context for most bluewhale commits.
and also this has to rewrite and breaks review muscle memory. you have to review a different mental model. surface evel diffs don't catch that. you have to re-simulate the logic from first principles.
reviewers can't grep intent. does the graph walk preserve behavior or did the merge introduce contention upstream or was state removed on purpose?
this has its own affects and effects tbh.
I'm sick and tired of all these AI generated comments. Oh you got the AI to use lower case! Wow it still writes the exact same way.
On a medium sized system that isn't young and fresh deleting 60 KLOC is highly unlikely to reflect a "system rethink".
Is this, from elsewhere in the thread, a system rethink, https://github.com/dotnet/runtime/pull/36715/files ?
I've worked on a product that reinvented parts of the standard library in confusing and unexpected ways, meaning that a lot of the code could easily be compacted 10-50 times in many place, i.e. 20-50 lines could be turned into 1-5 or so. I argued for doing this and deleting a lot of the code base, which didn't take hold before me and every other dev left except one. Nine months after that they had deleted half the code base out of necessity, roughly 2 MLOC to 1 MLOC, because most of it wasn't actually used much by the customers and the lone developer just couldn't manage the mess on his own.
I wouldn't call that a system rethink.
Nice when you turn an entire server into a library/executable.
What did the software product do?
Sounds interesting. Have you written about it in more detail somewhere?
In college I worked for a company whose goal was to prove that their management techniques could get a bunch of freshman to write quality code.
They couldn't. I would go find the code that caused a bug, fix it and discover that the bug was still there. Because previous students had, rather than add a parameter to a function, would make a copy and slightly modify it.
I deleted about 3/4 of their code base (thousands of lines of Turbo Pascal) that fall.
Bonus: the customer was the Department of Energy, and the program managed nuclear material inventory. Sleep tight.
> make a copy and slightly modify it
In addition to not breaking existing code, also has added benefit of boosting personal contribution metrics in eyes of management. Oh and it's really easy to revert things - all I have to do is find the latest copy and delete it. It'll work great, promise.
I mean…when you have a pile of spaghetti, there is only so much you can do.
Ask for more staff, reorganize the team into a set of multiple teams, and hire more middle management! Win win for the manager.
Add tests to the function as it exists today. Submit. Add new functionality, make sure tests still pass. Done. Updating a function here and there shouldn't require more staff.
Immutable functions! I guess that’s one way of doing functional programming /s
I work with someone who has a habit of code duplication like this. Typically it’s an effort to turn around something quickly for someone who is demanding and loud. Refactoring the shared function to support the end edge case would take more time and testing, so he doesn’t do it. This is a symptom of the core problem.
I've been getting stricter about not letting that stuff into the codebase. They always say they'll clean it up later but they never do.
I once had to deal with some contractors that habitually did this, when confronted on how this could lead to confusion they said "that's what Ctrl+F is for."
Was this in Blacksburg by any chance?
It was indeed! Back in the late 80s. You know of it?
It was so long ago it feels half mythical to me.
[dead]
Related. Others?
Negative 2000 Lines of Code (1982) - https://news.ycombinator.com/item?id=33483165 - Nov 2022 (167 comments)
-2000 Lines of Code - https://news.ycombinator.com/item?id=26387179 - March 2021 (256 comments)
-2000 Lines of Code - https://news.ycombinator.com/item?id=10734815 - Dec 2015 (131 comments)
-2000 lines of code - https://news.ycombinator.com/item?id=7516671 - April 2014 (139 comments)
-2000 Lines Of Code - https://news.ycombinator.com/item?id=4040082 - May 2012 (34 comments)
-2000 lines of code - https://news.ycombinator.com/item?id=1545452 - July 2010 (50 comments)
-2000 Lines Of Code - https://news.ycombinator.com/item?id=1114223 - Feb 2010 (39 comments)
-2000 Lines Of Code (metrics == bad) (1982) - https://news.ycombinator.com/item?id=1069066 - Jan 2010 (2 comments)
Note for anyone wondering: reposts are ok after a year or so (https://news.ycombinator.com/newsfaq.html).In addition to it being fun to revisit perennials sometimes (though not too often), this is also a way for newer cohorts to encounter the classics for the first time—an important function of this site!
I am a simple man I see -2k lines of code, I upvote
I've told this story to every client who tried schemes to benchmark productivity by some single-axis metric. The fact that it was Atkinson demonstrates that real productivity is only benchmarkable by utility, and if you can get a truly accurate quantification for that then you're on the shortlist for a Nobel in economics.
An old Dilbert cartoon had the pointy haired boss declare monetary rewards for every fixed bug in their product. Wally went back to his desk murmuring "today I'm going to code me a minivan!"
Sorry what's the minivan reference?
it's just a stand-in for "expensive but relatable purchase". He's saying "I'm about to write so many bugs that the sum reward will be in the tens of thousands"
I assume a cycle of write bug -> fix bug -> get paid until they can afford a new car!
https://i.imgur.com/tyXXh1d.png
My manager has it pinned on the breakroom wall.
This is a good example[1] at 64k LOC removal. We removed built-in support for C# + WinRT interop on Windows and instead required users to use a source-generation tool (which is still the case today). This was a breaking change. We realized we had one chance to do this and took it.
I think of this story every time I see a statistic about how much LLMs have "increased the productivity" of a developer
Don't be too hard on AI, it can delete code too!
https://forum.cursor.com/t/cursor-yolo-deleted-everything-in...
Comment was deleted :(
Or the current industry favourite, “X% of our new code is now written by AI!”
Including the cost to build and maintain new nuclear power plants takes developers' efficiency into absurdity.
Before a recent annual performance review, I looked over my stats in the company monolith repo and found out I was net-negative on lines of code. That comes mostly from removing auto-generated API code and types (the company had moved to a new API and one of my projects was removing v1) but it was quite funny to think about going to work every day to erase code.
A long time ago I was working in a big project where the PLs came up with the most horrible metric I've ever seen. They made a big handwritten list, visible for the whole team, where they marked for each individual developer how many bugs they had fixed and how many bugs they had caused.
I couldn't believe my eyes. I was working in my own project beside this team with the list, so thankfully I was left out of the whole disaster.
A guy I knew wasn't that lucky. I saw how he suffered from this harmful list. Then I told him a story about the Danish film director Lars von Trier I recently had heard. von Trier was going to be chosen to appear in a "canon" list of important Danish artists that the goverment was responsible for. He then made a short film where he took the Danish flag (red with a white cross) and cut out the white lines and stitched it together again, forming a red communist flag. von Trier was immediately made persona non grata and removed from the "canon".
Later that day my friend approached the bugs caused/fixed list, cut out his own line, taped it together and put it on the wall again. I never forget how a PL came in the room later, stood and gazed at the list for a long time before he realized what had happened. "Did you do this?" he asked my friend. "Yes", he answered. "Why?", said the PL. "I don't want to be part of that list", he answered. The next day the list was gone.
A dear memory of successful subversion.
I'm having a lot of trouble visualizing both the flag and the list modifications.
Comment was deleted :(
Just today I commited a +0-2kLOC change, removing two months of my coworker's contribution, because it had to be rewritten. Best feeling ever.
Adding that code was not a waste even. You don't have to work every line of code like a mule. Code ...is... thinking.
This is how you turn unwanted dependencies and inability to make string searches a virtue.
"Every line of code not written is a correct one".
One of the early Ruby Koans, IIRC, circulated on comp.lang.ruby around 2002
Should have said “Every line of Ruby code not written is a correct one”
bill rewrote the region engine, made it faster, simpler, smaller and 2k lines gone. when asked for his weekly contribution count, he wrote "-2000". thenafter they stopped asking. lol some work shows up in results, not in lines
I am currently working on a piece of code which I am actively trying to simplify and make smaller. It's not a piece of code which has any business ever getting larger or having more features. The design is such that it is feature complete until a whole system redesign is required at which point the code would be itself wholesale replaced. So I am sitting here trying to codegolf the code down in complexity and size. It's not just important to keep it simple, it's also important to keep it small as this bit of code is, as part of this solution, going to be executed using python -c. All the while not taking the piss and making it unreadable (I can use a minifier for that).
Comment was deleted :(
In an old ops role we had a metric called ticket touches. One of my workmates had almost double of everyone else but only for that metric. We had a look and it was due to how he wrote notes in tickets instead of putting all his findings in a comment he would do it incrementally as he went along. Neither of these ways were wrong it just inflated that stat for him.
I am net negative in lines of code added to two different companies I've worked for. I wear that proudly.
This being Lisa that's -2000 lines in 68k assembler. That's about as verbose as any real PL can ever get.
For what it's worth, here's quicksort in 5 lines of haskell https://stackoverflow.com/questions/7717691/why-is-the-minim...
That's not quicksort, though, because it's not in place; the actual quicksort on that page is in https://stackoverflow.com/a/7833043, which is 11 lines of code. That's still pretty concise. My own preferred concise, or at least terse, presentation of quicksort is http://canonical.org/~kragen/sw/dev3/paperalgo#addtoc_20.
How long would a quicksort (say, of integers) be in 68000 assembly? Maybe 20 lines? My 68000 isn't very good. The real advantage of writing it in Haskell is that it's automatically applicable to anything that's Ord, that is, ordered.
Not true quicksort though :)
That's the problem with comparing lines of code: you're comparing apples and oranges. In this case you aren't even solving the same problem.
Are... are you comparing quicksort to... Quickdraw?
Lol - ok that's genuinely funny :). slow clap
A manager asking you to tell them how many lines of code you wrote is peak middle-management. Like what are you even doing, you count them.
Just because lines of code is being reported it didn't mean that bigger automatically means better. It does tell a story about how one is spending their time though.
I often have a mental picture of the thing I need, I start writing it, get a bit "stuck" on architecture and think I could be using a ready made library for this. I find one or a few of them, look at the code (which is obviously more generic) and realize it's many times as large as I thought the entire project should be. With few exceptions the train of thought doesn't even reach the "Do I want to carry this around and baby sit it?" stage. Some how this continues to surprise me every time.
These 5 lines are probably my favorite example.
This just depresses me. So many programmers back then spent time optimising algorithms. Now it's slop city.
I've been playing with Claude 4 Sonnet in VS Code and found it quite good. As part of the development plan, on its own it had included an optimization phase where it profiled my go code, identified some hot spots, and proposed ways to optimize it. For the most critical area, it suggested using a prefix tree which it wrote on the spot, adapted to my code, wrote benchmarks to compare the old and new version (5x improvement). Then it wrote specific tests to make sure both versions behaved the same. Then it made sure all my other tests passed and wrote a report on everything.
There were three performance optimizations in total, one which I rejected because the gain was minimal for typical use case and there are still some memory allocation optimization which I have deferred with because I'm in the middle of a major refactor of the code. The LLM has already written down plans to restart this process later when I more time.
NoScript link: https://www.folklore.org/Negative_2000_Lines_Of_Code.html
Thanks. @dang update URL?
[dead]
Software metric are hard, indeed :) Be prepared in a ai-code world when more code does not mean better code.
I've been watching my colleagues' adoption of Copilot with interest. From what I can tell, the people who are the most convinced that it improves their productivity have an understanding of developer productivity that is very much in line with that of the managers in this story.
Recently I refactored about 8,000 lines of vibe-coded bloat down into about 40 lines that ran ten times as fast, required 1/20 as much memory, and eliminated both the defect I was tasked with resolving and several others that I found along the way. (Tangentially, LLM-generated unit tests never cease to amaze me.) The PHBs didn't particularly appreciate my efforts, either. We've got a very expensive Copilot Enterprise license to continue justifying.
I don’t believe your numbers unless your colleagues are exceptionally bad programmers.
I’m using AI a lot too. I don’t accept all the changes if they look bad. I also keep things concise. I’ve never seen it generate something so bad I could delete 99 percent of it.
I've never seen 8000 -> 40, but I have done ~10 kLoC -> ~600.
Aggggressively "You can write Java in any language" style JavaScript (`Factory`, `Strategy`, etc) plus a whole mini state machine framework that was replaceable with judicious use of iterators.
(This was at Google, and I suspected it was a promo project gone metastatic.)
90%+ is a stretch. Anecdotally I have cleaned up a vibe coded PR and removed at least half of the code. The thing with the LLM is that often they will make some decision up front that has downstream ramifications for how the entire project's code is structured. I don't think I've seen an LLM re-visit it's assumptions, instead they code around them.
In the case I saw, it was rust code and the LLM typed some argument as a Arc<Mutex<_>> when it absolutely did not need to, which caused the entire PR to inflate. The vibe coder apparently didn't catch this and just kept it vibing... Technically the code did what it needed to do but was super inefficient.
It would have been easy for me to just accept the PR. It technically worked. But it was garbage.
Yes. This is why I’m still “designing” projects and asking fairly specific things most of the time.
But it’s pretty obvious when it produces garbage. So you’d reject it there and then. At the very least code review will raise so many questions. How did 8000 lines make it into the code base?
I think you are over-estimating how much people care. If the code runs and provides the desired result, there are many, many people who will simply ship it. This is the bed we made for ourselves.
Every now and then, in between reasonable and almost-reasonable suggestions, Copilot will suggest a pile of code, stylistically consistent with the function I’m editing, the extends clear off the bottom of the page. I haven’t been inspired to hit tab a couple times and try to reverse engineer the resulting vomit of code, but I can easily imagine a new programmer accepting the code because AI! or, perhaps worse, hitting tab without even noticing.
"8,000 lines of vibe-coded bloat down into about 40 lines" ... I just saw a vision of my future and shuddered.
I mean, I like killing crappy code as much as the next guy, but I don't want that to be my daily existence. Ugggh.
I see a stratified software market in the future.
There will be vibe and amateur banged out hustle trash, which will be the cheap plastic cutlery of the software world.
There will be lovingly hand crafted by experts code (possibly using some AI but in the hands of someone who knows their shit) that will be like the fine stuff and will cost many times more.
A lot of stuff will get prototyped as crap and then if it gets traction reimplemented with quality.
Where's the part where it's different from the existing market?
What I meant was that the contrast will become much more extreme, like the difference between fine silverware and bulk plastic cutlery from Wal-Mart.
Pre-vibe-coding it was more like the difference between fine silverware and cheap stamped metal stuff.
This was said about large frameworks like electron on the desktop, but outside of some specific technical niches it literally doesn’t matter to end users.
It does matter and they do care; they just don't have the specific technical knowledge to pinpoint why their computer sucks now.
A beautiful vision.
If the vision were true, we should see it happen with normal goods too. Quality physical goods do not beat the shit goods in the market : crap furniture is the canonical example (with blog articles discussing the issue).
Software (and movies) is free for subsequent copies, so at first sight you might think software is completely different from physical goods.
However for most factory produced goods, designing and building the factory is the major cost. The marginal cost of producing each copy of an item might be reasonably low (highly dependent on raw materials and labor costs?).
Many expensive physical goods are dominated by the initial design costs, so an expensive Maserati might be complete shit (bought for image status or Veblen reasons, not because it is high quality). There's a reason why the best products are often midrange. The per unit 2..n reproduction cost of cheap physical goods is always low almost by definition.
Some parts of iPhone software are high quality (e.g. the security is astounding). Some parts are bad. Apple monetisation adds non-optional features that have negative value to me: however those features have positive value to Apple.
Back in the day, if you went to a website you could always tell who wrote their HTML by hand and who used a tool like GruntPage, Dreamweaver, etc. even without looking at the META tags. The by-hand stuff was like a polished jewel that had only as much layout, styling, and markup as needed to get the desired effect. The proprietary web editor stuff was encrusted with extraneous tags and vendor-specific extensions (like mso: attributes and styles in GruntPage).
Then as now, if you let the machine do the thinking for you, the result was a steaming mess. Up to you if that was accessible (and for many, it was).
You can make the same claim about compiled code vs hand written assembly, and yet the vast majority of software is compiled or interpreted.
In the past, hand-crafted assembly code was common because it was easy to beat the compiler. This is still true today in some niches.
A compiler is written by very smart humans to a spec written by humans, also probably smart but I don’t know enough to claim that bit.
An LLM is just displaying the next statistical token.
Completely different.
Or, as I like to put it, pulling out the next refrigerator poetry tile from a stochastic bag of holding.
yeah this is it ...
> Tangentially, LLM-generated unit tests never cease to amaze me.
In a good or bad way?
I've found AI pretty helpful to write tests, specially if you already have an existing one as a template.
I would love to know the time balance between the two activities. It takes nothing to generate slop, but could be weeks to extricate it.
This is also true for human code, more often than not.
[dead]
This is one of those stories that I am sure has happened, but when it comes to "and then they never asked him again le XD face" it's clearly just made up.
Bill Atkinson recently died and there’s a great HN discussion about him. He had a good relationship with Steve Jobs; it’s reasonable to assume it’s true that he got left alone, especially if Andy Hertzfeld is the person making the assertion.
1. The site is called folklore.org. You’re sort of saying the site is true to its name.
2. It’s a direct recollection from someone who was there, not an unnamed “my cousin’s best friend” or literal folklore that is passed down by oral tradition. Andy knew Bill and was there. There is no clear motivation to tell a fictional story when there were so many real ones.
3. The specifics line up very well with what we know about Bill Atkinson and some his wizardry needed to make the Mac work.
Given this, it’s much easier to assume that your assertion is what is made up.
I've pulled stunts like this that makes management realize its easier to make an exception than to fight it
We had free soft drinks in the fridges at one place I worked. Cost-cutting measures were coming and I sent an email to all of engineering (including the VP) asking who wanted to join me in a shopping trip at 10AM to restock the fridge. In the email, I estimated that it would take between 60 and 90 minutes. Two carfuls of engineers left at 10AM sharp and returned a little before noon and restocked the fridges.
That was the first and last time we had to do it, as the soft drinks returned the following week.
management could have decided on a process change. Simple as that.
I get the sentiment though, "He blew management's mind so much they made an exception for him".
But, Folklore.org is a bit less onanistic than ESR's jargon file.
It was Bill fucking Atkinson. Not a disposable random contractor you hire by the dozen when you need to build more CRUD APIs.
At that time at Apple, even as an IC, Bill had lines of communication to Steve and was extremely valued. There's absolutely no doubt he could get "middle manager shenanigans" gone simply by not complying or "maliciously complying". Hell, I've seen ICs far less valuable, or even close to negative value get away with stunts far worse than these, succeed and keep their jobs. Out of all the stories in Folklore.org, this is the one you have an issue with?!
Most people know who Bill Atkinson on this forum. The story premise that he wrote negative code isn't my gripe, I am sure it happened.
The outcome where all of a sudden leadership just shit its pants and doesn't communicate at all and never followed up... It's like writing "and then everyone clapped" for programmers.
Man you must have only worked with really good management. "Management realised the stupid policy change they announced with great fanfare was stupid, stopped doing it, and never mentioned it again" is something I've seen several times in my career.
It just occurred to me that really good management is like a fruit at the optimum of its ripeness - it stays that way only for a while so enjoy it while it lasts otherwise it will rot and stink.
> The outcome where all of a sudden leadership just shit its pants and doesn't communicate at all and never followed up...
This is not only a possible outcome, it is a common one. When leadership realizes it was a mistake to instill one of these types of "productivity motivators", it is easier to disappear it and never (officially) speak of it again.
Crafted by Rajat
Source Code