Hacker News new | ask | show | jobs
by kragen 529 days ago
I think you mean "literate programming".

The arena allocator in Hanson's chapter 6 is an arena allocator, not a "pool allocator" in the sense that 8dcc means, which is to say, a constant-time fixed-size-block allocator. It seems that you had the same reading comprehension problem that I did.

The difference is that Hanson's arena allocator can make allocations of any size (his Arena_alloc takes an nbytes argument) and cannot deallocate individual allocations, only the entire arena (his Arena_free takes only an arena pointer as a parameter). A fixed-size-block allocator like the one we are discussing here can only make allocations of a fixed size, but can recycle them individually, not only all at once.

(If Hanson's name sounds familiar, it might be because you've read the lcc book.)

It may be worth noting that Donald Knuth also invented the font used in 8dcc's article.

1 comments

Honestly, "literary programming" does better explain how Knuth writes code.
Yes, but that name lacks the benefit of implicitly describing other approaches to programming as "illiterate".
Reading the Metafont source is pretty challenging because of all the transclusions. There's a reason why programs aren't written like journal papers.
I think we can probably do better than METAFONT with the benefit of hindsight. Unit tests would help with comprehensibility. Including example outputs, too, like Darius Bacon's "halp", or R-Markdown, Jupyter, doctest, and org-mode can do. Higher-level languages than Pascal would probably be an improvement. Maybe building up the program as a series of versions, like Kartik Agaram's idea of "layers"; I did something similar but less complete in my literate-programming system "handaxeweb". We can do decent typography on a computer monitor now, so in the worst case, we can attempt to leverage interactivity, as so-called "explorable explanations" do.

Both programs and journal papers are mostly written the way they are because of tradition, not because it's the best way we've found to write them. Two examples:

Nobody would intentionally design a programming language to make it impossible to include the kind of diagrams that illustrate this article, but most programming languages are in fact designed in such a way.

Buckminster-Fuller-style "ventilated prose" turns out to be more readable than traditional paragraph formatting in psychology experiments, which is why we use it universally in our programs. But you can't publish a paper formatted that way unless you call it a poem.

Haha, never thought about that!
Knuth did.