How much computer code has been written?

Sage McEnery
Modern Stack
Published in
8 min readJul 18, 2020

Ever wonder how many lines of computer code have been written? It must be millions of lines by now, probably billions, right? Could it be as high as trillions?

There are a few questions we must address in pursuit of our answer.

  • What constitutes a “Line of Code”?
  • How many developers are out there writing code?
  • How much code does a developer write?

The odds of addressing all of these questions with concrete answers are quite small. For this article, I will attempt to land on reasonable answers to each question. I have included links to; documentation, surveys, and studies to illustrate how I arrived at the numbers I used to perform these calculations.

What is a “Line of Code”?

Programming languages tend to be quite different from each other. According to this article, there are more than 200 active programming languages in use today. In reality, there are roughly 50 programming languages in everyday use today, with many of the rest being obscure, one-offs, and esoteric languages that aren’t in extensive use today.

Each programming language has a syntax, which is the set of rules that describe how to program in that particular language. Programming language syntax controls how the logic in the code is understood by the computer running the code. The syntax is akin to grammar, where a misplaced character can change the intent of the statement.

Some programming languages, like Python, allow a person to code in English, with indentation driving the syntax of the language. Other languages, such as Java & C#, use brackets to drive the syntax of the language. One wrong indent, or a misplaced bracket, and the code won’t work as expected.

So, do these Syntactic Elements count as “Lines of Code”? If a developer were to add a missing indent or move a bracket, would we count that as them having written a Line of Code? I would argue that the answer is “yes.” The programmer had to read and interpret the existing code to recognize that it was incorrect and take corrective action.

How many people are writing code?

When I think of this question, I imagine that in our data-driven society, this answer must exist out there somewhere. While doing research, I found answers which were all over the place ranging from 2 million to more than 20 million developers worldwide. For this article, I am looking for a reasonable floor upon which to calculate a result.

One place we can look to find our answer is the number of StackOverflow users. StackOverflow is a software development question and answer site. This site has been around for a long time, and for most software developers, it is the go-to source for answers to their questions. Users, on StackOverflow, are people who have either asked a question or provided a response to a question.

At the time of writing, the StackOverflow Users page shows us 36 users per page. The page currently has 343,497 pages, which tells us there are about 12,365,892 users on StackOverflow. Let us assume half of those users are real, current, and valid people. That leaves us with over 6 million active software developers. Globally speaking, this number makes sense and seems realistic.

We can infer that this number might be reasonable by merely cross-referencing the Bureau of Labor statistics here in America. According to their 2018 figures, there are about 1.365 million software developers employed in America. However, as with any government bureaucracy, we need to dig a little bit deeper to get a more accurate picture of the data we seek.

If we explore the Information Technology parent category, we can find at least two child categories that warrant inclusion into our calculation; Web Developers and Computer Programmers. These categories provide us with an additional 160K and 250K workers, respectively. In reality, practically every sub-discipline in the Information Technology category could probably be included, but will not be because the point of this calculation is to define a floor.

Back to the question of how many people are out there writing code. We have arrived at the educated guess that there are about 6 million people in the world writing code right now. The real number is probably much higher than this, but this number works for our calculation.

How much code does one developer write a day?

The last question to answer is; how much code are these people writing? That question is by far the most difficult one to answer concretely. As such, we will need to settle on a number or range that feels reasonable.

The dirty truth is that many developers are not actually writing code all day. Rather, they are copy\pasting code off of the Internet and then adjusting it to suit their needs. Do we count this reality into our calculation? As with the Syntactic Elements argument before, I would say the answer is “Yes.” The programmer had to read, interpret, and adjust the copied code to work the way they needed.

The criteria I chose to use when trying to answer this question was to find examples of an everyday software development task coded in multiple programming languages. The chore I settled on was sorting a list or collection. I stumbled onto this article, and this repository, which both look like decent sources to use because; a) the code all dealt with sorting, and b) they have sorting code written in a fair number of programming languages.

