Found in 6 comments on Hacker News
a-dub · 2021-09-17 · Original thread
this makes a lot more sense alongside the actual souce code, like in this version:

flakiness · 2021-07-09 · Original thread
I had a colleague who did some work on PDP-11 on his early career. Excited, I asked "So you were using C (language) there?" "No, it's too early" He told me, kind of dismissively. In retrospect it was obvious - The PDP11-based Unix of the Lion's Book [1] was what I had in my mind, but that was probably more like an academic pursuit than a foundational OS of commercial software.


aeyes · 2019-08-27 · Original thread
The Linux kernel is unfortunately pretty far from UNIX nowadays but if you want to understand the basic concepts behind UNIX I think Lions' Commentary on UNIX is still the best resource out there:

todd8 · 2018-01-28 · Original thread
Once upon a time, programmers didn't have IDE's, Emacs, or even text editors. I'd been programming for seven or eight years before Bill Joy created vi. Each programmer and each program had its own style.

Often, a program's layout reflected the programmer's inner thoughts as he or she worked through the creation of the code. Expressions were written like a mathematician might write, with spacing and bracketing reflecting some way of thinking about the grouping of the abstractions at hand.

This is just a random routine, written around 1975, from Niklaus Wirth's PL/0 compiler for Pascal, the programming language that he created. The indenting is wild by contemporary standards:

    procedure getch;
    begin if cc = ll then
       begin if eof(input) then
                  begin write(' program incomplete'); goto 99
          ll := 0; cc := 0; write(cx: 5,' ');
          while not eoln(input) do
             begin ll := ll+1; read(ch); write(ch); line[ll]:=ch
          writeln; readln; ll := ll + 1; line[ll] := ' ';
       cc := cc+1; ch := line[cc]
    end {getch};
Early C code too, even in the Unix kernel, was often dense and hard to understand (the kernel was under 10,000 lines back then). See Lions' Commentary [2]. Here's a small function, setfs(), line 7167 of the system 6 Unix kernel in Lion's book. In particular note the lack of indention under the for loop:

       register struct mount *p;
       register char *n1, *n2;
       for(p = &mount[0]; p < &mount[NMOUNT]; p++)
       if(p->m_bufp != NULL && p->m_dev == dev) {
               p = p->m_bufp->b_addr;
               n1 = p->s_nfree;
               n2 = p->s_ninode;
               if(n1 > 100 || n2 > 100) {
                       prdev("bad count, dev);
                       p->s_nfree = 0;
                       p->s_ninode = 0;
       panic("no fs");
It seems obvious now that standard and consistent formatting make programs easier to understand. Why did we old timers do that to ourselves? First, short programs were easier to keypunch or enter via a teletype machine. Second, we had a plenty of time to study our code. Turn around time for a compilation, from submission to printed listing, could take 30 minutes to 12 hours.


[2] John Lions, Lion's Commentary on Unix 6th Edition with Source Code.

tankenmate · 2014-11-17 · Original thread
If you are going to study this you should also read the Lion's Commentary of the Unix 6th Edition (kernel)[0]. It provides a line by line commentary of the whole kernel (minus some of the hardware specific drivers). Xv6 is a port of the edition 6 kernel to x86 (with some minor changes).


Fresh book recommendations delivered straight to your inbox every Thursday.