Skip to content

Instantly share code, notes, and snippets.

@bkaradzic
Last active May 16, 2026 11:21
Show Gist options
  • Select an option

  • Save bkaradzic/2e39896bc7d8c34e042b to your computer and use it in GitHub Desktop.

Select an option

Save bkaradzic/2e39896bc7d8c34e042b to your computer and use it in GitHub Desktop.
Orthodox C++

Orthodox C++

This article has been updated and is available here.

@bkaradzic
Copy link
Copy Markdown
Author

@d-musique Excellent! 👍

@iperov
Copy link
Copy Markdown

iperov commented Feb 25, 2026

Any language starts to grow features with which you can accomplish the same task in a large number of ways.
As a result, when you read someone else's C++ code, it looks alien, because the language provides many ways to do the same thing.
Rust follows the same path. C# similarly adds new keywords with each version instead of removing them and making the language simpler and clearer.

@iperov
Copy link
Copy Markdown

iperov commented May 9, 2026

what is your standing on references ?

references are 💩

void do_something (int& x)
{
    x += 1; //mutate! hahaha
}

int main(int argc, char** argv) {  
    int q = 0;    
    do_something(q); // You won't know that q will be mutated unless you read the documentation or the function impl.

@iperov
Copy link
Copy Markdown

iperov commented May 16, 2026

No, guys.
Even Orthodox C++ doesn't fix the fundamental problem with C++, where any class can behave however it wants depending on its set of constructors and destructor. A class can be a value type (copied by value), act like a reference type, have an explicit free() method, or be a proxy value type that references a ref-counted object which destroys itself when the last reference in scope disappears. And that's not even mentioning the ability to template all of this and essentially create a mini programming language on top of C++.
Because of this variety, you are forced to study every single class to keep in your head exactly how it behaves during assignment and argument passing.

This results in multiple layers of mental pattern unfolding while reading code. Very high cognitive load.
Even if you add a rule to Orthodox C++ banning the use of class and constructors inside struct, it still doesn't save you from classes with diverse constructors coming from other libraries you use - because a library might provide an API where the class is designed as a proxy to a ref-counted object.
This would mean that such "Orthodox C++" needs its own separate repository of libraries, which is obviously absurd.

In light of this, using C++ even as "C+" just for namespaces and function overloading isn't worth the effort. Plain C is cognitively simpler: you know that all structs are copied by value, and the compiler simply won't accept anything else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment