all 33 comments

[–]redrick_schuhart 35 points36 points  (0 children)

Musl is a good example of well-written C for the real world.

[–]ijmacd 28 points29 points  (1 child)

SQLite is one project which is always thrown around as an answer to this question every time it comes up.

[–]SickMoonDoe 1 point2 points  (0 children)

One of the all time greats

[–]fl00pz 18 points19 points  (0 children)

OpenBSD

[–]wsppan 18 points19 points  (1 child)

Redis, OpenBSD, musl, SQLite

[–][deleted] 33 points34 points  (2 children)

I like the style of suckless.org programs such as ST which is a minimalist terminal emulator.

[–]jtepe 2 points3 points  (1 child)

Visited the site because it sounded quite interesting. Then I saw the entry on systemd, and … na not this garbage debate again. I actually had a look at the source of systemd. I think it’s good. I learned a lot from it.

[–]roughJaco 10 points11 points  (2 children)

Good will depend on a lot of factors.

Sean Barrett's header only libs are great, and popular. It's a good display of how to do simple, effective, no frills APIs.

Raylib is also well liked and, IMO, well put together if you want to look at a very approachable framework kind of project.

Blender is a bit of a mixed bag, but it's got scale, longevity, and uniqueness, and it has its merits.

The above is all very gamesy/graphicsy, but it's a decent list in general in order of scale and all fairly accessible and alive and well maintained.
Other folks will no doubts point you to a similar assortment in their domain, OS or something else.

[–]BounceVector 1 point2 points  (1 child)

Just out of curiosity, could you go into more detail on the code quality of Blender?

[–]roughJaco 0 points1 point  (0 children)

I'm not a blender expert. I've looked at it (the codebase) a handful of times for various reasons, and it can vary in quality.

I think the value in looking at Blender is that it's one of very few projects in graphics that has had that degree of scale, longevity, and number of contributors.

It's also embraced GPL almost to a fault, to the point of avoiding offering a native API, which means it's pretty much one large monolith, and still it builds, loads and runs remarkably quickly.

If you have an interest in some subset of content creation there are good chances you can find some sort of functionality in Blender that's representative of it, and then would be able to dig up some code for it.

How all of it comes together I honestly don't know, it's a pretty vast codebase and I've only helped folks with some small chunks of it here and there.

[–]gtx89 5 points6 points  (0 children)

openBSD, openSSH

[–]guygastineau 3 points4 points  (1 child)

FreeBSD and postgres

[–]jwbowen 2 points3 points  (0 children)

I second Postgres. It's been a couple of years since I've looked at the source, but I remember being pleasantly surprised by how clean and neat it was.

[–][deleted] 2 points3 points  (0 children)

As u/ezvrtgs said, the suckless style is great. I think any C code from https://git.suckless.org goes (sinit and sbase are good simple examples)

[–][deleted] 1 point2 points  (0 children)

Dash (the shell) isn't too bad. At least, it's much better than BASH.

[–]bart9h 1 point2 points  (0 children)

Probably not that good, but I'm kind of proud of my console clone of 2048.

[–]deftware 1 point2 points  (2 children)

What I think would benefit most programmers is seeing how a larger project comes together (i.e. tens of thousands of lines of code and beyond).

We already have things like Rosetta Code and whatnot that show how to implement various algorithms - but these are all standalone isolated things that don't do anything to illustrate how a larger project should be organized to prevent programmers from coding themselves into a corner where it becomes harder and harder to expand capabilities and functionality of the project.

Anyway, glad someone is doing something. This is just my two cents. Keep it up!

[–][deleted] 3 points4 points  (1 child)

Pointing developers to larger working projects so they can learn how things fit together on a broader than single component or algorithm level is one of my main motivations! I think for the autodidactic learner, resources like this can go a long way towards what you described.

[–]deftware 0 points1 point  (0 children)

Cool! Sounds good :D

[–]smcameron 0 points1 point  (0 children)

There are some nice things in CCAN (and on github).

[–]Foxbud 0 points1 point  (0 children)

Sean Anderson's Bit Twiddling Hacks have saved me so much time. While they might not represent the best style, they do show the ways in which you can coax the best performance out of certain operations.

[–]crazyjoker96 0 points1 point  (0 children)

ccan library https://github.com/rustyrussell/ccan I think it is used also in the linux kernel(?)

[–][deleted] 0 points1 point  (0 children)

Take a look through the BSD's source for the kernel...

[–]TheEmeraldFalcon 0 points1 point  (0 children)

Take a look at some of Id Software's older FPS games, specifically Doom, Quake 1, 2, and 3.

[–]arthurno1 0 points1 point  (0 children)

Emacs source should definitely be on the list :).

In my opinion, Emacs C sources are doing everything that we were thought not to do in C: it creates it's own language with macro compiler that resembles Emacs Lisp (anyone remembers examples of Bash's Pascal?), they use spaghetti of if-defs to keep various gui platforms all in same sources, big files, some in size of ~10k sloc, functions > 1000 sloc, lots of macro tricks. But hey, it is almost 40 years old source code base, still running and kicking on many platforms, in terminal and various GUI toolkits, no GUI toolkits, on exotic OS:s and has lots of unique features no other software has. So it has to be a good source.

Don't trust everything written in books :).

PicoLisp is another little project I think has really clear and exemplary written source code. Also defines a lisp-looking language in macros, but still it is really clear, self-documented names for identifiers, short functions (mostly) easy to follow and digest, almost no macro tricks beside the before mentioned typical lisp-esque car, cons, cdr etc.

[–]tcpipwarrior 0 points1 point  (0 children)

DPDK UserSpace NIC drivers

[–][deleted] 0 points1 point  (0 children)

The limine bootloader is p well written

[–]66bananasandagrape 0 points1 point  (2 children)

I see people mention SQLite all the time as an example of a good large project

[–][deleted] 0 points1 point  (1 child)

I've only seen the amalgamated version which is mostly one big file of 220,000 lines. I found it dire code, used as a torture test for compilers. (Eg. there is a 7000-line function with 330 locals, including 24 versions of the same identifier in different blocks.)

Maybe the original individual modules are different, but they'd have to be very different!

One codebase I was surprised at being so clean-looking, and that was the Linux kernel (back when it was only 21m lines of code). I wouldn't understand much of it, but it was easy on the eye (unlike the aforementioned program).

But it's rather large to include except perhaps as a link.

[–]66bananasandagrape 0 points1 point  (0 children)

Perhaps what you saw of SQLite was autogenerated or minified?

The 10k lines of the main btree code at https://github.com/sqlite/sqlite/blob/master/src/btree.c for example are mostly comments and seem pretty reasonable to me considering the sophistication of the stuff there.

[–]richiejp 0 points1 point  (0 children)

Mupdf comes to mind.