r/cpp • • Mar 18 '26

What open source projects in C++ have the highest code quality?

My understanding of the characteristics of quality code are the conventional ones.

  • operations on an object that are allowed in a particular object state do not put the object into an invalid state.
  • it's prioritized to organize the implementation of each object into the smallest possible number of sub-objects.
  • no cryptically abbreviated names are used, except possible in very small scopes.

    With the program(s)/executable(s) themselves, as well as modules with corresponding namespaces, being considered singleton objects.

Fair dinkum if you want to name projects that score well under a different understanding of code quality.

191 Upvotes

100 comments sorted by

View all comments

Show parent comment

36

u/Serious-Regular Mar 18 '26

LLVM et al is definitely ok but I wouldn't call it modern - we only switched to std=c++17 like 3 years ago! And it'll probably be a couple more years until we move to c++20...

27

u/pjmlp Mar 18 '26

Which is common across the industry when writing portable code that is supposed to work everywhere.

I only use latest C++ on hobby projects.

1

u/MarcoGreek Mar 18 '26

In my experience that is an excuse. In pushed for newer C++ and it was not the compiler support but the people who doesn't want to change. We have programmers who avoid unique pointer or variant.

4

u/pjmlp Mar 18 '26

In my experience that is a privilege position to be in, not everyone has the luxury to control which compilers are used by their customers.

2

u/MarcoGreek Mar 18 '26

The question is if that customers are worth the costs. My experience is that some of them go out of business. There is always a balance between future customers and legacy customers.

4

u/pjmlp Mar 18 '26

So far yes, they are worth it, especially in times like these, where every single custormer counts to keep the employees around.

3

u/MarcoGreek Mar 18 '26

But if your solution looks outdated to other customers because you lean to heavily on conservative customers it can hurt too. Especially in the future.

4

u/ShoePillow Mar 19 '26

The compiler choice has no effect on how the solution looks though 

1

u/MarcoGreek Mar 19 '26

I like to see how you emulate variadic arguments. I suppose that without ranges your interface can look different. And supporting serialization without reflection will be interesting.

2

u/ShoePillow Mar 19 '26

Ok, but I was thinking about the solution from the customer's perspective. For them, these things won't matter

→ More replies

-6

u/Serious-Regular Mar 18 '26

Um I have no idea what you're trying to say - c++20 isn't less portable than c++17 (that would make no sense - they're both standards....). Ironically enough the reason we (LLVM) haven't bumped std is because not all compilers have full standard support specifically clang.......

Edit: ah shit I didn't notice I was responding to pjmlp the king of cpp/compiler trolls 🤦

20

u/OlivierTwist Mar 18 '26

c++20 isn't less portable than c++17

Sweet summer child...

We have customers on RedHat-8.8. Our binaries should work with glibc-2.28 and headers be complilable by gcc-8.4.

-1

u/emidln Mar 18 '26

I compile with c++2c (26) and target hosts with Linux 3.x and 4.x kernels and unknown libcs. Ship the dependencies you use. Statically compile or RPATH with $ORIGIN and ship your installer to patch .interp to your ld.so if you need dynamic libraries for some reason. Relying on a random host's binary libraries to be magically compatible is delusional and should be mocked.

1

u/OlivierTwist Mar 18 '26

We have C++ in headers.

-11

u/Serious-Regular Mar 18 '26 edited Mar 18 '26

Do you people have literally any idea what you're talking about? This has literally zero to do with portability 🤦🤦🤦

Edit: Portability means it works across architectures not across time (backwards compatible with ancient versions of the compiler) because that's fucking impossible

13

u/yuri-kilochek Mar 18 '26

Rather, it seems you have an oddly narrow and specific definition of portability which doesn't include the software stack under your program.

5

u/38thTimesACharm Mar 18 '26

Not OP but to me, portability and compatibility are different things. I would say needing to support old versions is a compatibility problem, while a portability problem would be relying on GNU extensions or assuming UTF-8.

2

u/yuri-kilochek Mar 18 '26 edited Mar 18 '26

How is a GNU extension different from a new standard feature? Both limit where you can build your code, and both can be resolved by either modifying the code to not use them or getting a compiler that supports them.

4

u/Serious-Regular Mar 18 '26 edited Mar 18 '26

Both limit where you can build your code

Portable code means it compiles for multiple targets not that it compiles on multiple targets. Like lemme ask you: do you think people doing embedded dev are compiling on the microcontrollers themselves.............?

2

u/Serious-Regular Mar 18 '26

Portability means it works across architectures not across time (backwards compatible with ancient versions of the compiler) because that's fucking impossible

-9

u/MarcoGreek Mar 18 '26

There are so many different ways to ship your binaries in a container like Flatpak, docker, podman, toolbox etc..

→ More replies (21)

3

u/pjmlp Mar 18 '26

Glad to have won a title, maybe I should have that as flair.

So you answer yourself that "haven't bumped std is because not all compilers have full standard support specifically clang......." and I am the troll.

We write code that is supposed to compile in any compiler, not having to have cppreference open or its successor, to see what "Can I use" that works in all target compilers.

1

u/MarcoGreek Mar 18 '26

We write code that is supposed to compile in any compiler, not having to have cppreference open or its successor, to see what "Can I use" that works in all target compilers.

So you write C89? 😋

2

u/pjmlp Mar 18 '26

I avoid writing C as much as I can since 1993, I agree with Microsoft point of view that we should have nuked C long time ago.

Reader Q&A: What about VC++ and C99? from Herb Sutter.

Even though with Microsoft <3 Linux and FOSS, support for C11 and C17 has been added.

So if I do have to write C, all our target compilers do at least support C11, no need for C89.

2

u/Expert-Map-1126 vcpkg maintainer BillyONeal Mar 21 '26

To me "modern" means "post move semantics" and LLVM certainly qualifies