News for hackers. Stuff that matters.
Re:-2000 Lines of Code by hinkley on Saturday March 23, 2024 @04:09AM (#39798300)
Gave myself RSI deleting <600 LOC with vi.

On the plus side I replaced an O(n²) algorithm with a faster one in the very next commit. Needed to get rid of the ninety copies of the same bad idiom first.

Re:-2000 Lines of Code by hsjsbeebue on Saturday March 23, 2024 @04:30AM (#39798369)
600dd:w shouldn’t cause RSI ;)
Re:-2000 Lines of Code by hinkley on Saturday March 23, 2024 @08:32AM (#39799466)
It was five to six lines of code repeated in half a dozen spots in a dozen files, with different variable names, and different arguments. And I wasn’t deleting them, I was replacing them with the same function call.
Re:-2000 Lines of Code by aidos on Saturday March 23, 2024 @09:24AM (#39799760)
That’s got “macro” written all over it.
Re:-2000 Lines of Code by jraph on Saturday March 23, 2024 @09:43AM (#39799880)
That's a sed /d of course. Or a "Replace all in folder" in any decent code editor.

Or a sufficiently efficient "extract to method" on a decent IDE, that notices the different occurrences even with renamed variables.

Unless those lines of code were subtly edited all over the place and needed careful and subtly different replace for each occurrence, or at last review because that's what's truly evil with duplicated code. It's forks that diverged to maintain N times in your codebase.

Re:-2000 Lines of Code by selcuka on Saturday March 23, 2024 @04:32AM (#39798377)
> Gave myself RSI deleting <600 LOC with vi.

Why? Didn't you know the shortcut `d600d`? /s

Re:-2000 Lines of Code by mehdix on Saturday March 23, 2024 @05:01AM (#39798486)
I was giving myself RSI by deleting <12000 lines of copied comments (only misleading noise, explaining what was happening) and <4000 LOC (replaced with a 120 LOC in a single fn) when I reverted to using regex while sanitizing a badly bloated codebase.

Can feel you right there.

Re:-2000 Lines of Code by jpc0 on Sunday March 24, 2024 @10:38AM (#39807497)
> when I reverted to using regex

Begrudgingly I hope...

If you replaced 4000LoC with a regex that regex scares me...

Re:-2000 Lines of Code by mehdix on Monday March 25, 2024 @01:47PM (#39819280)
haha! I did use regex to find and delete repetitive patterns of code with slight variation that would be carried out by the aforementioned function.

I wish I could write such a monstrosity though :)

Re:-2000 Lines of Code by veidelis on Saturday March 23, 2024 @05:56AM (#39798707)
Not much of an achievement, but I once deleted a 45k line Jest snapshot test for a React component that basically asserted that a div is rendered.
Re:-2000 Lines of Code by prettyStandard on Saturday March 23, 2024 @06:42AM (#39798881)
Maybe you are being sarcastic...

Or you've completely missed the point of the article/story. The point is lines of code are almost meaningless. In this story the person saved 2k lines of code by rewriting a rendering engine, and use somehow think that's less than deleting a 45 k line jest snapshot.

Re:-2000 Lines of Code by stuartd on Saturday March 23, 2024 @10:16AM (#39800073)
“Not much of an achievement, but” here refers to the commenter’s action, not the one in the article
Re:-2000 Lines of Code by veidelis on Saturday March 23, 2024 @12:39PM (#39801177)
Sorry, if it somehow sounded that my example is somehow more than what was mentioned in the article. Absolutely not. I think that my example also very well demonstrates that lines of code (even that isn't really "code") isn't not a good way of measuring productivity etc. My example could be considered as an example of how a code review didn't "do it's job" for what might have been a newbies mistake. But I also think that code reviewers cannot be blamed for every bad piece of code that gets through (context matters).