logoalt Hacker News

jcranmertoday at 7:36 PM1 replyview on HN

I mean, a virtual ISA (think PTX, LLVM IR, WASM) is going to do a better job of giving you an abstract machine than something like MMIX. Virtual registers and call arguments/return values as nary arguments rather than fixed registers give you most of what you want, and it's easy to augment it with a large slice of primitive operations that is a superset rather than subset of assembly languages.

(There's another criticism to level at pseudo-assembly language, which is that modern high-performance processors are superscalar with cache hierarchies, which makes the analysis of execution time itself difficult from the kind of first principles that Knuth is working at. I can appreciate why Knuth is working differently from the more traditional big-O notation of typical algorithms classes, but it does need to be acknowledged that it does sap the treatise of its supposedly timeless quality.)


Replies

GeorgeTirebitertoday at 9:21 PM

I take the previous point about missing MMX / Vector instructions. Presumably, that's a straightforward optimization, when code is vectorizable? That is, yes, it would be nice to have sections on vector instruction use to demonstrate some appropriate algorithms; point taken.

I think, tho, the fundamental reason is: he specs the machine. It does exactly what he says it does. No edge cases, no surprising behavior that LLVM IR or WASM might have; also, I'm sure he spec'd it to make the algorithms he implements elegant or at least more understandable.

I suspect part our views comes from the purity of Mathematics (Knuth) and the actuality of Computer Science. I'm even sympathetic to your view, because then we could verbatim copy Knuth's algos to WASM etc and run them, and we get a twofer: a deeper understanding of the algo AND a deeper understanding of the underlying V-ISA (PTX, BEAM, WASM, LLVM IR, etc).

I think the learning / understanding of the algos Knuth presents partially comes from us Playing Computer, and manually going through the code. It's that pedagogy comes first, I think.

Next time I run into Don, I'll ask him about this. 'cause you're also correct about L1...Ln caches affecting performance drastically.

(And, yes, I had wondered why Don did MMIX he didn't create a "RISC-V" before there was a RISC-V; that is, why didn't he create the Next Great RISC Machine? He said he talked with John Hennessy and Richard Sites. This was in 1990.)

Here's HN on RISC-V vs MMIX: https://news.ycombinator.com/item?id=14635361