4 ms·
We have tools that let you examine code from various angles. There is no need to encode some "human order" in the code itself. Code should be organized in the w
by kazinator 10y ago
We have tools that let you examine code from various angles. There is no need to encode some "human order" in the code itself. Code should be organized in the way that harmonizes with the module structure and promotes maintainability, without regard for some "human order" nonsense.
Who decides what is "human order"? Humans want things in different order for different purposes. For example, business software generates all sorts of reports of different kinds from the same data.
This is wrong:
> Traditional source code, no matter how heavily commented, is presented in the order dictated by the compiler.
This is only true of one-pass, strict definition-before-use, single-module-only programming languages, like toy versions of Pascal.
In any decent language, we can take exactly the same program, and permute the order of its elements with a great deal of liberty, and present them in that order to the compiler. We can decide which functions go into which modules, and we can have those functions in different orders regardless of what calls what.
Ah, but some of the more crazy proponents of literate programming are not satisfied with that granularity. It bothers them that the individual statements of a program that are to be executed in sequence have to be presented to the compiler in that sequence: S1 ; S2.
Knuth's outlandish version, in particular, stretches the meaning of "literate" by turning code into a dog's breakfast in which functions are chopped into blocks. For compilation, these blocks are re-assembled by the "literate" processor into functions.
The result is difficult to understand. Yes, the nice explanations and presentation order may present something which makes sense. But here is the rub: I don't just want to follow the presentation of a program, I want to understand it for myself and convince myself that it is correct. For that, I need to ignore all the text, which, for all I know, only expresses the author's wishful belief about the code.