Before you go, check out these stories!

Hackernoon logoNo, no, no! You got it all wrong by@okaleniuk

No, no, no! You got it all wrong

Author profile picture

@okaleniukOleksandr Kaleniuk

I think I should write a little follow up for “Blood, sweat, and C++.” It was clearly misunderstood by quite a lot of people, and it’s fine. Inability to clearly express myself is only my fault. But it also revealed some cardinal misconceptions not about my writings, but about C++ in general. For the sake of argument, I have to respond to them.

Misconception 1. C++ is a bad language

C++ is huge, complex, needlessly eclectic and it suffers from its heritage. That’s all true. But there is another language we all know and love that share the same traits. It’s English.

At first glance it seems to be just pieces of French, Latin, Dutch, Sweden and God knows what else sewed together. But it has its own core, own rules which all the borrowed parts comply. It incorporates other languages just like C++ incorporates bits of Simula, Ada and ML.

It is also huge in comparison to its peers. Different methods show different word count, but with its 250 000–1 000 000 impressive number English probably has more words than any other language on earth. Just like that, current C++ standard ISO/IEC 14882:2014 consists of 1358 pages, and it is by far the largest computer language standard ever existed. Most of the languages fit in between 600–800 pages. But it only took 18 pages to standardize Algol 60, so this is also possible.

And have you ever wondered, how come non-personified objects come in neuter gender in English, unless she is a ship? That’s one example of confusing heritage. Gender system in English evolved from West-German where genders applied to inanimate objects as well. It became genderless only by the 14th century. Except for the exceptions of course.

Speaking about heritage. Up to C++17, the standard had trigraph sequences in it. Trigraphs is the way to type 7-bit ASCII symbols using 6-bit encoding. If you have a teletype that has no # button on it, no worries! Just type ??= and the wonderful world of C-preprocessing is open for you once again.

Yes, C++ is big and complex. You can’t deny it. But it doesn’t necessary make it a bad language. Complexity may be a burden, but it may also be a merit if you want versatility and the expressiveness.

Misconception 2. C++ was designed for performance

C++ was designed to be systems language with cheap abstractions. You can write rather efficient low-level code, and you can leverage it with little to none overhead. You can achieve comparably good performance with this, but this is not what “designed for performance” stands for.

Languages that are deliberately designed for performance are Fortress, Chapel, or even good old Fortran. Fortran compilers have a 60 years old history of optimizations, and since they are much simpler than C++ ones, they are notorious for creating more efficient code in Fortran typical applications. It’s also easier to port Fortran efficiently to any new perspective platform. There is CUDA Fortran with full support for the Fortran 2003 standard. But CUDA C/C++ only supports some bits of C++; it is not at all ISO/IEC compliant.

But honestly, if you want performance, you should think about programming hardware directly. Then VHDL and Verilog will be your languages of choice.

So yes, you can write rather relatively efficient code in C++; and no, it is not designed for performance.

Misconception 3. C++ is easy if you follow the rules

There are lots of rules for C++ programming. There are coding standards:

There are books that work like standards:

And there is, of course, Core Guidelines.

There are more, but these are the ones I read and can safely recommend for acknowledgment.

Technically you can follow HICPP 4.0 to the bone and shoot yourself in the foot a little less. That’s true. You can also quit drinking, eat healthy and run a half-marathon every other morning. Everybody can!

Everybody can increase their health significantly with a little discipline. But somehow the world is still full of heart diseases. Apparently, people don’t like to be told what to do. Even if it is for their own good.

I hope you can see what my point is. Standards are useless unless everybody follows them. And no, this is not the case. You may impose a standard for your organization, you can shield it with static analysis, and you can punish trespassers mercilessly, but the moment you have to go out in the wild — you’re screwed.

Unless you can make your development fully hermetic, — no third party code, no merger inheritance, no legacy — you should not rely on the sanity of a coding standard.

In conclusion

There is one thing that programming teaches better than anything else. And this is accepting reality. You can convince your college professor that you know all about economic transition in Uzbekistan, but you can’t convince a compiler that your syntax is correct.

The reality is harsh for C++ programmers, but since we don’t compete with gods, but only with each other, this harshness doesn’t mean all that much. It’s all even, all fair.

Good programmers write good code in any language.

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!


The Noonification banner

Subscribe to get your daily round-up of top tech stories!