By scanning all of these code samples, we can see that, on average, it takes about 30 lines of code to sort a list. Sorting a list is just one task that an engineer might work on in a given day. While this in no way shape or form is an absolute answer, it does provide us with a means of taking an educated guess.

In reality, arriving at our answer is a little more nuanced than just counting the number of lines it takes to sort a list. Most developers aren’t just sorting lists all day; they are actively working on Projects. Software projects vary widely in scope and size. Just take a look at the following infographic to get a feel for how big some software projects are.

Hitting a project with millions of lines of code isn’t very difficult, especially nowadays. When working in a codebase this large, one will easily write dozens, if not hundreds of lines of code each day.

Another trick to performing this calculation is that there is strong evidence that the longer a person has been writing code, the less code they write. In fact, the longer a person has been programming, the more code they remove from a given program. Does removing code from a program count as “Lines Written”?

In the end, and for this article, we need to arrive at some numbers that look and feel right. The table below shows the results of our calculations, which, again, are based on educated guesses.

As we can see, a new developer will probably write about 100 lines of code a day, or about 25,000 lines of code in a given working year. In contrast, a more senior engineer is probably writing about 20 lines of code a day, or about 5,000 lines of code in a given working year.

Having worked in IT for more than 20 years, most of the time, as a software engineer, these numbers don’t feel all that wrong to me. At this stage of my career, I am probably writing about 100 lines of code in any given week. Since I oversee a large team of software engineers with various backgrounds and levels of experience, I can attest that those engineers are indeed writing 2–5X more code than I am.

Now that we have these numbers, we need to break down our previous 6,000,000 global developers into “buckets,” which represent their years in this craft. Thankfully, we have a resource that will allow us to do just that: the annual Stack Overflow Developer Survey.

In particular, the Years Since Learning to Code section will provide us with the data we need to break down our six million developers.

Since we are grouping into 5-year buckets, our breakdown will be as follows;

Our Calculation

Having landed on some educated guesses, we can pop open Excel and start plugging in our numbers.

The calculation here is as follows;

( [Avg. Lines Per Day] * [250 Working Days Per Year] ) * [Number of Developers]

This table shows us that as a community, software engineers are producing about 93 Billion Lines of Code a year. Maybe it is just me, but that is an outstanding number. About 7 billion people live on this planet right now, which means our community is producing about 13 Lines of Code per person each year.

So, how much code HAS been written?

Software Engineering has existed for about 60 years now. For the majority of that time, the barrier to entry was kind of high, the nature of code itself was quite different, and the industry itself was nowhere near as mainstream as it is today. Software Engineering really entered the mainstream and went into overdrive about 20–25 years ago, alongside the public adoption of the Internet. Again, we are looking for the floor, so we will use 20 years to perform our calculation.

If we multiply our 93 billion lines of code by 20, we arrive at the following product.

2,781,000,000,000

Roughly 2.8 Trillion Lines of Code have been written in the past 20 years.

That is more than 5X the estimated number of stars in the Milky Way!

Closing Thoughts

The nature of this industry has changed dramatically over the course of the last 60 years. The barrier to entry has continuously been lowered, and the number of engineers today eclipses the number of engineers 30 or 40 years ago. In all reality, there is probably 3–4X the number of engineers in the world than I accounted for in these calculations.

The speed at which code today is assembled is also beyond these simple calculations. Modern Programming Languages are more approachable to new-comers and easier to learn and adopt. Modern Integrated Development Environments make it easier than ever to write software, and sites such as StackOverflow are instrumental in teaching people how to write code. As such, the amount of code a developer can write each day is probably twice what I estimated.

The real number of Lines of Code is probably beyond calculation. In the end, I don’t know if it truly matters what the actual number is. The simple fact is that this industry churns out an outstanding volume of work each year. Work that touches and impacts more than half the people living on this planet.

Let’s keep it up!

--

--