The 2024 Wheel Reinvention Jam just concluded. See the results.

What codebases are doing it well?

What's a forum without some discussion.

So I have a question to all of the more experienced guys here. What are some of your favorite open source, or available code bases do you know of that you consider to be truly high quality, and make it as easy for other programmers to integrate and build code as possible.

I get that the point of handmade is to build from scratch, but often a great way to learn is to dig into other peoples code. For example, looking around at game engines, everything is OOP to a point where most engines don't even bother to mention that.

So I guess, what are the codebases you look to for inspiration about how you make your own projects, and why is it good?

Is there particular things you prefer to see such as Casey being able to build 4coder straight away with a batch file rather than having to mess with yet another Makefilegeneratorninja3000 that you wish other coders would push to do?
It may be an obvious choice (though of course not so obvious if you aren't familiar), but the excellent libraries created by Sean Barrett fit the descriptions of "truly high quality" and "as easy to integrate and build as possible" near perfectly. It's amazing how your quality of life can increase when you don't need to fuss with attempting to configure and build a library before you can even try using it.

Sean also maintains an extensive list of other libraries created in the same fashion.

GingerBill created this collection of general purpose single-header libraries as well.
For a non-library project, I want to give a shout out to Martin Cohen's Punity game engine. The absolute minimalism of that project is inspiring to me, and its self-imposed limitations feels like programming for a Game Boy.

I get that the point of handmade is to build from scratch, but often a great way to learn is to dig into other peoples code.


The point of Handmade (at least as per my interpretation) isn't to build everything yourself from scratch. It is to have an understanding of what is occurring under the hood when your program runs.

If everyone wrote everything from scratch, we wouldn't get anything done. We as programmers already spend too much time independently solving the same problems over and over again. < /rant >

I've been using Omar Cornut's ImGui to make UI for an image editor I'm working on, and I've found the source code to be very readable, and I've also picked up a number of C/C++ tricks from it. I highly recommend you take a look if you haven't already.

Sean's stb libraries are hugely awesome to work with, but they have been optimized for performance and extensibility (e.g. custom allocators and various macro-controlled options), and can be a bit formidable for newcomers to dig into.

Edited by Apoorva Joshi on

The point of Handmade (at least as per my interpretation) isn't to build everything yourself from scratch. It is to have an understanding of what is occurring under the hood when your program runs.


Ok i like that, seems like a much better definition than what i said.

I had a feeling the stb libraries were going to be mentioned, but they of course should be brought up. I was trying play with punity before martin cleaned up his codebase properly, so I'll need to give it another shot. I shot him a tweet a few days back saying he should get this setup as a handmade project.

Thanks!
Ah... Off the top of my head besides GingerBill's and the STB libraries there are no really good public examples of code. This is something we plan on tackling with Ludus (a big project a bunch of people in the handmade community are working on). As we plan on having the source code available, but not for free.
Oh cool that should be really cool to see come together. How much are you thinking of charging for source code access?
MILLIONS UPON MILLIONS OF PENNIES! SHIPPED TO DENMARK! (joke obviously)
SDL2 (https://www.libsdl.org/) is another excellent codebase. Greatly simplifies some cross-platform stuff. Fast, has very little overhead, not bloated. SDL2's codebase is cleanly laid out. There are games written entirely in SDL2 that have been ported to platforms other than the one it was written for without any changes to the code. There was a particular video that showcased this well, but I can't seem to find it...

Edit: here we go: https://youtu.be/MeMPCSqQ-34?t=1266

I guess there's few who don't know about SDL, but thought I'd throw it out there anyway.

Edited by Kyle Devir on
I think mentioning what popular codebases are good should be encouraged. Not everyone has had a chance to dig into the code and know what is good.
Here's some stuff I can think right off the top of my head.

GLFW is similar to SDL2, but much simpler functionality (no renderer): https://github.com/glfw/glfw
SDL2 and GLFW are two of my favorite libraries for figuring out platform specific bits for windows/events/input.

miniz - single file zip manipulation library: https://github.com/richgel999/miniz

c99-snprintf - single file portable implementation of snprintf function: https://github.com/weiss/c99-snprintf

c4 - pretty cool subset of C interpreter with just 4 functions (it can interpret itself) https://github.com/rswier/c4

webby - two file (h/c) tiny http webserver for game development: https://github.com/deplinenoise/webby

mongoose - two file (h/c) feature rich webserver (http, websockets, json-rpc, and more), useful for embedded environments, unfortunetaly it changed license from MIT to GPL at some point: https://github.com/cesanta/mongoose

xbyak - cool C++ header library to JIT assembly code: https://github.com/herumi/xbyak

asmjit - similar to xbyak, but bigger library: https://github.com/kobalicek/asmjit

nedtries - C and C++ header file that implements efficient in-place bitwise binary Fredkin trie algorithm (std::map/set alternative): https://github.com/ned14/nedtries

jsmn - two file (h/c) super minimalistic C json parser (actually it's more tokenizer than parser), doesn't use any dynamic memory allocations: https://github.com/zserge/jsmn

sxml - same as jsmn, but for xml files: https://github.com/capmar/sxml
Hell Yeah, tons of stuff to look at then :D!!!

I'm going to have a busy week reading code.


Has anyone had a play with BGFX, for a rendering library? I've had a play and i like what I see, but again I'm not a good enough coder to judge the codebase.
https://github.com/bkaradzic/bgfx
For basic access a very small fee. Think around $5 a month
I often look at the Quake source code (or any of the old id games really).
https://github.com/id-Software/Quake

Philip Buuck is doing a series of videos called Handmade Quake where he goes though the Quake source code and recreates the game which really interesting. https://www.youtube.com/user/philipbuuck/featured

There's also some games that use the Quake engine that have had their source released, including Jedi Outcast and Jedi Academy which are two of my favorite games.
https://github.com/grayj/Jedi-Academy
https://github.com/grayj/Jedi-Outcast
Handmade Quake is on this site actually, forgot about that.

https://hmq.handmade.network/

Edited by Matt Hartley on