What Programming Language Should You Learn for Game Development?

By in
826

After doing software development for more than 30 years, the one question I hear most frequently is “What programming language is best for X, Y, or Z?” This is especially true in indie game development due to the explosion of indiedevs and the ease with which anyone can build games.

So which language should you choose? Turns out, it matters far less than you think. Let me explain why.

Harry Potter

Think about Harry Potter for a moment. What makes Harry Potter great? In my opinion, it is the humor, the dramaturgy, the characters, the mystery, and the joy of expectation that builds up as the story go on. You may have other things that are important or perhaps you don’t think the books are great at all.

None of this, however, is related to in what language the books were originally written. I know it’s English but millions and millions of people around the world has never read Harry Potter in its original language and yet, you can sit down with any reader of the books, assuming you know a common language, and discuss the same story.

Why is this? The language used is simply a means to convey something else. All those elements that make Harry Potter great, whatever you may think they are, are simply conveyed with a language. The books are not the language used to write them.

I’ll tell you another secret. I’ve never read any of the books. I’ve only seen the movies and yet I can keep conversations with my wife about the story and the characters. She’s read the books only in our native language Norwegian.

The language matters far less than what the language conveys. You need the language but it’s not really what makes the books, or most books, good or bad.

The Right Tool

In my first article on “Four #GameDev Lessons from 30+ Years of Software Development”, I paraphrased a quote, possibly from Edgar Dijkstra, that programming language is to programming like telescopes are to astronomy. I further went on to explain why language is irrelevant, and although I still stand by those statements, it doesn’t really give you an answer as to what language you should learn.

The problem with answering this question is that to understand the answer, you must understand programming, and to understand programming, you must understand the answer.

For example, language X may be strong in algorithmic solving whereas language Y excels at handling recursive data structures. Language Z on the other hand supports platform ABC and language W does feature DEF really well.

Which of these features are important? It is really difficult to know until you actually know what these features are and to do that you need to already have decided which features are important.

Chickens and eggs. Impossible to solve, right?

However, what if we look at the problem from a different angle? Rather than trying to determine whether we get the chicken or egg first by studying chickens and eggs, why not look at a broader perspective?

If we learn more about biology, we find ourselves much more able to figure out mysteries like these. It took modern science to solve the question from a biological point of view and scientists came to this conclusion not by studying chickens but by studying biology.

In programming terms, this results in looking at programming concepts. Rather than learning a language, we focus on learning the ideas that we need to express through programming.

Programming Without Language

See if you can find a physical phone directory in a book form. It used to be that you could talk about the phone book and everyone knew what that meant, but those barely exist anymore. If you cannot find one, you may just have to imagine the following problem, which is this:

How many names must you see in that book to find any given name? Imagine that you can flip to a page and look solely at a specific name on that page. How many pages must you flip until you find the name you want?

As a programmer, I can tell you that the answer is below 33 off the top of my head, but before I reveal how, try it yourself. You’ll find the answer later in the article.

Here’s another one. Get a group of friends together in a room and ask them to move to any spot in the room. Then, move them one by one so that they stand in a line in alphabetical order. How many times must your friends move in order to get everyone organized as such? Building off the previous problem, how many times must you compare someone’s name to another friend to find the correct order?

Next, pick up a city map and a pencil and pick two random points that are connected by roads. How can you move from one place to the other if you were driving a car that couldn’t turn left? Count the number of intersections you need to cross or the turns you need to make and give the map to your friends to see if they can find a route with fewer intersections or turns.

Problems like these are what software developers face every day. You don’t need programming tools or even electricity to solve them. You need a phone book, some friends, and a paper map.

What you are doing now is logical problem solving. That is essentially what programming is all about. You can solve most, if not all of these problems in any language so as you can see, the actual problems you will face are independent of language.

In fact, I’ve just used English to express these problems and let me use English to solve at least the first of these problems, the one with the phone book. The answer is less than 33 because of an algorithm called binary searching. Binary searching halves the possible solutions for every name you see, and if you do that 33 times, you’ve exhausted all the people on the planet (more than 8.8 billion people).

The way binary search works is that you take a list of ordered items, just like a phone book. You then pick the middle item of that list and check whether the item you want is before (earlier in the alphabet) or after (later in the alphabet). Throw away or ignore the part of the list that does not contain the item you want and then repeat the process. Do this 33 times and you are guaranteed to have found your name.

Cool, eh? Without teaching you the first thing about programming, I’ve presented to you and solved a well-known programming problem, just using the English language.

So… Which Language?

It doesn’t matter. Really. Pick any but pick one that has ample learning resources. Learn its syntax and then use the language solely to learn programming and the concepts of programming. After you’ve done that, you’ll find that learning a language is irrelevant.

Think of it as writing a mystery novel. It isn’t because you write it in German that people will love or hate it but because of your command of the thrill. Stephen King is scary in any language.

As someone who has done software development for many years, I’ve built production software in a myriad of languages. I’ve even built several languages myself.

When people contact me now to ask whether I can help them with some programming task, I can usually forego the question of language or platform because my command of programming means I generally spend less time learning how to express the solutions in a new language than I do understanding how to solve the problem.

Unity? Fine, I’ve done .NET development more or less continuously since 2001. Unreal? Awesome, I wore out my first pair of baby shoes in object orientation using C++. Python? JavaScript? Perl? Java? I hadn’t written a line of Java for almost 20 years when I picked it up to build libGDX games a couple of years ago and I had my first game published two weeks later.

Once you understand how computers work, how programming languages allow you to communicate your ideas to that computer, and how to ignore or work around the peculiarities of individual languages, the language becomes just another line in the game design document, if it is mentioned at all.

So go ahead! Find a phone book, a few friends, and a map and start programming in whatever language you like. It’s a great hobby or job, whichever you prefer!

54321
(0 votes. Average 0 of 5)
Leave a reply

Your email address will not be published. Required fields are marked *