7 ms·
Just like you read the classics in literature, I think it would be interesting to read some of the classic codebases. They should fit the following criteria: -
by fasterik 3y ago
Just like you read the classics in literature, I think it would be interesting to read some of the classic codebases. They should fit the following criteria:
- The project was highly successful or influential
- Freely available source code
- Ideally the bulk of the project was written by one person
So far my list includes Linux, the John Carmack id releases (wolf3d, DOOM, Quake), SQLite, and vim. Any others I'm missing?
- ansbalin 3y agoThe Apollo guidance computer source code? https://github.com/virtualagc/virtualagc https://github.com/virtualagc/virtualagc
- fasterik 3y agoVery cool. Unfortunately it's probably not very relevant to current programming practice, but it definitely fits the bill for historical impact.
- nurettin 3y agohttps://github.com/virtualagc/virtualagc/blob/master/Solarium055/PINBALL_GAME__BUTTONS_AND_LIGHTS.agc https://github.com/virtualagc/virtualagc/blob/master/Solariu...
- School-Cotton 3y agoThe original releases of gcc and GNU emacs both fit all your criteria.
- pseudostem 3y agoI am not a programmer (yet). I am an openBSD fanboy. I've read stories of people reading the code and raving about the quality. It does tick 2 of the checkboxes you mentioned (not just one person). Does this qualify?
- fasterik 3y agoYes, I think so. Being written by one person isn't a hard requirement, it's just that I feel like you get a better sense of programming style and someone's approach to problem solving when you read code that hasn't been touched by too many people. Projects with a maintainer who strictly enforces code style and quality would still fit the description. From what I've heard, OpenBSD falls under this category. I'll add it to my list.
- sobolopq 3y agoIf people are interested in looking at Unix kernel implementations: Open Solaris code is out there, too. Now, i haven't looked at it myself (not a kernel hacker) and it's more like the exact opposite of a one person effort, but i heard praises about its alleged code quality more than once. So it might be educative (as far as the design of a commercial Unix kernel goes).
- kramerger 3y agoCan confirm. I needed to learn how a very specific OS thing worked and I read the code from Linux, openbsd, L4, hurd, minix, and a few other projects. The openBSD kernel code was easiest to follow because it favored simplicity over all other things (improved security was just a byproduct). For the record, the microkernels where hardest to follow despite having tons of books and a few experts nearby. But that's a whole different discussion
- philistine 3y agoBBedit ?
- MikeTheGreat 3y agoThat's not open source, is it? I feel like we can be more (or less) flexible about the 'impact' and 'single author' criteria, but we _definitely_ need to be able to see the source :)
- malkosta 3y agoRedis...
- pbaam 3y agoLua's codebase is also great for getting started
- yjftsjthsd-h 3y agoAssorted members of the unix and BSD family probably would qualify - research unix (at least v6, but maybe others) and 4.4bsd-lite come to mind. Maybe minix.
- mananaysiempre 3y agoThose aren’t necessarily written as people would do it today, but Knuth’s literate sources for TeX[1] and METAFONT[2] are explicitly meant for reading. The literate program family also includes LCC[3], but A retargetable C compiler is a book that you’d need to buy; and PBRT[4], but Physically based rendering is more exposition than program (even if the program is a perfectly good one). The source for Unix V6[5] with the accompanying commentary by Lions is probably as much of a classic as it’s possible to get. And as an eccentric choice in a similar format, may I suggest cmForth[6], perhaps paired with Footsteps in an empty valley[7]? Also, though this is not precisely what you’re asking for, The architecture of open-source applications and its sequels[8] have the original designers’ reflections on some well-known codebases. [1] http://mirrors.ctan.org/info/knuth-pdf/tex/tex.pdf http://mirrors.ctan.org/info/knuth-pdf/tex/tex.pdf [2] http://mirrors.ctan.org/info/knuth-pdf/mf/mf.pdf http://mirrors.ctan.org/info/knuth-pdf/mf/mf.pdf [3] https://github.com/drh/lcc https://github.com/drh/lcc [4] https://pbr-book.org/ https://pbr-book.org/ [5] http://v6.cuzuco.com/ http://v6.cuzuco.com/ [6] https://github.com/ForthHub/cmFORTH/blob/combined/cmforth.fth https://github.com/ForthHub/cmFORTH/blob/combined/cmforth.ft... [7] http://forth.org/OffeteStore/4001-footstepsFinal.pdf http://forth.org/OffeteStore/4001-footstepsFinal.pdf [8] https://aosabook.org/ https://aosabook.org/
- bear8642 3y ago> may I suggest cmForth[6] Hmm, not a forth I've come across before - enjoyed reading JonesForth though.
- johndoe0815 3y agoI can also recommend Niklaus Wirth's "Project Oberon" - not quite literate programming, but extremely well explained code examples and data structures of the Oberon OS/language/UI system: http://www.projectoberon.net http://www.projectoberon.net Wirth's "Compiler Construction" is very concise and written in a similar way: https://people.inf.ethz.ch/wirth/CompilerConstruction/ https://people.inf.ethz.ch/wirth/CompilerConstruction/ - he manages to describe a complete compiler for an Oberon subset (earlier versions of the book used PASCAL) in a bit more than 100 pages.
- apples_oranges 3y agoI studied assembly graphics programming on the Amiga 500 and had a good time
- quickthrower2 3y agoFairly old Glasgow Haskell Compiler: https://github.com/ghc/ghc/commit/e7d21ee4f8ac907665a7e170c71d59e13a01da09 https://github.com/ghc/ghc/commit/e7d21ee4f8ac907665a7e170c7... Bitcoin? Redis? Coreutils?
- mysterydip 3y ago(soon, for #1 I hope): serenityOS and/or ladybird browser
- mtlmtlmtlmtl 3y agoStockfish is a good one. Though the original codebase was called glaurung or something like that. Written mostly by one person or a small handful(the original anyway), I think. Obviously successful, wildly influential in its niche, and the code is open source. Though honestly if you were gonna read a chess engine, might as well read modern Stockfish. You'll learn a lot about squeezing out every last cpu cycle and byte of memory, as well as parallelism in a non- "embarassingly parallel" problem domain. I recommend starting with the transposition table(ttable.cpp), since it's very self-contained. GNU Emacs also comes to mind I suppose.
- fasterik 3y agoYeah, chess engines are a good call. They're often relatively small and self-contained, and feature a lot of good programming tricks and optimizations. I have read some of the Stockfish code, but if were going for something more "classic" I might try to dig into GNU Chess, Fruit, or Crafty.
- christophilus 3y agoRedis is a great codebase. Very readable, probably even for someone unfamiliar with C.
- stevekemp 3y agoOf course Redis was originally written in TCL: https://gist.github.com/antirez/6ca04dd191bdb82aad9fb241013e88a8 https://gist.github.com/antirez/6ca04dd191bdb82aad9fb241013e...
- js2 3y agoGit's first commit: https://github.com/git/git/tree/e83c5163316f89bfbde7d9ab23ca2e25604af290 https://github.com/git/git/tree/e83c5163316f89bfbde7d9ab23ca...
- Cloudef 3y agoInteresting how little there actually is
- barefootcoder 3y agoFunny, if not helpful, error message: pw = getpwuid(getuid()); if (!pw) usage("You don't exist. Go away!"); I find it interesting that originally each command was a separate executable.
- 4m1rk 3y agoThey could search it in the source so uniqueness was enough.
- js2 3y ago> I find it interesting that originally each command was a separate executable. That's actually still the case. `git` is just a wrapper that when called as `git <command>` looks for `git-<command>` under `libexec/git-core/`. You can add any command named `git-foo` into your PATH and then run it with `git foo`. For example, I have `git-gsr` which is a simple shell script that does a global search and replace in a git repo. I run it as `git gsr <old> <new>`
- paulddraper 3y agoPostgreSQL
- fortran77 3y ago"vi" (Bill Joy's) not "vim"
- mst 3y agoHaving hacked on that codebase (the heirloom-vi project has replaced my personal ex-vi fork for my own use since) the heavy use of globals and assorted trickery means it's not the easiest thing to read. For a simple but really rather elegant piece of code, I very much enjoyed reading the sources to abduco a while back.
- Zambyte 3y agoeval[0]. Originally written by John McCarthy to define LISP, it has had massive influence over the implementation of all interpreted and dynamic languages. [0]: https://web.archive.org/web/20130319041327/http://www-formal.stanford.edu/jmc/recursive/node3.html https://web.archive.org/web/20130319041327/http://www-formal... - this is a link directly to the page that has eval on it, but the rest of the paper leading up to it is important to really understand what's going on.
- kazinator 3y agoMacCarthy described EVAL as a theoretical entity; it was Steve Russel who said he would code it. MacCarthy was surprised and said that Russel is misunderstanding it; it's just a theoretical description, not code. But Russel basically hand-translated the calls into assembly code and got an interpreter out of it. An interpreter written in Lisp cannot be executed if you don't already have an existing interpreter to run it. The key insight that we can describe the interpreter in Lisp, and then somehow compile it into code belongs to Russel. Eventually it became possible to do that by machine: when you have a Lisp compiler, the Lisp-in-Lisp interpreter can be compiled by machine rather than by hand.
- Dalewyn 3y ago>Any others I'm missing? I would suggest MS-DOS: https://github.com/microsoft/MS-DOS https://github.com/microsoft/MS-DOS
- yla92 3y agoWhile I was reading Julia Evan's "Behind "Hello World"[0] on Linux, I had some fun digging up the zsh[1] source code. Granted, I needed some help from Cody AI[2] and even wrote some notes from my learning https://blog.yelinaung.com/posts/behind-hello-world-on-linux-notes/ https://blog.yelinaung.com/posts/behind-hello-world-on-linux... [0]: https://jvns.ca/blog/2023/08/03/behind--hello-world https://jvns.ca/blog/2023/08/03/behind--hello-world [1]: https://github.com/zsh-users/zsh https://github.com/zsh-users/zsh [2]: https://docs.sourcegraph.com/cody https://docs.sourcegraph.com/cody
- bboreham 3y agoUNIX (6th edition): https://freecomputerbooks.com/Lions-Commentary-on-Unix-6th-Edition.html https://freecomputerbooks.com/Lions-Commentary-on-Unix-6th-E...
- reassembled 3y agoI used to read the OBS classic code base before it was replaced by OBS Studio. The original OBS was monumental when it came out. Yes, it was a Windows-only code base, with the GUI coded in straight Win32, and didn’t support the extensive array of sources that OBS Studio now does. But it opened instantly, and had the best D3D and OpenGL capture performance available. To my mind OBS Classic single-handedly boosted Twitch streaming to the stratosphere. This happened despite existing and new competition in live streaming apps (primarily Wirecast and XSplit). OBS Classic was just that good for its time. OBS Classic even enabled shared texture capture of Direct3D9 contexts, via a hack to d3d9.dll which had to be maintained for every new major Windows update that came out. OBS Studio carries the torch with a much cleaner cross-platform core library written in C, and better performance and stability, which itself is an achievement. Since OBS Classic is now gone, I’d recommended anyone interested in programming video, audio and cross platform native apps to read through the current OBS Studio code base on GitHub.
- mdp2021 3y agoObvious reply, but don't forget e.g. Andrew Tanenbaum's Minix - some code was made exactly for educational purpose. (There should be a cone for that: classic codebases for production and classic codebases for education.)
- stevefan1999 3y agoTiny C Compiler
- lioeters 3y agoI was going to say, the list should include something by Fabrice Bellard. Tiny C Compiler is one. https://bellard.org/tcc/ https://bellard.org/tcc/ I was thinking, maybe first version/commit of QEMU would be interesting to read.
- wkjagt 3y agoWozmon, the ROM on the Apple 1 that fit in 256 bytes. Ben Eater did a good video (1) recently going through the 6502 assembly. (1) https://youtu.be/SpG8rgI7Hec https://youtu.be/SpG8rgI7Hec
- jhasse 3y agozlib: https://github.com/madler/zlib https://github.com/madler/zlib
- cmdrk 3y agoNot a single author, but the Erlang parts of the Erlang source code are quite readable. (I haven't looked at the C parts)
- phendrenad2 3y agoEarly versions of programming languages, like Ruby.
- afr0ck 3y agoThe Amoeba distributed operating systems, from Andrew Tanenbaum. The distribution also includes Amake, a parallel version of Make. https://archiveos.org/amoeba/ https://archiveos.org/amoeba/