Donald Knuth, Ken Thompson, Dennis Ritchie, Grace Hopper: The United States has produced some of the greatest software engineers who have ever lived.

But outside the United States computer technology and education have become far more accessible over the last 20 years or so, and that means that in China and many other less developed countries there are now plenty of young minds that have been trained to become skilled programmers.

So which countries produce the best coders is an interesting question to ask. Perhaps more importantly why do some countries lead the way?

China and Russia on top

One source of data about programmers' skills is HackerRank, a company that poses programming challenges to a community of more than a million coders and also offers recruitment services to businesses. Using information about how successful coders from different countries are at solving problems across a wide range of domains (such as "algorithms" or "data structures" or specific languages such as C++ or Java), HackerRank's data suggests that, overall, the best developers come from China, followed closely by Russia. Alarmingly, and perhaps unexpectedly, the United States comes in at 28th place.

China is a vast country with a huge population, so perhaps it should come as no surprise that many people with a great aptitude for programming happen to be born there. The same is also true for Russia.

But that alone can't explain why Chinese and Russian coders rank so highly. And it's unlikely that the results are skewed towards these countries just because coders from them happen to like to participate in HackerRank challenges. That's because Chinese and Russian coders often outperform other countries in other coding events as well, including Google Code Jam, an international programming competition hosted and administered by Google.

While Chinese and Russian coders perform well across many of the fifteen domains for which HackerRank poses challenges, it’s also worth noting that coders from specific countries excel in specific domains: Japanese coders are the best for artificial intelligence and Hong Kong produces the best Python programmers, while the best Ruby programmers are in Finland and Denmark is tops for SQL programmers. There are other surprises too. The best database programmers are from Switzerland, Ukraine produces the best security coders, Sri Lanka is the strongest for distributed systems, and France is tops for C++.

Getting an early start

Let's consider first why China and Russia produce such a wide range of skilled programmers. "One hypothesis is the way education in those countries is focused," says Heraldo Memelli, HackerRank's lead technical content manager. "At an early age people learn mathematics, sciences and programming. Great programmers can come from anywhere, and the fact that they learn mathematics earlier shows up later in the results of these challenges."

Shimi Zhang, a highly ranked Chinese competitive programmer, backs this hypothesis. "Math and computer science are very popular in China, and parents and students pay much attention to those topics along with other technology and science topics," he says. And, he points out, that level of competition for education means that Chinese students start studying from a very early age, and when they learn to code they tend to study intensively.

"Chinese students are very hard-working right from primary school, because there are not enough high quality education resources for all smart students," says Zhang. "They have to work really hard to get into a good middle school, high school and good universities. Many students maintain this habit when it comes to learning how to program."

There are differences, too, in the way that college students learn programming in the United States and in China, but Zhang thinks the American system has the edge. "[M]ost fundamental courses in universities in China are taught by lecturers, not professors, so the quality of these courses are not as high as in U.S. universities. And students in the U.S. can join research groups in their second or third year, but in China this only happens in top Universities."

Despite the United States having what Zhang considers to be a better university system, it seems that this is not enough to outweigh the benefits of starting early and competing with their peers.

More hackathons needed

What lessons can American universities looking to improve programming education learn from China’s example? HackerRank's Memelli thinks it may be a good idea to add more competitive problem solving to the curriculum, or even outside it. "One thing that comes to mind is that U.S. educators could supplement what is taught in schools by organizing hands-on coding challenges, online hackathons and so on," he says.

By contrast, Zhang says that American students are already good at practical projects that involve solving real problems to build products. Chinese students, by contrast, have less opportunity to do test their skills on real-world problems so they spend more time in academia, focusing on fundamentals. "This actually helps [Chinese students] build a solid fundamental skillset before they go into industry," he says. "It is true that China is producing top programmers, but U.S. students are still really good at solving real challenges and changing our world."

Centers of excellence

It may be that China and Russia excel in a wide range of programming domains — and coding competitions as well — because of the way that their educational systems work. But what accounts for a particular country's strength in one specific domain? Why, for example, does Finland excel at Ruby?

The reason may be because of some "quirk" in that country, believes Memelli. "It's difficult to know for sure, but some countries' high rankings in a specific domain may come down to the school curriculum in that country, or the fact that a particular company or industry is important in that country, or that for some reason a particular programming language is popular there," says Memelli.

To Memelli’s last point,particular skills are likely to proliferate where they are needed. So if one country needs a large number of artificial intelligence specialists to support a particular industry it's likely that there will be plenty of people there who learn, and practice, those skills.

That may sound obvious, but it does have an important implication when it comes to recruiting developers with the talents you need, or deciding where to base a particular project's operations. The bottom line is this: particular coding skills are not evenly distributed around the world. Until they are it makes sense to know where to look to find the best people.