News for hackers. Stuff that matters.
Re:To become a good C programmer (2011) by yesenadam on Friday February 14, 2020 @09:49AM (#22326981)
This is a great list of books - at least, I found the same ones were the most excellent. Also I really learnt a lot from 21st Century C (The author here said they wanted to stick to C89, which is fair enough.)

>To read great C code will help tremendously.

But then he just gives examples of games I don't know and am not really interested in. Anyone know some non-game C that is, I suppose, well-known and wonderfully-written?

Also, am learning about writing APIs, any good books or talks about that people could recommend, or examples of particularly good ones in C? (I'm particularly interested in maths/graphics-type stuff.) Thanks!

Re:To become a good C programmer (2011) by jraph on Friday February 14, 2020 @12:46PM (#22328468)
I find the source code of the Netsurf browser really beautiful:

- https://netsurf-browser.org/

- https://source.netsurf-browser.org/netsurf.git/tree/

Including the sub projects, for instance:

- https://source.netsurf-browser.org/libcss.git/tree/

- https://source.netsurf-browser.org/libdom.git/tree/

It feels immediately obvious and understandable, which is quite impressive for a browser. Everything is well documented, well separated, the code is clean and seems simple, functions are small, etc. I am really impressed. I'd want to work on such code. I have never worked on it though, and I am not connected in any way to this project.

Re:To become a good C programmer (2011) by needs on Saturday February 15, 2020 @04:54PM (#22338264)
Very well written code indeed. Thanks for the links. They could make error management less bug prone by using goto, but it's definitely high quality C code nonetheless.
Re:To become a good C programmer (2011) by eindiran on Friday February 14, 2020 @04:36PM (#22330645)
The sqlite codebase is well-known for being a large, well-written C codebase:

https://github.com/sqlite/sqlite

The tests in particular are very impressive.

Some other notable C codebases: Redis, LuaJIT, FreeBSD, Memcached -->

https://github.com/antirez/redis

https://github.com/LuaDist/luajit

https://github.com/freebsd/freebsd

https://github.com/memcached/memcached

Re:To become a good C programmer (2011) by fanf2 on Friday February 14, 2020 @06:18PM (#22331423)
PostgreSQL’s source code is also really good. https://git.postgresql.org/gitweb/?p=postgresql.git;a=tree
Re:To become a good C programmer (2011) by jacquesm on Friday February 14, 2020 @06:02PM (#22331320)
Varnish and the Linux kernel should be in that list as well I think.
Re:To become a good C programmer (2011) by eindiran on Friday February 14, 2020 @06:22PM (#22331450)
Nice! Here are the links:

Varnish --> https://github.com/varnishcache/varnish-cache

Linux Kernel --> https://github.com/torvalds/linux

Re:To become a good C programmer (2011) by fabiensanglard on Friday February 14, 2020 @03:39PM (#22330169)
I recommend git source code which was pretty neat last time i checked.
Re:To become a good C programmer (2011) by rhoyerboat on Friday February 14, 2020 @03:30PM (#22330089)
recently I started working on a module for nginx and have developed a full-blown crush on the module loader and its relationship with core functionality. haven't seen anything else quite like it, in C, that is. major newb talkin'

also plan9, its nice to read some kernel code that hasn't been tortured by practical requirements for decades.

Re:To become a good C programmer (2011) by atq2119 on Friday February 14, 2020 @05:40PM (#22331125)
The core Linux kernel is well-known and mostly well-written C.
Re:To become a good C programmer (2011) by ndesaulniers on Friday February 14, 2020 @05:55PM (#22331265)
I'd say "advanced" C, not necessarily "well-written" C. There's certainly a lot of C in it, and I'd bet it's the largest open source C codebase.
Re:To become a good C programmer (2011) by cesarb on Friday February 14, 2020 @06:03PM (#22331323)
They go beyond C, it's actually C + GCC extensions. The only reason clang can compile it (in some configurations) is that they painstakingly implemented each of the GCC extensions the kernel uses (and when they were almost done, the kernel started requiring a few more).