◀ prevnext ▶

Crisis

Other · Apr 10th, 2022

Thumbnail credit: "VOID KING", found during the 2022 April fools event on r/place, reddit

I've been reading about how game engines work since September last year. And I've been trying to program one since January. I have learned a lot, but made frustratingly little progress. And now, I've hit a roadblock so hard, that I am reconsidering the entire project altogether.

I programmed my engine in C++, because it is fast and the industry standard for this kind of job. It's fun, really. I have read a few books on the language, and I think I know my way around pointers, memory management and the things alike. But while things were doing fine, most of the code I've written was untested. This is because I have lost the motivation to write unit tests at my fulltime job, and thus I attempted to write not a single test. However, I quickly realized that without unit tests, I can't possibly expect all the edge cases to work. Once they turn up in the engine, it could spell disaster. With unit tests I can throw edge case after edge case at my code and see what happens, stomping out bugs before they can even occur.

I know what unit tests are, how to write and design them. I simply never did it in C++ before. So my thinking was optimistic: I relearn the syntax and that's it. Sadly, there were multiple issues ahead. First of all, ReSharper just sucks. Its IntelliSense constantly shows errors in the code editor, despite the fact that the compiler has not a single issue with my code. Then there is also the fact that ReSharper doesn't find all the tests I write. Luckily the Test Explorer of Visual Studio finds them effortlessly, and thus I can use that instead. It's quite frustrating that ReSharper does the opposite of what it's designed to do.

The worst thing however has nothing to do with ReSharper, and it has to do with the Linker and how it refuses to Link pdb files. It does fine linking them in my actual engine, but for whatever reason, it doesn't like to do that for my tests. This means that even though my tests compile and run, I can't debug and step through them.

With the books I've read, I feel like I have accumulated a lot of knowledge about C++ and the cool stuff you can do with it. But the things that I fight with most are not the concepts themselves, but the tools I am working with: The IDE and ReSharper.

Now thinking about it, it was always the tools that I was fighting with. Moving files in Visual Studio is horror, as it just updates references and doesn't actually move the files. Then there is the fact that the directories in the Solution Explorer aren't actually directories, but "Filters", which I carefully need to manage so they look like the folder structure beneath. Or how about the issue, that when I run the tests, some process is hoarding all the obj files, meaning that the Linker can't open them when I try to build the project some time afterwards. This is fixable by simply running a "Clean Solution". But this inevitably means that the next build has to build the entire solution, which is unnecessary and takes an unreasonable amount of time.

I feel like I know how to drive a car, maintain it and even build custom parts for it, but I just can't open the car door. I am aware of the dangers of driving a car, like causing accidents, but also the cool stuff I can do, like drifting or what I am most excited about: parallel parking. But these are absolutely non-issues for me, because I just can't open the fucking door.

So, where do I go from here? As far as I can see, there are 3 paths for me to take: 2 painful ones and 1 very scary one. I could just bite the bullet and stick with Visual Studio + ReSharper, trying to find that hidden Linker setting to make everything work again. But considering that this wasn't the first time I had problems with the Linker, I don't think I will have much success with that approach. Thus, another option is to switch to a simple Text editor + CMake. Browsing r/cpp nowadays, it seems that this second option is very popular. But this requires me to learn CMake and I probably need to restructure my entire engine. And then there is also no guarantee that the Linker is still happy with the garbage I am throwing at it. These are the 2 painful solutions to my problem, but there is a third, and very scary one: Rewriting everything in another language.

Ever since I started this project, there is this nagging thought at the back of my head: What if C++ dies tomorrow? C++ is an established, successful and popular programming language, but it's no secret that it's old. As such, one disadvantage of C++ is the fact that it accumulated a lot of garbage over time. For big companies and century old code wizards this may be no issue, since they know what to use when and how. But for me as a beginner, sifting through all that garbage is cumbersome. Maybe the issues that I have laid down so far are actual non issues, but simply a result of my poor understanding of what is garbage and what is not. Though this begs the question: How do I know which of the stuff I am using is garbage? All of the books I've read talk about pointers and how the language works, not about how I need to set up my damn compiler.

