12 ms·
-2000 Lines of Code
- zeckalpha 11y agoI deleted 205 today. Felt good.
- epalmer 11y agoI deleted about that many today as well. Cleaner neater more readable code is better.
- moonshinefe 11y agoIt'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.
- bargl 11y agoI 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.
- cpeterso 11y ago520,000 lines of code per year! :)
- Zelphyr 11y agoCouple that with pay and just tell them to pay you $1 per line of code written.
- boxidea 11y ago# Need to increment this count so it matches up with the length of the list we just created. count = 1 count = count + 1 count = count + 1 count = count + 1 count = count + 1 count = count + 1
- bargl 11y agoHa, I guess the developers they are hiring used to be sci-fi writers! But don't most writers say the hardest part is cutting words out of their book and cleaning up language? P.S. I don't remember exactly what she put down as my "line-count" I was pretty annoyed at that point, it might have been a much more reasonable 5000. :-)
- doorhammer 11y agoThis reminds me of a quote I enjoy: "If I had more time, I would have written a shorter letter." Some interesting attributions of that and similar quotes: http://quoteinvestigator.com/2012/04/28/shorter-letter/ http://quoteinvestigator.com/2012/04/28/shorter-letter/
- avmich 11y agoA good case to use code generators, I guess...
- mgkimsal 11y ago> 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.
- AnimalMuppet 11y ago"I want to pay you as little as possible and still get you to come to work here." That's the truth.
- onion2k 11y agoActually the truth is more like "I want to pay you as little as possible for you to work here and be productive." People who're worried about money are really bad at their job. They spend all their time thinking about something else. If someone is willing to accept a job on a salary that isn't really enough to live on (say, because they don't know how expensive the area is) then you should pay them more than what they believe their minimum is. Unfortunately hiring managers quite often fail to understand this.
- wdewind 11y agoDon'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 11y agoNo... 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.
- nickpsecurity 11y agoWhat is the current average in a language like C# or Java for a skilled developer? Average that goes into production rather than what's likely thrown away.
- marcosdumay 11y agoIn a week long project (some supporting tool, or something similar) it's easy to write 10k lines a week. In a 6 months project, 10-100 lines are more likely, and in an "eternal" software that is already mostly written, 0 is a perfectly fine number.
- nickpsecurity 11y agoAppreciate the reply.
- voltagex_ 11y agoI dread the day someone starts tracking LOC vs productivity in TFS. I might be switching between C#, SQL, CSS, HTML and Javascript on a busy day. A context switch == a productivity hit.
- cpitman 11y agoThat was actually one of my favorite moments! Someone pulled up the TFS chart of lines of code added/removed per developer. First, I removed way more lines then I added. But second, the number of lines I removed was (completely accidentally) the same as the number of lines my team lead added. When he saw that, he just kind of looked over at me to make sure I wasn't following him commit by commit to rewrite his code!
- on_and_off 11y agoI have senior in my title so I guess I count as skilled, I work on an Android app (so Java). I have absolutely no idea of what my average LOC / week looks like and could not care less. This is a really dumb metric. Between Annotation processors & code generation plugins, it already means nothing. If you factor in DRY, it is just insane. Am I supposed to willingly write horrible and unproductive code just to increase my LOC / time ?
- duncan_bayne 11y ago> I was offered the job but decided not to take it because that plus the technical interview made me wary. Sounds like you made a great choice :)
- deleted 11y ago[deleted]
- incepted 11y agoIt's a well-known tactics to lowball you. The standard answer is "I'm not allowed to disclose it" and if they push, I just give them what I want them to give me minus 5% regardless of what the actual number is. If they end up calling my current employer and that this employer gives them the number (which is extremely unlikely), I just tell them "What I'm making right now is irrelevant, I gave you the salary I think I'm worth right now. If you don't agree, I'll just walk, no big deal".
- kriro 11y agoI'd be very tempted to ask the HR person for their salary and/or ask for the CTO/CEO's salary and/or some confidential revenue number or something like that before ending the interview. It's fairly shady negotiating to anchor the process one sided. If they want your salary they should tell you what the highest paid developer makes as well.
- on_and_off 11y agoThese sound like two very big red flags. You have probably dodged a bullet here.
- jamaicahest 11y ago> 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 So you base your salary offer on my current salary, instead of what I would be worth to you guys? Good luck. We're going to be here a while, since I'm not going to disclose my salary.
- gricardo99 11y ago4 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.
- nickpsecurity 11y agoShow management a picture of the code. Show them a visualization of all of it with its myriad connections. Tell them you just got rid of 4,000 lines of that crap. Show a visualization that's smaller and connected neatly. Promise to continue attempting this incrementally and safely in between new features. New features that are coded similarly neat. Not sure if it will work but I keep wanting to see someone try it. :)
- girvo 11y agoI've pretty much exactly that, and it did work. Though it was at a company that had a headcount of 15, so in a larger org it might not go down so well.
- greggyb 11y agoWe've done this as a recap of successes with a few clients, now. It helps that the old stuff was stupid slow and ours has been both understandable and faster.
- agumonkey 11y agoMy favorite OS updates are the one with negative net install. Keep trimming.
- nostrademons 11y agoThere 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.
- pcl 11y agoI wish the output from git diff used red for new lines and green for removed lines...
- Hello71 11y agogit -c color.diff.old=green -c color.diff.new=red
- dheera 11y agoStock 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.
- fredkbloggs 11y agoTo be fair to the Chinese, whether a price going up or down is alarming or encouraging depends on whether one wishes to buy or to sell.
- executesorder66 11y agoDo you know if that is because up is generally "bad" for them, or because red means "good" and green means "bad"?
- X-Istence 11y agoRed 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
- Isamu 11y ago"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/
- intrasight 11y agoI 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 11y agothe moral here is not to be dogmatic.
- mxhuang 11y agoFolklore.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.
- jason_slack 11y agoI 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 11y agoCould you one week later delete "comments" without sign off?
- jason_slack 11y agoI 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" :-)
- dhd415 11y agoI 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 11y agoWhat kind of software takes 1M lines of code and 105 project? Is it one of those Java enterprise software projects?
- grandinj 11y agoEven worse, probably one of those C++ enterprise software projects.
- kkapelon 11y agoBanking software, hospital software, nuclear reactor software. Not all people are writing self-contained web applications.
- dhd415 11y agoLate reply, but yes, it's hospital software.
- rainrainrain 11y agovideo games codebases are sometimes this large
- Illotus 11y agoWell considering Visual Studio was mentioned enterprise C#/C++ project would be a safe bet.
- pjc50 11y agoAn EPOS application: PS D:\project\> (dir -include *.cs,*.cpp,*.h,*.idl,*.asmx -recurse | select-string .).Count 1626667 At a previous employer, a piece of chip design software got to 1.25m lines of C++ over the course of a decade.
- gjkood 11y agoOne 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 11y ago... 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 11y agoThat sounds stupid. Did they not know about inheritance or template classes or anything??
- jacquesm 11y agoI've had that exact same scenario about 4 years ago with a very large website (you've probably used them) which was put together in a hurry. The site was written in Java and each and every access to the database contained the exact same pre-amble, a bunch of database interaction with the aforementioned change to the where clause and then a cleanup section. Typically 50 to 100 lines. There must have been 100's of these copies in the code. In the end I moved the db open and close stuff to program startup and shutdown and replaced all the rest of it with a single function with a couple of parameters. The code suddenly became maintainable again.
- zomgbbq 11y agoSimilarly, 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.
- euske 11y ago"If we wish to count lines of code, we should not regard them as 'lines produced' but as 'lines spent'." - Edsger Dijkstra
- ja27 11y agoI 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.
- egroat 11y agoThat is genious. Absolute genious. There are likely to be less problems on a smaller codebase and when there are its much easier to recommend a rewrite of 1k than 10k
- executesorder66 11y agoThat's brilliant. I would love to know how he reacted and what happened next.
- wmt 11y agoI really hope he was happy that his nefarious plan worked where he managed to make his job easier while improving the product.
- kabdib 11y agoPorting 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
- starmole 11y agoThis 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..
- wldcordeiro 11y agoNegative LOC while retaining those things would be optimal, if you can manage to reduce the size of the overall codebase while fixing issues and/or adding features it's the best possible outcome.
- crististm 11y agoLOC is not useless since it's just a metric. It's interpretation is what matters.
- onion2k 11y ago- 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.
- praveenster 11y agoI 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 11y agoI 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.)
- jballanc 11y agoBrings 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
- joeheyming 11y agoWriting code is like playing jazz. It's not about the notes you are playing, its all about the notes you are not playing
- johnflan 11y agoor with similar sentiment.. "Music is the space between the notes" Debussy
- hibikir 11y agoIt'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.
- on_and_off 11y agoI 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.
- musesum 11y agoOnce 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.
- ldong 11y agoI guess the management finally realized that deleting codes without breaking existing functionalities is more difficult than adding :)
- lordnacho 11y agoImagine 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.