4 ms·
I've already seen a few places where this is compared to literate style programming. I agree and can see the comparison. However, a main draw of literate styl
by taeric 8y ago
I've already seen a few places where this is compared to literate style programming. I agree and can see the comparison. However, a main draw of literate style, as used by most tools that support it, is precisely that it lets you bend the code around a narrative. Instead, this is having to fit a narrative to the code.
As an example of what I mean, look at some places where the if chunk is as big as the else chunk. By the time you are at the else, you might have to scroll back a ton to get to what it is you are in the else of.
Now, yes, to an extent, you could split this between functions. Such that you could have:
if foo {
doSomething
} else {
doSomethingElse
}
Literate style, though, would be more akin to
if foo {
<<since we have a foo, we can ...>>
} else {
<<Without a foo, we have to ...>>
}
This is somewhat subtle, but not having to define everything in terms of functions with inputs and single outputs can free certain parts of your code to just dealing with the core logic that you care to explain.
Not a panacea, but can be quite powerful.