This question is often asked by one programmer to another, in a way to gauge how good or even how long someone has been writing code for. The usual answer is a rough estimate, as no one in their right mind would count every single line of code they've written. Does the number of lines of code matter anyway? It does, but not for the sake of comparing one's programming skills to another.

Today's computer systems come packed with gigabytes of RAM and multiple core processors capable of processing a lot of data in a short amount of time. Efficient code does not matter as much as it used to, so programmers may end up coding more lines than needed to take care of a certain task. It's not necessarily bad, assuming that the software meets the guidelines that have been set, but back before the advent of today's machines, care had to be taken in order to get the desired result.

In the early days of programming, there was a limited amount of processing power and memory available for use. Inefficient code severely affects performance on machines such as these, since the code needs to be loaded into memory and executed, leaving that much less RAM available as well as taking up CPU cycles to process the lines of code written. Programmers had to keep lines of code down out of necessity to keep the software they were writing performing at an acceptable pace.

As technology increased, the need for efficient code dropped because it simply did not have an impact as it used to. You could get away with something like this in COBOL (which is still used today):

It would be a lot easier and more efficient to do this:
No matter what language, there are programmers who do things this way. While the result will be the same, there are two extra lines just for the computation. In COBOL, those extra two fields would need defined, which is a couple more lines of code. The next time someone asks you how many lines of code you have written, ask them if it matters.

Log in or register to write something here or to contact authors.