Ask HN: Where do I find good code to read?

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • pytudes

    Python programs, usually short, of considerable difficulty, to perfect particular skills.

    Peter Norvig's Pytudes was recently posted here. I think that's some of the best code I've read, although they're only small problems and not a bigger project. Still very much worth a read, he goes through the whole problem solving through code process.

    https://github.com/norvig/pytudes

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • Refactoring-Summary

    Summary of "Refactoring: Improving the Design of Existing Code" by Martin Fowler

    I find that reading books rather than code tends to be more helpful in terms of finding good takes on what clean code is -- more specifically books on refactoring or specific language-related features (like 'Effective Java' or 'Fluent Python'). The issue with just reading code is that many times - you'll miss out on why the author chose to use the expression or abstractions which they chose to use. Reading a book at least takes you through author's thought process. For an alternative - you could always browse repositories which contain notes on refactoring as well like this one (which does a good job summarizing some of the key principles from Fowler's book on refactoring):

    https://github.com/HugoMatilla/Refactoring-Summary

  • clean-code

    Book review: A Handbook of Agile Software Craftsmanship

    This isn't exactly a repo to look at, but the book "Clean Code" is a fantastic read for learning how to write good code. It does have a lot of examples in it, and does a great job explaining everything. https://github.com/jnguyen095/clean-code/blob/master/Clean.C...

  • The-Simpsons-Hit-and-Run

    Stolen (and slightly cleaned up) version of The Simpsons: Hit & Run original source code from 2003

    I'm an F tier programmer but I think the Simpson's Hit and Run game has some really great code. Its easy to read and well organized in my opinion.

    https://github.com/Svxy/The-Simpsons-Hit-and-Run/tree/eb4b34...

  • Binaryish-Clock

    A fitbit watch face that partially displays the time in binary

    I'll shoot with two examples:

    (Tooting my own horn) A Fitbit watchface that I wrote a few years back: https://github.com/GWBasic/Binaryish-Clock

    An event/threading library for C#. I keep a fork in my Github because the original source was archived: https://github.com/GWBasic/retlang

    Note that both examples are "functionally obsolete." The Fitbit studio environment is deprecated in favor of Android Watch; and if you're using C#, you can should be using Tasks to get similar functionality to Retlang.

  • retlang

    I'll shoot with two examples:

    (Tooting my own horn) A Fitbit watchface that I wrote a few years back: https://github.com/GWBasic/Binaryish-Clock

    An event/threading library for C#. I keep a fork in my Github because the original source was archived: https://github.com/GWBasic/retlang

    Note that both examples are "functionally obsolete." The Fitbit studio environment is deprecated in favor of Android Watch; and if you're using C#, you can should be using Tasks to get similar functionality to Retlang.

  • SQLite

    Official Git mirror of the SQLite source tree

    The sqlite code base is really well done. Lots of documentation.

    https://github.com/sqlite/sqlite

  • DOOM

    DOOM Open Source Release

  • jonesforth

    Mirror of JONESFORTH

    Is there any particular language you're looking for? I've found some languages hideous until I understood them and could appreciate their respective graces. Off the top of my head the I can think of a couple.

    The first is Jones Forth (https://github.com/nornagon/jonesforth), start with jonesforth.S and move into jonesforth.f. I really enjoyed following along with it and trying my hand at making my own stack based language.

    The other is Xv6, a teaching operating system from MIT (https://pdos.csail.mit.edu/6.828/2021/xv6.html), not all the code or implementations are top notch but it shows you non-optimized versions (just because they're simple and more readable) of different concepts used in OS design.

    If you're interested in the embedded world, there is a really neat project I've been following that feels a more structured and safe (as in fault-tolerant) while still staying pretty simple (both conceptually and in the code itself): Hubris and Humility (https://hubris.oxide.computer/).

  • pocket

    Official implementation of the Pocket Network Protocol v1

    the right amount of context + easy-to-use tooling

    - Code culture; follow industry best practices and make it clear where & why you deviate

    My personal favorite one: `make todo_list`

    We use keywords (TODO, OPTIMIZE, HACK, etc…) through the codebase and make them easily searchable with make helpers.

    Ref: https://github.com/pokt-network/pocket/blob/main/Makefile#L5...

  • glib

    Read-only mirror of https://gitlab.gnome.org/GNOME/glib

    The question doesn't specify any language, so FWIW, I first learned "serious" programming by reading the sources for GNOME Glib, about 18 years ago.

    https://gitlab.gnome.org/GNOME/glib

  • dagger

    Discontinued A fast dependency injector for Android and Java. (by square)

    I learned a ton about Java and pragmatic algorithm development from reading Dagger (https://github.com/square/dagger) and porting it to C#. It's small enough that you can grok it in a reasonable amount of time, but sophisticated enough that there's a lot to learn. (Yes it's deprecated in favor of Dagger 2, but the latter is a tougher slog IMO)

    Actually most of the big Square OSS libraries are great to read - okio, okhttp, picasso.

  • clara-rules

    Forward-chaining rules in Clojure(Script)

    I've met a few young programmers who heard somewhere that object-oriented programming was bad and they want to get the enlightenment of functional programming that they've heard about. Frequently they travel from job to job like itinerant martial artists always looking for somewhere where they practice the true technique but they always seem disappointed as it is just as easy if not easier to screw up handling errors with monads than it is with exceptions and they find analogies like "a monad is like a burrito" just get them more confused.

    As for something profound I'd point you to

    https://github.com/cerner/clara-rules

    which many people will struggle with because like many other production rules engines in LISP (and many other examples of simple compilers), there is hardly any code! Contrast that to the orders of magnitude larger rules engine Drools

    https://github.com/kiegroup/drools

    which is so crazy-complicated primarily because the Drools language is Java-based so you need all sorts of things that Clara or CLIPS don't need.

  • Drools

    This repository is a fork of apache/incubator-kie-drools. Please use upstream repository for development.

    I've met a few young programmers who heard somewhere that object-oriented programming was bad and they want to get the enlightenment of functional programming that they've heard about. Frequently they travel from job to job like itinerant martial artists always looking for somewhere where they practice the true technique but they always seem disappointed as it is just as easy if not easier to screw up handling errors with monads than it is with exceptions and they find analogies like "a monad is like a burrito" just get them more confused.

    As for something profound I'd point you to

    https://github.com/cerner/clara-rules

    which many people will struggle with because like many other production rules engines in LISP (and many other examples of simple compilers), there is hardly any code! Contrast that to the orders of magnitude larger rules engine Drools

    https://github.com/kiegroup/drools

    which is so crazy-complicated primarily because the Drools language is Java-based so you need all sorts of things that Clara or CLIPS don't need.

  • kakoune

    mawww's experiment for a better code editor

  • deno

    A modern runtime for JavaScript and TypeScript.

  • deno_std

    Discontinued deno standard modules

  • sortedcontainers

    Python Sorted Container Types: Sorted List, Sorted Dict, and Sorted Set

    If you like Python, the library sortedcontainers as a clear, well documented, yet short source code that is a joy to read for a non trivial problem:

    https://github.com/grantjenks/python-sortedcontainers/blob/m...

  • sqlite

    sqlite mirror (by smparkes)

    Rust stdlib code is quite high quality although not particularly dense due to large amount of comments. Start from the docs, and click any source link: https://doc.rust-lang.org/std/vec/struct.Vec.html

    Sqlite is supposedly high quality C code: https://github.com/smparkes/sqlite

    For videos of someone (Casey Muratori) writing video game code and debugging it, Handmade Hero: https://handmadehero.org/

    A blog post about how to write code by the same author: https://caseymuratori.com/blog_0015

    For how to implement a fairly advanced type system, Typing Haskell in Haskell: https://gist.github.com/chrisdone/0075a16b32bfd4f62b7b

    But, honestly, you're probably better off writing code yourself and learning by doing.

  • beanie

    Asynchronous Python ODM for MongoDB

    I recently came across Beanie. A Python ORM for MongoDb. A pleasure to work with and integrates well with FastAPI, the tests document the code well, and at this point it’s only as complicated as it needs to be.

    https://github.com/roman-right/beanie

  • htmx

    </> htmx - high power tools for HTML

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Any tips to improve my coding abilites ?

    3 projects | /r/node | 2 Apr 2023
  • Python Code Reviews and Collaboration Best Practices and Tips

    1 project | dev.to | 30 Nov 2024
  • Using PostHog in Remix Loaders and Actions on Cloudflare Pages

    1 project | dev.to | 27 Nov 2024
  • Posthog – The single platform to analyze, test, observe, and deploy new features

    1 project | news.ycombinator.com | 18 Nov 2024
  • Open-interpreter: A natural language interface for computers

    1 project | news.ycombinator.com | 18 Nov 2024

Did you konow that C is
the 7th most popular programming language
based on number of metions?