Oleksandr Kaleniuk

@okaleniuk

Blood, sweat, and C++

First of all, before I prove my point, before I even expose my point, I want you too see this:

#include <iostream>

int main() {
int n = 3;
int i = 0;

switch (n % 2) {
case 0:
do {
++i;
case 1: ++i;
} while (--n > 0);
}

std::cout << i;
}

I found it on http://cppquiz.org/, which is by itself a great fun and a challenge. The program is valid, it is legit, it compiles, and it runs. It is an excellent bit for a quiz and an absolute crap of a code.

C++ is full of quiz material. It’s not only these particular 75 questions. It has enough obscurities for the whole professional life. It is just too inconsistent and overcomplicated. It combines 45 years of C legacy with all the misleads of the modern programming.

In my ten years with C++ I found answers to a lot of questions. I know what integral promotions are, I know how slicing works, I know how come we have such a ridiculous switch statement. But there is one question, I never could answer properly before now. And it is: why are we doing this to ourselves?

There are better languages. Some are more mature, some are more novel. Some are more expressive, and some are more versatile. Some are mainstream, and some are esoteric. There are alternatives. But somehow C++ manages to keep its popularity, if not regain some in the recent years. Why though?

I think the bigger part of it would be that C++ programming plays the same strings as the Shackleton’s ad. There is a legend that in order to recruit men for his Endurance expedition Ernest Shackleton printed an advertisement in a newspaper and it went like this.

Men wanted for hazardous journey. Low wages, bitter cold, long hours of complete darkness. Safe return doubtful. Honour and recognition in event of success.

Needless to say, he found an excessive number of willing men instantly, and the advertisement has been since regarded as an exemplary piece of copywriting. Apparently, it is also a myth.

But C++ isn’t. Among all its characteristics, the one stands unarguable. C++ is challenging. Not that as the Endurance expedition, but it neither guarantees a safe return.

Perhaps, that is what drags smart people in. The very badness of a language becomes a merit when you want to keep your mind hectic in the day to day work. Java isn’t nearly that dangerous, and C is not that variegated. These are the excellent languages to get the job done, but do they grant a satisfaction of a good fight?

It probably starts in childhood, when you see your parents going to work and it almost seems like they disappear for nine hours or so. You know, that they do something there, you’re not stupid, but it’s all seems so boring and monotonous, it’s almost like they voluntarily go out to non-existence day after day after day. And then when you grow older, you discover your first fear of non-existence, but you can’t yet comprehend it, you just make choices that float you away from it. You need some challenge in life if only to prove that you don’t just disappear every day for 9 hours or so.

Some men go professional boxing; other join the army. Some choose C++.

Hacker Noon is how hackers start their afternoons. We’re a part of the @AMIfamily. We are now accepting submissions and happy to discuss advertising & sponsorship opportunities.
To learn more, read our about page, like/message us on Facebook, or simply, tweet/DM @HackerNoon.
If you enjoyed this story, we recommend reading our latest tech stories and trending tech stories. Until next time, don’t take the realities of the world for granted!

More by Oleksandr Kaleniuk

Topics of interest

More Related Stories