Ask HN: How much code do you write a day?
I'm curious about how much code most people write in a normal working day as a programmer.
I am looking into changing careers to become a programmer and want to know how much code one would be expected to write in a day.
Example:
Profession/position: --
Code: - x amount lines of code / x amount of issues, etc.. closed
41 comments
[ 3.2 ms ] story [ 279 ms ] threadThe same is true of number of issues closed. Some issues are short and quick, and some issues take a whole day. Sometimes an issue will seem small and turn out to be large. Handling these things is part of good management.
I personally measure people more on how many bugs they don't produce. A single bug can cause losses of revenue that are equivalent to weeks of a developer's time. Bug-free code is so much more cost-effective than fast code.
Not directly about development, but this should be somewhat of a rule of thumb in general: https://www.slideshare.net/dmc500hats/best-strategy-is-speed...
Time is important. More important than you think.
You can have a bugfree code, but release it in 6 months. Or you can have a code that creates outages once per month, but release it in 3 months (figure of speech, 6 months is optimistic for some projects).
By trying to optimize for 0 bugs, you are losing on the 3 month of business opportunity of high revenue. At FANG scale, that's a lot of money.
Disclaimer: G employee, but this is my own opinion etc.
That said, no one (in their right mind) intentionally releases buggy code. They may release incomplete or under-tested code, of course. But that's not what I'm talking about.
I'm saying that when someone feels like they're "done" (in a reasonable amount of time), some people will end up with more bugs than others. If the trade-off is 3 more hours of work for 1 fewer bug, that's an incredible economy.
And, of course, no metric is perfect or comprehensive. But "bugs per hour" is much better than LoC per hour.
One reason is that high quality code is concise leading to less lines. If devs are measured by how many lines they write, that leads to writing verbose / long / bad code. I really enjoy pushing up a negative lines pull request.
There really aren't any good objective metrics. I've seen and heard of some companies measuring programmers by scrum points, but then it leads to either inflating the point numbers, or shipping large amounts of low quality code to look better on paper. Really what it does is shift the burden of fixing your code and making it production grade onto the other members of the team.
It's much better to have a flow that allows for continuous delivery of working software with monitoring, etc. rather than focusing on counts of things that don't matter. Do customers care about how many story points happened last sprint?
If management is focusing more on metrics than working software - then they will get people to focus on that as well over working software.
There's a correlation, but it's more subtle than that. Often simpler but repetitive code is less technical debt than the less code but more complicated version.
So far today: 13 lines of code. 5 issues closed.
coding: 20-30%
designing(thnking) issues:
unit testing: less than I should
documentation: 20%
on HN: more than I should
on the internet researching an issue/feature: 10%
in useless meetings: 10 hours a week
in productive meetings: ?
talking/chatting/emailing about an issue/feature: 20-30%
By then end, perhaps 1500 lines of code, but how long did I spend writing it? Four days? Three? One? (the fourth day's work ultimately didn't add many lines of code though every file was touched and had to be checked in again).
So a lot of my energy has shifted from wring clean(ish) and maintainable(ish) code, to writing coherent articles for content marketing.
But when I was building it out? some days I would sling quite a lot. Other days were spent just tinkering with CSS to get the layout or experience down right, or doing research on the best way to do something.
Some people also, write really fast code. and other people are more methodical. So, take any comparisons you make in that regard with some salt; what's possible for others might not be for you, and visa versa.
But generally, the expectations are based on todos like adding a feature or interface, which is known to represent some kind of easy/medium/hard difficulty - which may also be contextual to the developer when domain knowledge comes into play. So the expectations vary from one dev to another based on experience, familiarity, and known unknowns.
* I'm thinking of writing a book, how many words should I use?
The answer is very varied. I read a book to my son at the weekend. 20 words, at the most. The book I'm currently reading is in the region of 1500 pages. Many words.
Code is like that. Today I might have written negative 100 lines, and been productive. Tomorrow I might write a template-generation system and have a net positive of a few thousand. It all depends, so much.
Hence, taking time to write more readable code may lead to writing code sooner and/or faster in the future.
[0] https://github.com/arzzen/git-quick-stats
Now that may be different if you are starting a greenfield project or banging out a prototype.
There are a lot of repetitive things we do, which can drain your brain, and like any other job you are also likely doing the work for a company/someone else which means they define what it is you are building/fixing. So make sure you are motivated to be a professional about programming. That means being able to grind through the "this is just like that other thing, but slightly different enough that I can't re-use that other thing", etc.
Although I do completely agree that about 90% of my work is actually thinking about how to implement a problem as opposed to actually implementing it.
If you're rewriting tens of functions that are almost identical, you should probably consider finding a different way of organising your code (even if there are minor differences between the functions).
Number of issues closed: Depends on what I'm doing. Short little maintenance things can take less time, and you can clear a bunch in a day. Some individual features will take weeks or months to code, depending on how deeply new changes need to infiltrate into old code, the size of the change, how much work you depend on other teams to do to provide ancillary features to support your work, etc.
My team's more of a "fulfill the requirements; do it right" than a "move fast and break things", because our products are backup applications. I suspect that this changes the tempo of the work, compared to how other teams might function.
git diff --author="<me>" initial_commmit..@ --shortstat
969 files changed, 29501 insertions(+)
Total LOC for the project is 17514.
I don't know if that helps you, but it was fun to look up.
I think being quick and responsive to consistently deliver what customers need is more important... because without profitability and useful utility, code is mostly academic.
(Moderation in all things, including moderation.)