Do you C?

The confinement has taken its toll on me. I’m dropping C++ in favor of C.

I wonder if the the virus got to my brain instead of my lungs?

A week ago I decided to port all my C++ code to C. I still like C++ it a lot, I’m using it all the time at work. But with my own code, I was feeling like I was always ending up with bloated structures. I was trying to follow OOP principles and somewhat it added complexity that I don’t need, especially being the only one to use that code.

I have been watching and reading some people talking about this (the famous Mike Action talk at CppCon, Jonathan Blow, the guys from Handmade Network), and I am now very interested in data-oriented design.

I took the radical decision of going pure C instead of writing C++ in a “C with classes” style. It sure would have been a smarter decision, I would not have had to rewrite everything, the MSVC compiler is better with C++, I am effectively pushing myself back weeks if not months… From a productive point of view it is a very silly decision.

But I feel good about this. C was the first language I properly learned how to use, that made me fall in love with programming in college. I want to get better at it and I really like programming things on my own.

A few observations after converting parts of my code:

  • it is hard to detach myself from OOP principles, after years of programming that way, it will take me time to adjust
  • some code is way more verbose, especially without constructors / destructors, copy operators, operator overloading, function overloading (those two I am really missing 😥 ), no templates, etc.
  • a good deal of code is actually simplified, which comforts me in that choice
  • I’m having a lot of fun!

I hope it won’t take me too long to port all features, so I can start adding new things. I am confident it will be slightly easier to avoid spaghetti code by changing my way of thinking.

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s