This is a work in progress, comments are welcome to: johno(at)johno(dot)se

Object Oriented Programmers Anonymous

Hello my name is Johannes 'johno' Norneby, and I am an Objected Oriented Programmer.

There Was Going To Be A Book...

Over the past 12 years, since I finished work on Ground Control 2 at Massive Entertainment, my thoughts on game programming have gone through a large number of changes.

Around 2008 I started working on a book that was supposed to be enlightening and highlight a lot of the pitfalls I had experienced while writing games using Object Oriented C++, and what the techniques I had discovered in order to avoid those pitfalls. That stuff is here, but I now think that that stuff is misguided.

Since then I have found my code style has changed radically yet again, and I very much feel like the root of all the problems I was facing and trying to solve was Object Oriented Programming itself. This feeling has been severely validated by my experiments and experience while developing Space Beast Terror Fright. This basically renders all of the previous stuff in the book pretty much moot, unless they are interesting from a historical perspective.

I would like to start again and cover a lot of the things that I currently think are interesting when the goal is to be super-productive in creating real-time games using C (and possibly some of C++).


What the Space Beasts taught me (abandoning OOP)

Relational Model theory and how it inspired my legacy persistence solutions

High-school datasets, Dreamler, transactional persistence, and generic data stores

Current thoughts on generic data representation and persistence (Tangle)


It Seems Like The Problem is C++

They say that C++ is multi-paradigm. Some people say that this is a good thing, because you can pick and choose and find exactly the right spot between the Procedural and Object Oriented styles. I'm starting to feel like this isn't good at all, because what happens when your choices are based on the fact that you don't understand what the paradigms even ARE to begin with?

I had a talk with a programmer yesterday who was MUCH more experienced than I am, and who also has more experience with different types of languages than I do. C/C++, Lisp, Java, C#, Elm, the list goes on. When I started talking to him I expected a flame-war of sorts, because he was working on something all in Java and C#, and as I'm very much moving away from OOP in what I'm doing I didn't expect to find a lot of common ground. What I found instead was that he had a much better understanding of the trade-offs between Procedural and OOP.

As I understand him it is all about understanding your problem. He completely agreed that if you were working on a super-high performance real-time game, then you basically have a data-transformation problem ala Mike Acton's definition and you should use C and hence a completely Procedural style.

If on the other hand you are doing something that isn't as performance critical, ONLY THEN can you afford the performance overhead of using higher level constructs like OOP. In those cases he felt pretty strongly that you should use a more modern language like Java or C#, simply because these have a cleaner / stricter implementation of OOP concepts then something like C++.

I like this view very much because it avoids the whole dogmatic "what is the truth!?" aspect of discussing what programming style to use. It also speaks to me very much in terms of why it has been so extremely painful to navigate all the dogma of OOP (which I was very enamored of in the 90s) as seen through the implementation of said dogma in C++.

I have honestly NEVER programmed purely in C. I started in 1994 with C++ which was very much the go-to language. Going to university around 1996 we were taught that OOP was the way to go, and we were heavily influenced by things like the GOF Design Patterns. Also I recall that our class was the last year to be taught OOP in C++; after that they switched to Java. As I was (and am still) primarily interested in programming from a real-time game development standpoint, I was happy that we learned C++, but it also seems now like I managed to be TOTALLY distracted from what my real goal was, namely game development, by the lure of high-level programming via OOP.

I recall seeing id Software's Doom source code when it was released under the GPL. I'm sure that the actual quality of said codebase can be discussed ad nauseum, but I remember very clearly feeling something like:

"Ok, this stuff is in C, and it doesn't look like the stuff we are doing at Massive because we are using C++, but C++ is BETTER ON ALL COUNTS than C, so everything is fine."

Nearly 20 years later I'm feeling very strongly like I was completely wrong in thinking like that when it comes to my specific goals in games programming. I will expand on this idea in future installments.


Why I am a programmer at all

As a kid I went nuts over the first Tron movie. The dude WENT INSIDE A COMPUTER, and even better the movie expanded on the implications of the arcade style of games that I was growing up playing. Later in highschool I saw Doom, and remember clearly thinking:

There are WORLDS in there!

Doom initially got me into designing levels for the game, because I wanted to be a person who created said worlds and in general just be in that conceptual space. I soon found that I wanted to move beyond what was offered by those tools, and also explore concepts inspired and implied by the arcade games that I grew up with. All of this led me naturally (at the time) to programming in C/C++, because that was how games were crafted, created and controlled.

This growing interest led to me studying (general) software engineering in university, but always with the agenda of learning more about programming so I could be a more effective game creator. This in turn led to Massive Entertainment where I worked as a programmer (not a game designer).

What took me a long time to realize (and to be fair it was easy to be distracted by everything going on in the growing industry during the later 1990s and early 2000s...) was that my interest in programming was always driven by my creative desires to create games. When working at Massive, Dice, Jungle Peak and Mindark over many years, I finally figured out that ONLY being a technical programmer type was relatively uninteresting to me.

All of this made me into somewhat of a maverick, because trying to be a "creative programmer type" didn't really fit into the structure of the swedish games industry as a whole. This eventually led to me going indie, and finally after many years and many games seeing some success with my game Space Beast Terror Fright. There's an interview here that goes into this progression / realization in more detail.

I have found it is super-easy to be distracted by dogmatic ideas about programming. This is probably because I am so hell-bent on figuring out the most productive way to do the required programming for the games that I want to make, and this causes me to be in a state of constant questioning of the techniques that I use since I only use ANY techniques out of the necessity of programming in order to create games. I keep saying to people that I'm not really interested in programming per-se, only what I can ACHIEVE by programming, and only then in the most productive way possible.

This page is about the ongoing demise of my long-time relationship to Object Oriented Programming in the context of real-time action game development in general, and in C++ in particular.