DEV Community

Bad Code Killer
Bad Code Killer

Posted on

Senior Dev and Multi-threading

Oh wow, sounds like you're living the dream in that startup! Working alongside a "senior" dev who somehow managed to fall upwards into a C++ role after a brief affair with Python. Let's call him Mandd, the accidental C++ guru.

So, Mandd, in all his infinite wisdom, has discovered the marvel of RAII (Resource Acquisition Is Initialization), but only about 20% of it. Now, when he writes multi-threaded code, instead of gracefully managing resources like an actual C++ dev, he just throws random scopes around like confetti at a Pythonic parade.
{
if (something) {
std::unique_lock(mtx);
// do stuff
}
}

Now, I'm sure you're thinking, "Wait, what happens to that lock? When does it release?" Oh, my sweet summer child. According to Mandd, who needs lock management when you can just keep nesting scopes until the lock accidentally releases itself?

You know, it's like taking a road trip and throwing your car keys out the window, hoping gravity will take care of it at some point. It’s the C++ version of a trust fall.

This is what happens when Python devs infiltrate the C++ world through a combination of sheer luck and high-powered networking. And voilà, the code reads like a love letter to scopes, locks, and confusion.

Mandd should probably stay away from pointers, but then again, he might invent a new C++ design pattern: Scopeful Destruction.

Top comments (0)