So, if one option is to face constant struggle via trial and error, and the other to rewrite potentially everything to make it magically work with CMake (which may not work btw), then why don't I just rewrite everything in a newer language? I don't know how long C++ will last. Maybe it doesn't die tomorrow and it will last for another 100 years. But switching languages feels like the safe bet. Though I have to mention that with my experience so far, everything that felt like a safe bet always found a way to hurt me in some way. Though considering my other options, switching languages may be the least painful one that I have.

And thus I want to take a shot at Rust. I've heard good things about it. What intrigues me most is that it's comparable in performance and low level to C++ (allegedly). But then Rust also provides a tier list of supported platforms. This in itself is a deep relief for me. With C++, even writing a single line of code can sometimes feel very stressful, as you are aware that it may or may not work on all platforms. But Rust itself guarantees that my code definitely works on certain platforms. I hope that I simply don't need to have as much concern about platform independent code as with C++.

So my plan is set: I try out Rust. I throw my bad code at it and see how it responds. In the worst-case scenario, Rust throws the garbage back at me and refuses to do what I want it to do. But in that case, I can then choose: Do I stick with it, or do I go back to my C++ code? What this means is, that in a couple of months down the line, I actually have options on what to do. And considering that the development stage of my engine is so early, I can afford to try out stuff and see what works.

Okay, so it feels like I am attempting to do the job properly now, or how we say in German: "Ich versuche Nägel mit Köpfen zu machen." But there is one thing left, that I want to set straight: The state of my blog.

I haven't titled this blogpost "Crisis" for no reason. And it's not just about me crying about the fact that I am too stupid for C++. No. It's also that I am unhappy with my current life and the work I am doing. The Void King in the thumbnail visualizes my current feelings very well to be honest.

I really love science, and as such I consume a lot of scientific and educational content on the internet, most notably YouTube. While this is a lot of fun, I can't help but feel very useless while consuming such content on the internet. There are amazing people who educate about fascinating stuff. They are doing incredible experiments and demonstrations. I love it. But as much as I love it, it greatly puts all my work to shame. I am here, sitting in my room, debating what language to use or how to name my variables. And then there is this dude on YouTube, who actually performed Veritasiums thought experiment, to correct him. (I freaking love this dude and his videos. I don't want to sound like I am discrediting him.)

I want to add to this world. But I did not study science. I studied IT. All of the stuff I know, both science and IT, I have learned from other people. And all these people are better at explaining than I could ever be. As a concrete example: This year I fully understood how Unicode works. I even implemented working(!) UTF-8 and UTF-16LE encoders into my engine. And I wrote a blogpost about it. But why would anyone read my crappy blog, when there are better explanations out there? For example this blogpost, or this talk on YouTube.

I concluded that my blog doesn't add anything. It has no value, neither to me, nor to anyone else. And as such, I decided to delete my blogposts about my engine. I will try to post stuff which actually has value. An example of something with value would be my blog about how I wrote this very website: LINK

While this isn't a tutorial that tells you step by step on how to write a website, it condenses a lot of information into a couple of chapters, about what I have learned on how to make a website. My findings may or may not be best practice, or up to todays standards, but it does work. And I feel the fact that it does work so well, is very important to share.

I hate that this blogpost ends on such a low note. But I feel like it is necessary for the 2 people who read this blogpost, and for myself. I need to grow in my abilities: Both in improving my programming skills and in dealing with huge projects. I don't know how things will look in the future. Only time will tell.

Next Post: Post Crisis

Other · Jun 11th, 2022

Next Post: Post Crisis


Other · Jun 11th, 2022

Previous Post: Why people love Bad Art
More Other related Posts