Learning C: or how I stopped using C++

image alt text

I am a web developer. If you asked a few years ago what kind of developer I would want to be, web developer wouldn’t be my first choice. Don’t get me wrong, I love my job, but my love for minimalism and simplicity makes me die inside a little every time I have to write a Vue component or create a Laravel controller.

As much as I love Vue and Laravel for the tools they provide (and they are great tools for their purpose,) something inside me yearns for a simpler solution, and well, just less.

If I had my way, every website would be simple HTML, sprinkled with CSS, with little to no javascript and with the bare minimum backend, everyone would have their own site, instead of using shite like Facebook or “insert social media here”, which if your in Europe maybe soon that’ll be the case.

I’ve always been interested in computers, right down to the bare metal. Now I’m not as knowledgeable as I want to be, but I don’t think it’s ever too late to learn about something you’re genuinely interested in. (unless your dead, that might make it harder.)

For a few years now I’ve been trying to get into C++, and at first I was amazed by the powerful inbuilt features it provides, the speed of your programs and the large community willing to help newbs like me. But as I’ve continued to use C++ I’ve slowly become disillusioned with it. There are many reasons why I’ve moved away from it, and some of those reasons might not even be known to myself, but I can list a few things:

  1. There are TOO many ways of doing the same thing, it just makes things confusing and hard to pin down what is the correct solution, most especially for newbs.
  2. My slow disillusionment with Object Oriented Programming (OOP). I still haven’t come to terms with this and it’s something I’ve been thinking about on and off for a while now. But my general feeling towards OOP has been slowly souring over the years. (maybe I should write about this in future?)
  3. Old C++ vs Modern C++. Being a beginner, it really isn’t helpful when someone on StackOverflow asks how to do A, and the responses explain why A is wrong and you need to do B, then they proceed not to explain why B is a better solution or even why A is bad. It’s very frustrating, especially as the modern solutions they suggest tend to hide away issues you would naturally come against, and thus you are ignorant on the actual issue in the first place, an example that stumped me would be smart pointers.

On that last point, it confused me as a beginner that there is this big consensus that Modern C++ is the one true way and you must never even consider old-style C++, but I bet if you asked most people why, you wouldn’t get a straightforward answer as they probably don’t know themselves.

The reason I wanted to learn C++ in the first place was I wanted to program at a lower level and really dive deep into how a computer works. My previous experience with Lua, C# and Python really didn’t expose me to this, and in my head this would be a great start to the next level of my programming journey. But with Modern C++ I felt that all these inbuilt data structures, std library methods and wrappers just added an extra layer of mist over the interactions with the hardware and really didn’t help me at all in understanding what was actually going on.

I found myself starting projects and ending them just as quickly. I was never able to be productive with C++ and I just couldn’t figure out why. With every segmentation fault my brain would fizzle and I was just getting more frustrated with every error message that required a doctorate in linguistics to decipher.

I reflected for a very long time on why this is the case, is it just that I’m too stupid to use it? Probably, lots of people are productive with C++, why can’t I be? Is it just that I’m a ADD riddled zoomer who can’t get anything done?

image alt text

You see, I have finished programs I’ve started before, not as many as I like but there’s been a few. And all of them had a common theme, all of them were kept simple, I’ve had a well defined goal, and little to no OOP was used. Just pure, procedural programs that (and this is the key) I actually wanted to use. Not to mention all the projects at work I’ve finished (but they don’t really count.)

Now all these issues sort of culminated into me being pushed towards C. At first I was scared to dabble with it as the internet likes to say how dangerous C is with it’s manual memory management and segmentation faults, this is mostly from the C++ and more recently the Rust communities. But here’s the thing, every time I got a segmentation fault in C, I have been able to fix it relatively easily, one of the reasons being because my programs just ended up being naturally simpler. However, every time I got a segmentation fault in C++… now that is torture. I don’t know why the CIA at Guantanamo Bay don’t just get prisoners to fix people’s C++ code bases, it’d save them thousands on the electric bill for the nipple clamps.

After playing around with C for awhile I’ve slowly started to like it. Now I’m still no expert, but after getting over the first hurdle of learning Makefiles, malloc() and free() for my runtime memory and deprogramming my brain from the OOP mindset, I’ve begun to appreciate C for what it really is, a simple procedural language for simple people like me. I find myself more relaxed writing in C as it is so straightforward, my mind can just keep on what’s important, the code.

Now, I still wouldn’t (and don’t) use C for everything, I still much prefer Python for short scripts that I can get finished quickly, but there’s something about C that keeps me close. The only thing holding me back is what next to program.