The Zen Of C++

Published on
11,590 Points
1 Endorsement
Last Modified:
An expert in cross-platform ANSI C/C++ development, specialising in meta-template programming and low latency scalable architecture design.
Inspired by The Zen of Python and with a wink and a smile, and tongue firmly in cheek, I hope this will bring a smile to you C++ programmers.

Are you a C++ programmer who works with Python programmers? Are you fed up with them banging on about their "Python Philosophy"? Do you feel like beating them over the head with your compiler every time they witter on about using 4 space intending? Does the fact they continuously try to convince you enforced white space syntax is a good thing just make you want to hurl chunks? If so, what you need is "The Zen Of C++"!

The Zen of C++:

Beauty is but skin deep.
Explicit is implicit.
Why be simple when we can use meta-templates?
Complex is better when more complicated.
Nested is fun but tail end recursion rocks.
C++ is better than Python.
Readability counts for nothing.
Special cases aren't special enough if they don't break the rules.
Forget practicality; you're an artist so let your creativity flow.
Errors can be ignored; that's what default exception handlers are for.
Supress all compiler warnings -- you know best!
In the face of ambiguity, resort to templates.
There should be one-- and preferably only one --obvious way to do it; but don't let that stop you inventing others.
Although that way may not be obvious, which clearly means a better way exists (probably using lots of templates).
Now is the best time to introduce unnecessary complex constructs otherwise you may never get around to it.
Never is often better than right now, unless it's that "one last 'quick' change that you know will not cause a defect.
If the implementation is hard to explain, good -- you'll have job security.
If the implementation is easy to explain start working on your CV.
Namespaces are one honking great idea -- it means we can now dump everything in the global one!

So there you have it... The Zen of C++ to be used liberally with a bit of joy and if said with a smile should not offend anyone (including Python programmers) :)
Ask questions about what you read
If you have a question about something within an article, you can receive help directly from the article author. Experts Exchange article authors are available to answer questions and further the discussion.
Get 7 days free