I was recently asked a bizarre question in an interview – “how many lines of code do you write every day?”
I’ve been thinking about that question for a week and realized that it makes sense since she was a C person before migrating to other work a few years ago, not a contemporary java person.
To explain, I can fold my career into three major stages.
Ancient – computers were resource-limited (memory < 1 MB) and no third-party libraries to speak of. Our “internet” was journals (esp. “Programming Pearls”), magazines (e.g., “Dr. Dobbs”) and books. You wrote everything you used and you needed to use efficient algorithms and data structures if you didn’t want it to crawl. SLOC could be considered a fair measure of productivity, subject to various well-known limitations. (E.g., you needed to be comparing comparable work using the same definition of SLOC, etc.)
(Sidenote: on several occasions I improved performance of existing code by several orders of magnitude – literally hours to minutes or minutes to seconds – by simply recognizing that the code was now running on computers with more memory and I could cache values instead of constantly rereading files or the database, recomputing values, etc.)
Mature C – computers had decent resources (memory < 100 MB) and a wide variety of quality third-party libraries. We could get those libraries via the internet but it was years before Google or blogs and we still depended on journals, magazines and books. SLOC was starting to lose its value since you could have one person who still wrote everything himself (including bugs) and another person who took less time and wrote fewer SLOC but had better results since he used a third-party library. Knowing good third-party libraries was important but not critical and you still spent most of your time writing code (excluding meetings, etc.).
Mature Java – computers have ample resources (memory > 4 GB, multicore processors) and a number of quality deep libraries. The standard API, Apache, Spring Framework, etc. We can get libraries by adding a few lines of text to a configuration file and we can learn about them by reading blogs and Google searches. We’re often more productive with a day of research than a week of coding.
There is no “right answer” here since it depends on the ecosystem. Some languages have deeper third-party libraries than others. Some shops require highly specialized needs that they must write themselves. But it really struck me just how different my world has become over the last few years when she asked that question and my first thought was how much time I spent in research vs. coding and how that affects the raw SLOC numbers.