• Stars
    star
    110
  • Rank 314,908 (Top 7 %)
  • Language
  • Created over 9 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A catalog of code worth reading

code-canon

You've probably seen calls for recommendations for good code to read and study. When this comes up on aggregators and stackoveflow, the result is pretty scattershot. Here is my own list, with only code I've read enough of to judge as in some way interesting.

Canonizing my personal recommendations is a little fraught, since I know some of the authors and potential authors. Don't take an omission as much of a signal; we all have finite time, biases, and different goals and tastes. I'd love to get suggestions, by pull request or otherwise.

Hopefully I'll add critical remarks, though I'm lazy.

Counterpoint: other lists, commentary, and tips

(An exception to the my-own-judgement rule.)

Peter Norvig

(I've contributed in small ways to several of these.)

Kragen Sitaker

Barbara Liskov and John Guttag, Abstraction and Specification in Program Development

It's hard to find good models of contracts and invariants driving and documenting code. This book with its examples taught me this.

Kernighan and Pike, The Unix Programming Environment.

So old-school it’s practically prehistoric, but the best book I know on the philosophy of Unix (with the possible exception of ESR’s The Art of Unix Programming, but that book has hardly any code, and thus is not so relevant to this question). The longest example is a small programming language with a compiler and VM interpreter developed in stages. http://cm.bell-labs.com/cm/cs/upe/

Kernighan and Plauger, Software Tools in Pascal.

Develops variants of a bunch of classic Unix tools, back before Unix became popular. http://www.amazon.com/Software-Tools-Pascal-Brian-Kernighan/dp/0201103427

Aho, Weinberger, Kernighan, The AWK Programming Language.

Many surprisingly interesting and compact examples. (E.g. a ‘make’ in half a page of code, an assembler and interpreter, a command-line database system, etc., etc., etc.) Code is available for download, but it’s best with the book, which is unfortunately ridiculously expensive these days. http://cm.bell-labs.com/cm/cs/awkbook/

Chris Okasaki, Purely Functional Data Structures.

Just what it says, with code in Haskell and ML. Not your parent’s data-structures book. http://www.cs.cmu.edu/~rwh/theses/okasaki.pdf

Donald Knuth, Literate Programming.

Has a few extended examples doing neat things. http://www-cs-faculty.stanford.edu/~knuth/lp.html

Mark Jason Dominus, Higher-Order Perl.

Ideas from the functional-programming world brought to Perl. The longest example is a constraint-based domain-specific language for diagram drawing. http://hop.perl.plover.com/

James F. Gimpel, Algorithms in Snobol4.

An overlooked classic with lots of fun code in a terribly obsolete programming language. Emphasis on string processing. Hard to find. The code is available online but probably hard to get much benefit from without the book. http://www.amazon.com/dp/0471302139/

Paul Graham, On Lisp.

Fine examples of the power of Lisp. The best chapters on macros I’ve seen anywhere. His programming style is not so much to my taste (favoring too-abbreviated global names, anaphoric macros, etc.) but still interesting and educational.

http://www.paulgraham.com/onlisp.html

Peter Seibel, Practical Common Lisp

http://en.wikipedia.org/wiki/Practical_Common_Lisp

Richard O'Keefe, The Craft of Prolog.

A bit of a grab-bag but a tasteful exposition of ideas and examples relevant to functional programming as well as Prolog. O'Keefe is entertainingly opinionated, not unlike Snape at Hogwarts when a student screws up. http://www.amazon.com/dp/0262150395/

Leon Sterling (editor), The Practice of Prolog.

A collection of articles, each an extended example, with code, of making Prolog do something interesting, usually something AI-ish. Chapters by O'Keefe, Chris Mellish, Sterling, others. http://www.amazon.com/dp/0262193019/

P.J. Plauger, The Standard C Library.

A full, portable, clean, reasonably efficient implementation of the (C89) standard library, with discussion of the design tradeoffs. Includes the relevant pages from the standard. http://www.amazon.com/dp/0131315099/

Edsger Dijkstra, A Discipline of Programming.

Lots of small but nontrivial examples of developing a program and its proof of correctness hand-in-hand. http://www.amazon.com/dp/013215871X/

https://github.com/rswier

I've read https://github.com/rswier/c4 but not https://github.com/rswier/swieros

Others' suggestions, or otherwise pending

More Repositories

1

requestAnimationFrame

Polyfill for requestAnimationFrame/cancelAnimationFrame
JavaScript
273
star
2

awklisp

A Lisp interpreter written in Awk.
Awk
254
star
3

ichbins

A tiny self-hosting Lisp-to-C compiler
C
234
star
4

expr

Evaluate mathematical expressions in Java
Java
97
star
5

halp

Run programs in the Emacs buffer holding their source, seeing their output inline, interactively.
Python
91
star
6

languagetoys

Random fun with statistical language models.
Python
65
star
7

wren

Language with a bytecode compiler that can run on computers with only a few kB of RAM.
C
60
star
8

parson

Yet another PEG parser combinator library and DSL
Python
58
star
9

cant

A programming argot
Scheme
58
star
10

tush

Literate testing for command-line programs
Shell
56
star
11

bytebeat

Coded music in HTML5
JavaScript
54
star
12

sketchbook

Smallish programs written to learn something.
Python
49
star
13

tailbiter

Self-compiling compiler of a Python subset. Just enough Python to Python in Python.
Python
46
star
14

peglet

Robinson Crusoe's parsing library
Python
38
star
15

pythological

A MiniKanren in Python
Python
36
star
16

regexercise

Exercises in implementing regular-expression search
Python
32
star
17

spaced-out

Vocab drill using parallel corpora, plus classic spaced-repetition drill
Python
30
star
18

tusl

A scripting language for extending C programs; recognizably Forth-like, but definitely not Forth.
C
19
star
19

amphigory

Metrical rhyming verse in Javascript
JavaScript
18
star
20

miasma

An x86 machine-code toolkit
Scheme
15
star
21

aima-python-mirror

Mirror of the aima-python svn repository
Python
15
star
22

mccarthy-to-bryant

Propositional logic in terms of if-then-else
Python
15
star
23

cogen

Compiler generator (3rd Futamura projection) for first-order Scheme
Scheme
14
star
24

ung

Pointless reimplementation of Unix userland tools.
C
13
star
25

mixal

Assembler and emulator for Knuth's MIX machine
13
star
26

idel

A low-level virtual machine for mobile code
C
12
star
27

minilight.js

A MiniLight Javascript port
JavaScript
12
star
28

tinyhiss

A Smalltalk in Python
Python
12
star
29

vicissicalc

A spreadsheet program for my own amusement.
C
12
star
30

toot

A small language to demo turning an interpreter into a compiler
Python
11
star
31

consp

A capability-secure Scheme dialect
Scheme
11
star
32

elv

A very basic Lisp + Erlang-style processes, on a virtual machine
C
11
star
33

logsim

A digital logic simulator to work through the book The Elements of Computing Systems.
Scilab
11
star
34

sturm

Simpleminded terminal interface
Python
10
star
35

ake

A 'make' program in one little Awk file
JavaScript
10
star
36

quick-study

To explore tracing JIT compilers and explanation-based learning
Python
8
star
37

math-toys

HTML5 canvas widgets for exploring complex arithmetic
JavaScript
8
star
38

columnize

View strings, Python dir() output in particular, in nice columns.
Python
8
star
39

squerm

Prototype of a concurrent Scheme dialect
Python
7
star
40

hmph

Prototype of a system for user-programmable websites; a kind of mishmash of Smalltalk, Boxer, E, and wikis.
Python
7
star
41

versecop

Match text against verse forms, like: is this line in iambic pentameter?
Python
7
star
42

transparent-dilemma

The Prisoner's Dilemma for agents that see each other's source code.
Scheme
7
star
43

req

A rewrite-rule language
C
6
star
44

superbench

A cross-language shootout, starting with a circuit superoptimizer
C
6
star
45

Bleaty-the-Lamb

A superoptimizer for the lambda calculus
Scheme
6
star
46

peckcheck

Randomized testing library for Python; like a subset of Haskell's QuickCheck.
Python
6
star
47

spellmell

A quickie spelling corrector
Python
5
star
48

selfcentered

A self-centered compiler
Scheme
5
star
49

circuitexpress

Secret project 42A
Python
5
star
50

rebabbage

Design studies for a mechanical computer
Python
5
star
51

escheme

A Scheme dialect built on and interoperable with Emacs Lisp. Why, I dunno -- for the hell of it?
Emacs Lisp
5
star
52

goobergram

A Python rewrite of Mark Jason Dominus's linogram language. Unfinished.
Python
5
star
53

js-playground

Stuff I write to learn Javascript
JavaScript
5
star
54

unitcalc

Calculator with units.
Python
5
star
55

sniki

A semantic-network wiki
Python
4
star
56

traitor

My translations to English of public-domain works
4
star
57

alliterate

Compute alliteration scores for English text
Python
4
star
58

regexercise_solutions

My answers to the regexercise problems
Python
4
star
59

unmush

Take wordsmushedtogether and guess how to split them back into individual words.
Python
4
star
60

dole

The Doe text editor rewritten in Lua
Lua
4
star
61

greek_to_me

Guess the language of a text using n-gram models
Python
4
star
62

tusdl

SDL binding for Tusl, plus some programs using it: two genetic picture-breeders, A-life simulations, etc.
C
4
star
63

clickcheck

Randomized testing library for Common Lisp; like a subset of Haskell's QuickCheck.
Common Lisp
3
star
64

icfp09

Tackling the 2009 ICFP contest
Python
3
star
65

yajson

JSON library for Python, generating both pure-Python and C-extension versions from a common spec.
Python
3
star
66

wirth-a-risc

Wirth's RISC machine in software
C
3
star
67

toy-compiler

A compiler for a toy language, in Standard ML
Standard ML
3
star
68

lurx

Regular expression matching in Lua
Lua
2
star
69

indent

indentational syntax for Scheme (ancient)
Scheme
2
star
70

github-contest-2009

Just for fun
Python
2
star
71

one-day-i-will-play-chess

hackety hack hack hack
Python
2
star
72

bookdraft

Literate programs demonstrating self-reliance
2
star
73

squee

A sketchy language for a blog post or something
Python
2
star
74

pother

Another toy programming language imitating bits of E
Python
2
star
75

unreal

Van Wyk's IDEAL picture language redone in Python
Python
2
star
76

wason

Webification of http://lesswrong.com/lw/g2/positive_bias_test_c_program
Python
2
star
77

chispa

Indexed text search in <500lines
Python
2
star
78

cs191

Biomolecular Computation classwork
Python
1
star
79

peglet.js

Adaptable parsing
JavaScript
1
star
80

radiation

Mutagens for everyone!
JavaScript
1
star
81

bicicleta.js

Kragen's Bicicleta now all in Javascript
JavaScript
1
star
82

hello-canvas

Like "hello, world', but for HTML5 canvas hacking.
JavaScript
1
star
83

ml-fumbling

Phlogisticosh. Rhomothriglyph. Floof.
Python
1
star
84

quarters

more meta
Python
1
star
85

teeny

A Scheme subset with reflective access to Java. A relic of the 90s.
C++
1
star
86

codingquizzes

nothing here but my attempts at some coding quizzes
Python
1
star
87

bicicleta.py

Another slow prototype of Kragen's Bicicleta
Python
1
star