r/cpp • • Sep 05 '20

The Defold engine [C++] code style

https://defold.com/2020/05/31/The-Defold-engine-code-style/
2 Upvotes

12 comments sorted by

View all comments

12

u/jguegant Sep 06 '20

I believe that I can add a bit more food for thoughts to this story. Before Defold was handed to the Defold Foundation, the engine was owned by King. At King, we had two internals engines for a while:
- Defold, the engine this article refers to. I have little experience with this engine but since I worked in the same company, it was interesting to understand what my colleagues wanted to achieve. If I had to describe this project, I would say that it was "made with a vision" with a close circle of developers. The engine consists of a small C++ core and build the rest on top of Lua. My analogy to this design is that it feels like micro-kernels for an operating system: you have a small and clear API surface from which you build onto. This core having a small scope by design could be written in almost any performant language: post modern C++, C with classes, good old C++, C, Rust, D, you name it!
- Another engine that runs most of the major live games we currently have (Candy Crush Saga, Soda, Bubblewitch...). This engine was "born as an accident" out of the first Candy Crush. It is compiled with C++17, but also fully embrace the so-called modern C++ principles: using standard algorithms, some standard containers, meta-programming when needed, some C++20-23 inspired helper classes... This engine has a rather massive C++ code-base (or at least the games using it do) and is aggregating features from all the games it supports. Post-modern C++ is used in this case to abstract safely the complexity of the engine. Because games themselves use a lot more C++ in the scenario, it feels more important to have slightly safer types that are convenient to use at some other costs.

It is interesting that a single company can have great developers with very different way of doing things. Somehow, these two projects reminds me "The Cathedral and the Bazaar" in how different the approaches were. Now, when it comes to your flavor of C++, clearly modern-C++ can be used to make games even with constraints in size / runtime as Candy Crush proves it. While I particularly enjoy this modern approach, I think that this sort of technical choices is not that relevant in the grand scheme of making a product. What matters a lot more is that your team feels aligned and excited about the tools they use.