r/cpp • u/Both_Helicopter_1834 • 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.
190
Upvotes
84
u/_Noreturn Mar 18 '26
I liked sfml codebase
57
u/kevinfrei Mar 18 '26 •
The LLVM/Clang/LLDB codebase is marvelous. Clean, modern, but sensibly restrained C++. Easy to follow, with an in depth test suite, and a reasonable amount of documentation. Iβve spent time in four different compilers. LLVM is light years ahead of the rest from a βcode qualityβ perspective.
https://github.com/llvm/llvm-project
22
u/tmlildude Mar 18 '26
WebKit
18
u/hdkaoskd Mar 18 '26
https://github.com/facebook/folly
9
u/MarcoGreek Mar 18 '26
I looked into Glaze and was surprised how readable it was. I was expecting much less readable code because it aims for being the fastest JSON parser.
It has a nice interface for serialization, so the consumer has not to write JSON walking code.
I would say there is not the most readable C++ code. For example to write an readable interface you have sometimes use quite strange C++.
Variadic template were an example but nowadays they are quite reasonable because the language was extended.
Templates were really hard to read if you wanted to provide an nice interface with overloads. Concepts made that so much better. For example testing if a method is present is now absolutely readable.
Projects like Google Test are a negative example. They try to provide a readable interface but their code makes it really hard to understand.You have to look into the documentation.
Hopefully with reflections projects like Google Test can provide a nice interface and readable code together.
8
u/IceMichaelStorm Mar 18 '26
stockfish cheas engine is neat
7
u/allybag Mar 18 '26
https://github.com/mawww/kakoune
34
u/OkYou811 Mar 18 '26
Googles carbon compiler has very organized and well structured design. The code itself seems to follow the Google code guidelines, and their overall project structure is nice. Made it easy to get in to
27
u/sessamekesh Mar 18 '26
I can't think of anything I'd call "highest code quality," but in general Google's C++ guidelines + internal readability standards are pretty good, and their open source work is generally pretty high quality: Google C++ open-source repositories.
The two I'm most familiar with are Draco, and Dawn - I have largely positive and a few negative things to say about each.
I haven't looked beneath the covers of Filament, but I'd imagine that's a great one to look at.
The real world is messy and practical scale code bases are often messy with them, I have yet to see a code base in any language that I'd call "highest code quality" outside of maybe a handful of <10k LOC utilities.
3
u/ZachVorhies Mar 18 '26
https:://github.com/fastled/fastled
3
u/dydzio Mar 18 '26
battle for wesnoth (sorry, do not beat me, i am joking)
3
u/def-pri-pub Mar 18 '26
MineI would say to look at Qt's. When I've had to build it from source its been a cinch. When I've needed to dig through the source to explain to my boss why what he wants is impossible (yes, this has happened to me multiple times in my career), it's been very easy to do so with tools like Woboq.
3
u/readanything Mar 18 '26
duckdb is very well written IMHO
2
u/sriram_sun Mar 18 '26
Not the author, but a fan of HFSM2. Look it up on GitHub.
2
u/LiAuTraver Mar 18 '26
LLVM. Fantastic doc, but it's code needs time to understand, though.
2
u/Acrobatic_Ad686 Mar 18 '26
Not C++ but C But raylib header only is surprisingly easy to read and figure out how the code flows without docs
2
u/IniKiwi Mar 18 '26
Serenity os
2
u/Aggressive-Lawyer207 Mar 18 '26
Matroska is an interesting project
https://github.com/Matroska-Org/libmatroska
3
u/darkriftx2 Mar 19 '26
The Boost C++ library: https://www.boost.org/ is one of the best out there in terms of quality and peer-review.
1
u/Alarmed-Extent6639 Mar 18 '26
Not an answer but just curious as I'm learning C++, what are each of you definitions of a good C++ codebase? The language is so insanely huge that I'm struggling to define how to write it best.
On the other hand, what do you think of SerenityOS code?
1
u/EffectiveAsparagus89 Mar 18 '26
Lean4 is good.
1
u/sitbon Mar 18 '26
I contributed to NS-3 like 15+ years ago and remember the codebase being very well organized and consistent. They've had clear and comprehensive guidelines that helped the codebase grow in a sane manner over time. And it's still going!
1
u/LuisAyuso Mar 21 '26
llvm/clang was mentioned. This is triple A.
I enjoyed Skia. Although it follows the very opinionated google c++ practices and naming, it is clean and effective on delivering.
CGAL library for computational geometry is a special mention for its type safety and compossibility of algorithms using templates. This is not everyone cup of tea, but it uses C++ at its highest capacity.
Special mention to the standard library, the interfaces are extremely well thought of, implementations are like they do not apply their own rules.
1
u/Specialist_Nerve_420 Mar 22 '26
big projects like chromium or bitcoin look messy sometimes but for their scale theyβre actually pretty solid . iβve learned more from mid sized well maintained libs than huge codebases tho
1
u/araml I have no idea what I'm doing Mar 25 '26
I like dlib as the standard of a library I'd aspire to write, although I think it's become a bit stagnant as of late.
1
u/Deep-Piece3181 Mar 18 '26
ArduPilot
-10
u/Resident_Educator251 Mar 18 '26
Cmake. No templates no inline just .cpp and .h a super pragmatic code base that can scale with global contributions and needs.
The more I think about it that seems to be the only way to manage huge c++ projects without making compiler times hell.