Our first step in learning how to make games was to decide on which programming language to use. I am an experienced software developer, so I guided this decision.
This is Game Dev From Scratch, and we want to learn about programming. We don't want to use a game maker tool or a third-party engine, at least not in the beginning. We would like our game to run in the browser, so that people can discover and play it easily. We have lofty goals, so we want to use a high-performance language.
Typically browser games are written in JavaScript. I don't mind JavaScript, and I use it for front-end web development. JavaScript has dynamic typing, but I believe that static typing is advantageous for all but the smallest projects. This stackoverflow page explains the difference. JavaScript is not a slow language, but it's not the quickest either.
TypeScript is JavaScript with static typing bolted on. The transpiler is slow. It was developed by Microsoft. Call me a bigot, but I don't like Microsoft, and I don't like TypeScript!
I do much of my professional work in Python. I really like the light-weight syntax, without all those pesky braces and semicolons. Python is great for experiments, and has been adopted by the scientific and artificial intelligence communities. Although Python has some excellent and very fast libraries for mathematics, scientific computing, and AI, the Python language itself is much slower than JavaScript, and for that reason I don't think that it's ideal for game development.
-
Mainstream stand-alone games are often written in C++. C++ has been described as an octopus made by nailing extra legs onto a dog. When invited to reflect on whether he should have written git in C++, Linus Torvalds retorted that:
C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do nothing but keep the C++ programmers out, that in itself would be a huge reason to use C.
If C is a dog, it's a good old dog. The C programming language was created by Dennis Ritchie in the early 1970s. In my opinion, just about every programming language that has come after C is largely inferior to C, and none is wholly superior to it. It is not so easy to get started with C compared to Python for example, but I believe that I can make up for that with some helpful libraries and syntactic sugar.
Can we make a browser game written in C? According to Mozilla's Game development page, yes we can. We can compile C or C++ to WebAssembly using a tool called emscripten, and WebAssembly runs much faster than JavaScript in the browser.
As I understand, the popular SDL2 library has been ported to work with emscripten. Using SDL2 and OpenGL, we can build a browser version of our game, and native versions for the major platforms, all from the same code base. I have some prior experience with SDL2 and OpenGL.
In summary, we considered several different programming languages for learning about game development, and we decided to use C:
- JavaScript – good for web, dynamic typing, not the quickest.
- TypeScript – I don't like it.
- Python – beautiful syntax, but it's too slow.
- C++ – Linus doesn't like it.
- C is the worst programming language – except for all the others that have been tried.
Next post: My Simple Programs, by Thalia
Previous post: Creating Games, by Sean
Contents: Game Dev From Scratch
Top comments (0)