Skip to content

Instantly share code, notes, and snippets.

@bkaradzic
Last active November 3, 2025 04:11
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.

@DBJDBJ
Copy link

DBJDBJ commented Mar 4, 2024

GCC and clang should introduce new switch: /orthodox

@GabrielRavier
Copy link

GCC and clang should introduce new switch: /orthodox

@DBJDBJ what would the flag do ?

@amlel-el-mahrouss
Copy link

This should be the default way of doing C++
Feature creep is never good.

@DBJDBJ
Copy link

DBJDBJ commented Jun 29, 2024

@GabrielRavier

GCC and clang should introduce new switch: /orthodox

@DBJDBJ what would the flag do?

Enforce "all" the "rules" discussed here. The very first post on this page explains it. I would also add: bar std::

@meemknight
Copy link

Yo, hopping in the discussion, my style is that I just use std::vector and string and things like that. I think that using them is very nice and they don't really have many problems for 99% of use cases, writing them is horrible tho, so I would never write them. So basically I write C with methods, operation overloading, vectors, lambdas, std::file_system and one time a year templates ๐Ÿ˜‚. I also never use destructors.

@KubaO
Copy link

KubaO commented Feb 6, 2025

@bkaradzic , I have a small doubt I wish to ask you. Heap fragmentation is a problem when it comes to STL, so why not write something to a bump allocator? Have a continuous block of memory, and when a realloc is requested, if requested size is bigger than existing, expand the pool, move it to the end and get rid of the hole in between (using memmove).

A simple implementation of this comes with asmjit. See Zone, ZoneAllocator, ZoneVector, ZoneHash, ZoneString. It is used in what amounts to compiler-class code that has to be light and fast. It delivers on that.

@Refractor-Will
Copy link

Question @bkaradzic : What would be considered "selective" use of C++20? I'm planning on upgrading my C++ version for a game engine I'm working on. Any particular features in mind, or just keep using features that existed in C++17 that might have additional power in C++20 (for example, updates to constexpr)?

As a side note, personally, struct/enum/union without typedef, reference parameters, and constexpr are all I use from C++.

@trcrsired
Copy link

trcrsired commented Feb 25, 2025

@d-musique
Copy link

@DBJDBJ

GCC and clang should introduce new switch: /orthodox

I've implemented it, pretty much. See https://github.com/d-musique/orthodoxy
It does the enforcement of programming rules that you mention.

It's quite recent and it works for me well. This thing was born out of extreme frustration with the ongoing ens*ittification of C++ to a point that I could no longer accept it.
This lead me to revise my approach to C++ programming to a large degree, and I judged this kind of tool to increasingly become a necessity. This has been on my mind for maybe a year or so but finally I dedicated some time so I could bring it to reality.

@bkaradzic
Copy link
Author

@d-musique Excellent! ๐Ÿ‘

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