Hi all; I'd like to use Literate programming in Vi...
# thinking-together
h
Hi all; I'd like to use Literate programming in Visual Studio Code for js. Anyone doing that? E.g Plug-in recommendations would be appreciated. Ideally I'm looking for something with a subset of similar features to what [@ibdknox] Chris Granger did for Eve [

demo

]; Free source code ordering, ability to add some interactivity using the code itself etc, mix markdown and js. That should be pretty doable, don't you think? Thing is I've got a perfect use-case for literate programming in a current project; not much code, just a few hundred LOC, but conceptually heavy. So I'm not in need of any deep magic, it's enough if Literate Programming would: (1) help me understand my own underlying model. (2) Produce something useful to others wanting to understand the code/underlying model later (without extra work on my side 🙂 ). That would be great! Recommendations/ideas/experiences are super welcome!
t
Observablehq.com is literate programming but not in VSCode. Its online in the browser, which for me is better (Chrome dev tools). There is an attempt at porting to vscode: https://marketplace.visualstudio.com/items?itemName=GordonSmith.observable-js but I do not know how well that works.
👍 3
h
Wow, thanks @Tom Larkworthy! That sounds great! I'll check it out; What are your experiences with LP; For what projects do you find it useful etc?
t
everything
👍 2
With documentation next to code, I spend a good chunk of time rewriting the documentation sort before every coding session. It improves my documentation a lot (many revisions), but keeps clarifying to myself what the purpose of the contained code is. With LP, you can't help but read the opening paragraph every time. so you keep refining it and its gets better, and you code backs up that mission.
👍 2
❤️ 4
k
Probably not relevant to you, but I use an unconventional form of literate programming that includes tests and an explicit history of the project: http://akkartik.name/post/wart-layers. I think LP is awesome, and there's wide open spaces for making it even more awesome.
👍 6
w
All my comments are war stories.
😆 2
Only serious. Latest comments...
Copy code
/** To preserve browser undo/redo stack, patch StreamActions.replace to modify DOM without moving input[type=text] elements. **/
And...
Copy code
const missing = []; // collect since removing during iteration breaks iteration.
And...
Copy code
// Reconnect unchanged controller, more direct than DOM manipulation.  For example, removing and adding the data-controller attribute will cause an animation artifact.
k
Reminds me of Notes on the Synthesis of Form, with its focus on "misfits." For every design choice, say what you don't want to happen.
🤔 1
t
In literate programming, test cases can become part of documentation. "When you do X, Y will happen, e.g. <ACTUAL EXECUTED CODE WITH ASSERTION AND THE ABILITY FOR THE READER TO EDIT>" I have a reactive unit testing library for Observablehq (@tomlarkworthy/testing). Observable has in built version history so you don;t get to add "commit description", but for things like major releases I write a change log entry in prose as part of the notebook text.
❤️ 3
This application notebook has some tests in it. When you say LP I think linear programming because of this notebook, lol. Its LP LP https://observablehq.com/@tomlarkworthy/mip
💡 2
h
Hey, Kartik Agaram, Your approach using layers both was really helpful to me! It made me realize that it would be simpler if I solve a small clean subset of the whole thing in a first version, and then add one thing at a time. Since I’m learning/discovering how things should be work while writing the code, it is really helpful to be able to go back and look at a simpler version, complete with examples and explanations, and then just focus on understanding the diff 🙂 . As an aside, I couldn’t really call it
layers
since that is the name of the fundamental abstraction i my project 🙂; I tried with
levels
but it was too similar; couldn’t keep them clearly apart in my mind, so for now I just use
chapters
; that reminds me that I can look at it like a writing project, and keep nibbling on it in the spirit of “Write now” by Harold Thimbleby.
🙂 1
❤️ 1