Fork me on GitHub
#architecture
<
2018-05-04
>
Drew Verlee20:05:54

Why do or dont you use literate programming techniques?

Alex Miller (Clojure team)20:05:37

if I can’t even keep my docstrings up to date, what hope do I have in keeping additional prose correct? really good literate programs also take exceptional care about the “story” and order inherent in the code. I have no desire to add that additional constraint on either initial dev or refactoring. that is, my perception is that there is substantial cost to using literate programming with unproven roi.

Alex Miller (Clojure team)20:05:51

so that’s my don’t :)

seancorfield20:05:24

I mostly agree with Alex. I've tried it several times and I've not found it to help with maintenance at all. On one project, I found it helped with the initial design/build: the requirements were very sparse, so I write it all out in prose and used Marginalia to generate HTML which I shared with the business team. We went back and forth over the text several times, and I slowly started converting the prose to code, but then found the prose/comments inside the code just made the code hard to read in my editor (the generated HTML was fine).

seancorfield20:05:45

Good, easy-to-read code should not need/have comments littered through it, in my opinion.

👍 4
seancorfield20:05:24

But literate programming really focuses on the text, with the code almost as a secondary concern, and that seems backwards to me.

Drew Verlee20:05:16

@alexmiller Thanks for sharing.

seancorfield20:05:44

That project has ended up with a fair bit of prose still, in "section" comments between groups of functions and in some (overly) large docstrings. And at this point, the code is drifting away from the prose and docstrings -- which makes it misleading and an obstacle to future maintenance. So simply removing the text would help at this point.

Alex Miller (Clojure team)20:05:36

I’d be more interested in tools that help explain the code that exists than write static text that tries to explain it

spfeiffer08:05:04

I thought you Cognitect guys do that in your hammocks ☺️

seancorfield20:05:53

☝️:skin-tone-2: Yes, this!

Alex Miller (Clojure team)20:05:40

I love the idea of literate programming and someone sitting down with a pipe in their library to consume the great works of code…. that just doesn’t match the reality I live in :)

john20:05:04

is there a literate programming framework in Clojure that allows you to instrument fns separately, perhaps from another ns, which live in a registry, similar to spec?

john20:05:20

So I wouldn't have to couple my doc with my code?

seancorfield20:05:41

@john That sounds like an even bigger recipe for code and docs getting out of sync!

john20:05:02

with the idea that they'd be "consumed" through some viewer

john20:05:48

@seancorfield good point. But perhaps chasing that goal is too hard. Perhaps the leverage of having a manageable doc-base would be more beneficial than having them up-to-the-minute current with the code... Not sure.

john20:05:37

And that assumes the docs could be consumed by various tools

john20:05:51

or views

seancorfield20:05:56

I've never worked anywhere that seems able to keep their documentation up-to-date with their code, making the documentation anything from useless to only mildly helpful.

seancorfield20:05:14

Only very high level documentation ever seems to remain accurate.

Drew Verlee20:05:44

Part of the problem is that its hard to define the goal.

Drew Verlee20:05:12

The reward for doing the thing were trying to do is somewhat more clear. Its not clear what there is to gain from helping people understand it. Or what would help them understand it.

john20:05:42

you don't know what they don't know they don't know 😂

Drew Verlee21:05:19

My intuition is to agree with @seancorfield @alexmiller and @john on that its hard to justify the effort. To @alexmiller’s point, and one which i have given a little thought, i think there might be an opportunity to design in such a way that your system explains itself both at the functionality level but that also tells a narrative. For example, the code is very open ended, you can pass any number of options… but a narrative would tell me which options people usually pass and show me what the normal output_ looked like. I think in order to do this, the system would need side effects to be isolated. I suspect there is nothing novel here 🙂