Paddlist (C++)

in Programming, Thoughts

Learning C++

Since I was in middle school, I wanted to make games. Discovering gamedev.net was a revelation that made me realize video games did not magically spawn out of the ether. They were crafted by real artists and programmers.

I devoured several articles on gamedev.net that gave advice to game development newbies. My interest gravitated to the dark arts of programming. Then I made the same mistake common to most aspiring game developers: I decided to learn C++.

C++ is a terrible language for newcomers1)Granted, my journey started in the mid-2000s when there were far fewer options available. Nowadays, Python, C#, and other languages have far more game development resources than they did a decade ago.. However when you first begin, you have no idea if the alternatives are better or worse; your limited experience is all that you know. But now that I have several languages under my belt, I can see what makes C++ difficult for novices:

1. Memory management Pointers are already a difficult concept to grasp, but actually using them and managing heap memory is where the true struggle begins. Garbage collectors make learning to program so much easier.

2. Weak IDE support I first was exposed to C++ using the Dev-C++ IDE. At the time, that worked fine but in the past decade, it has naturally been surpassed by other IDEs and fallen by the wayside. However (at least on MacOS), there is still no great C++ IDE. Xcode is the most common option, but its C++ support is lacking, and I find myself wishing I could use Android Studio whenever I code in C++.

3. Verbosity As someone who frequently writes games in Java, this feels a little hypocritical to bring up, but C++ is an extremely verbose language. Whereas Java feels long-winded, C++ feels repetitive. Functions have prototypes and declarations. *.cpp files have corresponding *.h files. I understand the historical reasons for these necessities as object-oriented programming was basically just slapped onto C, but that doesn’t mean I have to enjoy writing C++ as much as Ruby.

4. Terrible libraries The appeal of C++ to newcomers is it is what the pros use. If a brand new programming student fights all the way through understanding C++ instead of learning Python, then he is also the type of person to want to go straight to learning DirectX or OpenGL. Newcomer-friendlier alternatives like SFML or SDL would be considered too “simple” or “basic”. And if you want to learn DirectX or OpenGL as your first graphics library, then God help you. Here’s an unbelievably long tutorial to render a simple polygon.

The cruelest trick is that C++ is unnecessary for newbies. Though it may be the lingua franca of the game industry, you will not be making a AAA release as your first, second, or fiftieth programming project. All the performance benefits C++ provides are virtually irrelevant to new programmers.

Naturally, I gave up on learning C++ around the time I was introduced to pointers. Years later, I would learn other programming languages and how to make games. I wish I had tried learning a different language first.

But I am still stubborn and want to use C++. So over the past two weeks, I’ve worked my way through a C++ book and made yet another Pong clone using SFML.

The funny thing is I still hated programming in C++. It is not a language I am going to stick with as I would much prefer to actually get stuff done in Java and LibGDX.

Yet still I am happy that I wrote something in C++. Maybe I was a fool for trying to use a language I dislike. But middle school Mat would be proud.

Footnotes   [ + ]

1. Granted, my journey started in the mid-2000s when there were far fewer options available. Nowadays, Python, C#, and other languages have far more game development resources than they did a decade ago.

Write a Comment

Comment