
-2000 Lines of Code - craigc
http://www.folklore.org/StoryView.py?story=Negative_2000_Lines_Of_Code.txt
======
bargl
I had a job interview once where the HR rep asked me how many lines of code I
wrote a week. I responded, "On a really good week -1000, I don't remember the
exact figure." She was extremely confused by this answer and wanted me to give
her a number. So she said, "I'll just put down 10,000."

This is also the interview where they refused to continue unless I told them
how much money I made (which I don't do anymore). The justification they told
me was that they weren't going to give me a 20K raise if I wasn't making that
much right now. I didn't point out that they aren't giving me a raise, they
are paying me market value based on what the position is worth (to
oversimplify it).

I was offered the job but decided not to take it because that plus the
technical interview made me wary.

~~~
mgkimsal
> The justification they told me was that they weren't going to give me a 20K
> raise if I wasn't making that much right now

Even after 20+ years in the labor force, I've never understood that
justification. "I'm a nosy bastard" at least has a ring of truth to it.

~~~
wdewind
Don't be so literal about it. I used to get defensive about that question too,
but the truth is they aren't asking you how much you are making, they are
asking you to start the salary negotiation so they can get a feel for what
it's going to take to hire you and describe you adequately to a hiring
manager. It's just an opportunity for you both to ballpark the situation and
eject early if there's going to be a wide disagreement about comp. It can be
equally advantageous to both parties if you use it properly.

~~~
mgkimsal
No... there are recruiters who are a lot more invasive and pushy (and a couple
employers I've run across).

"Proof of previous income" was required at one place I applied years back, and
I've heard similar stories from colleagues. No, of course, I don't bother
going forward in those situations.

"What are you making now?" is crass. The good recruiters I've worked with
phrased it as "what are your salary expectations?" or "the range is $x-$y -
are you OK with that?"

I've taken it literally in situations where they actually _meant_ it
literally. "We will not pay you $80k until you can prove you were making $80k
at your previous job". Insane, but it does happen on occasion. How those
companies ever manage to hire anyone... I'm not sure.

~~~
rhizome
I've gotten "I need a number for us to continue" multiple times.

~~~
meric
Just say "my salary expectations for this position is $XY0,000". I use it as
an opportunity to set the ballpark for the negotiation. Sometimes bosses don't
know what people are worth so they ask these kind of questions. Once we opened
an office in a new country, and when we hired people, we asked them what they
expected and gave them that + 20% because we really had no idea how much we
should be paying.

------
hibikir
It's not just old managers that dislike negative lines of code: Static
analysis tools dislike them too, under the right bureaucracy.

At a certain huge company that sells seeds, they decided to start having both
a base test coverage target, and a specific plugin that demanded that the
coverage never went back more than half a percent from the high water mark on
any given project. The engineering managers thought it was a good idea: As
time goes by, we'd have better code coverage!

I joined a team that had an application full of repetitive code, because
nobody had spent much time thinking about reuse. I decided it was bad for
maintainability, and the team let me rewrite a big chunk of repetitive, well
tested code. I shrunk the codebase by a good 10K LOC, and it still did the
same thing. Teammates liked what I had written, and everyone was happy. But
when I pushed it, the build refused to deploy, because now the code didn't
meet coverage standards.

The manager was mad at me: you wrote all that code, but I guess your unit
tests were sloppy! he said. But when I went and looked at the code changes, I
had a 100% code coverage. Since I am not a football player, I just couldn't
give 110%. So then we look at the reports, slowly, and saw that while I had
full code coverage, the code I was replacing also had full code coverage, but
mine was so much smaller, our total coverage percentage went down! 1000 lines
of uncovered code, in a codebase with 30K lines, gave us better numbers than
the same lines in our shinier 20K LOC codebase. And building tests for some
really old, badly factored code just wasn't in our top list of priorities.

The people in charge of this system refused to change it, even though it was
really not helping things in our case. So what did we do? Fool the tool, of
course. Added a bunch of well tested dead code that was never going to get
called in production, and wouldn't even get built into the binary, thanks to
some packaging magic. We put it in a separate module, clearly marked as 'dead
code to make Sonar happier', and we went our merry way.

~~~
kkapelon
Great story! You should submit this to
[http://thedailywtf.com/](http://thedailywtf.com/)

~~~
curiousGambler
Given that all I could think was "wtf?!" as that story went on, definitely!

------
gricardo99
4 months into a new job, and I realized I had contributed about -4000 lines of
code. I thought, how weird it would be to explain (especially to someone less
technical), that I'd pretty much just been deleting code since I started. I'd
also added a number of important features along the way.

Since then, I've taken some pride in trying to be a "net negative" (by line
count), contributor to any code base I work on. Not always possible, but it's
a good mindset to strive for leaner designs/implementations.

~~~
nostrademons
There was someone at Google whose total code delta over his tenure was
something like -2M. Yep, two million lines of code deleted. May we all be that
productive.

~~~
willis77
"Oh, him? That's Chuck. He just runs our commits through a minifier and takes
credit for the lost lines. Means well, but he's kind of a jerk."

~~~
some_furry
This is the funniest comment I've read all week.

------
euske
"If we wish to count lines of code, we should not regard them as 'lines
produced' but as 'lines spent'."

\- Edsger Dijkstra

------
gjkood
One of the most interesting experiences I had very early on in my career was
reducing a 12,000 line C program to a roughly 1,000 line version (in C itself)
without losing any functionality.

No, it had nothing to do with my prowess as a young coder, but solely due to
the fact that my predecessor did not know what a function was nor how to use
parameters.

He had written unrolled versions of the same piece of code, with embedded SQL
with minor variations in WHERE CLAUSE values which could be easily
parameterized.

All I had to do after analyzing the code was move the code into a function and
loop through it with different parameters values.

Such is life.

~~~
jgord
... I remember deleting ~500 C++ files .. they were all classes that differed
by a constant, so I just passed in a parameter. Was not popular at all, they
liked lots of files.

~~~
72deluxe
That sounds stupid. Did they not know about inheritance or template classes or
anything??

------
Isamu
"One of my most productive days was throwing away 1000 lines of code."

    
    
       — Ken Thompson
    

[http://quotes.cat-v.org/programming/](http://quotes.cat-v.org/programming/)

------
jason_slack
I worked at a furniture company where in order to delete code you had to have
the head IT guy, the IT Director and an outside consultant sign off on it.
Yes, that is right! 2 people that didn't know how to code and an outside
consultant that we paid to look over "IT" moves before we made them.

However, I didn't need anyone to sign off on commenting out code and replacing
it with something else. :-)

~~~
wingerlang
Could you one week later delete "comments" without sign off?

~~~
jason_slack
I was one of 2 coders that worked there, but we did different things. We were
supposed to do "code reviews", monthly with each other. We did, but we usually
went to a Denny's (open 24 hours) and literally hung out there for 15 hours,
ate 3 times, etc and reviewed things. We cared about code quality and not
having to band-aid.

We had a saying: "Comment in a fix....". This is our way of saying to each
other that we needed to re-write code and to get around "red tape" we would
comment out and replace the code.

So if comments confused things, we removed them, with a comment that previous
comments "were confusing" or "no longer applied" :-)

------
jballanc
Brings to mind the classic:

> "Measuring software productivity by lines of code is like measuring progress
> on an airplane by how much it weighs." \- Bill Gates

------
dhd415
I finished up a 24-month project earlier this year on a codebase of ~1M lines
in which I dropped a net of almost 100k lines of code and reduced the main
Visual Studio solution from 325 projects down to 105 projects. Compile times
dropped from ~40 minutes to 6 minutes. If only all my projects could be that
fun.

~~~
pkaye
What kind of software takes 1M lines of code and 105 project? Is it one of
those Java enterprise software projects?

~~~
kkapelon
Banking software, hospital software, nuclear reactor software. Not all people
are writing self-contained web applications.

~~~
dhd415
Late reply, but yes, it's hospital software.

------
ja27
I worked somewhere where the support manager somehow managed to get approval
to bill his costs against each product group based on the lines of code in
their product. We spent part of a week refactoring and reformatting to cut it
by 70% before we gave him our numbers.

~~~
executesorder66
That's brilliant.

I would love to know how he reacted and what happened next.

~~~
wmt
I really hope he was happy that his nefarious plan worked where he managed to
make his job easier while improving the product.

------
pcl
I wish the output from _git diff_ used red for new lines and green for removed
lines...

~~~
dheera
Stock market indicators in China are reversed in colour from the western world
(up=red, down=green). Sometimes I wonder if Github really should be flipping
the colours on diffs for Chinese language users for the sake of consistency.

~~~
executesorder66
Do you know if that is because up is generally "bad" for them, or because red
means "good" and green means "bad"?

~~~
X-Istence
Red is considered good and prosperous. Hence the huge amount of red in Chinese
culture.

[https://en.m.wikipedia.org/wiki/Color_in_Chinese_culture#Red](https://en.m.wikipedia.org/wiki/Color_in_Chinese_culture#Red)

------
musesum
Once had a compiler QA gig. Was kinda lazy. So, I wrote a nonsense code
synthesizer. Just take the BNF and belch out code. Millions and millions of
lines of code. A fun variant was to create a class hierarchy that would run
100's of levels deep. I showed it to marketing. They asked: "Can you do that
for <competitors> compiler?" "Sure thang!". Soon, there was an ad showing how
our compiler could handle a lot more bloat than their compiler. Not my
proudest achievement.

------
lordnacho
Imagine being a civil engineer, and your boss says "how much concrete did you
use? I'll pay you to use more."

Or an electrical engineer: "How many resistors did you solder? I want them all
gone."

Or an aeronautical engineer: "What does the plane weigh? I was expecting a few
more tons."

Or a traffic engineer: "Why haven't you put more stop lights in?"

Or a mechanical engineer: "More gears!"

Always hard to get the bean counters to appreciate elegance.

------
starmole
This story is about how useless LOC is as a metric.

But negative LOC alone is just as useless a metric as positive LOC. It's easy
to come up with examples where deleting unused code is actually harmful:

\- Just delete all comments

\- Remove platform code you are not using now, but might in the future

\- Remove reference code because you are only using platform code

\- Remove test code that is just not called yet, but really should be

\- Remove code from a copied library that is now harder to keep current

\- etc..

~~~
onion2k
_\- Just delete all comments_

This is definitely harmful, agreed.

 _\- Remove platform code you are not using now, but might in the future_

Definitely. It's in the repo if you want to get it back, so there's no reason
why unused code should be in your source.

 _\- Remove reference code because you are only using platform code_

Yes. Remove everything you're not using. It's in the repo.

 _\- Remove test code that is just not called yet, but really should be_

And again. Remove it if it's not used. Or start using it. Nothing else is
acceptable.

 _\- Remove code from a copied library that is now harder to keep current_

You should probably be pinning versions of libraries otherwise you're going to
see things break in the future. Upgrading them is a feature.

Deleting comments aside, using negative LOC as a metric _does_ encourage
people to write better code.

------
joeheyming
Writing code is like playing jazz. It's not about the notes you are playing,
its all about the notes you are not playing

~~~
johnflan
or with similar sentiment.. "Music is the space between the notes" Debussy

------
intrasight
I deleted a couple thousand lines this week. It felt awesome. But you'd have
to admit that rewarding based upon deleted lines of code could be even more
dangerous than rewarding added lines of code.

~~~
hidroto
the moral here is not to be dogmatic.

------
kabdib
Porting a large piece of PC code to a console:

\- every deleted line meant we could have more content

\- the code ran faster

\- there were, axiomatically, fewer bugs (and we fixed a lot of bugs on the
way)

\- the code was more understandable

------
on_and_off
I work on a large Android app.

I have absolutely no idea of what my average LOC / week is and I would argue
that it is a silly metric.

Last week I deleted 30k LOC from the project (~10% of the code base) :

-we used to have both the old & new version of the UI in the codebase so we could switch between the twos in production. Now that the new version is complete, there is no need for that.

-There were many deprecated parts of the app and unused resources, I did a big cleanup of these and I have even more work in that area.

This has resulted in way cleaner code, easier to apprehend for newcomers. The
app is also lighter by 2 mo. Probably a very productive week overall.

------
mxhuang
Folklore.org has plenty of other great stories from the Mac team. I remember
reading some of these long before the Steve Jobs biography was released.

------
zeckalpha
I deleted 205 today. Felt good.

~~~
moonshinefe
It's funny that other programmers feel the same way. I've never discussed it
with other developers much, but I also derive a degree of satisfaction when
refactoring if I leave the code with fewer lines than it had originally.

I'd say I'd enjoy deleting 200 lines to adding 200. It's like sitting down in
a freshly cleaned room once you finally get your chores out of the way.

------
praveenster
I was surprised when YC asked something similar in their application:

"If you've already started working on it, how long have you been working and
how many lines of code (if applicable) have you written?"

My response ... "I personally believe that using "lines of code" is a crude
metric as it favors the sloppy programmer who doesn't write compact code and
discourages code reuse by utilizing libraries and frameworks."

~~~
sokoloff
I think you'd improve your response by answering:

1234 LOC, but I personally believe that....

IMO, the answer to a question like that begins with a number (if applicable)
and contains commentary only after the number. (I agree with your commentary,
just disagree with the value of not answering.)

------
zomgbbq
Similarly, the number of git-commits is also a poor judge of how much work was
done. When CI builds automatically build release notes based off of the git-
log since the last successful build, this can be deceiving.

------
ldong
I guess the management finally realized that deleting codes without breaking
existing functionalities is more difficult than adding :)

