4 ms·
there’s a relatively esoteric paradigm known as “literate programming” which has been around since Knuth (he wrote the book [0]) and that has some software tool
by tony_cannistra 8y ago
there’s a relatively esoteric paradigm known as “literate programming” which has been around since Knuth (he wrote the book [0]) and that has some software tools associated, of which Jupyter is a particularly web-age example.
[0]: https://en.m.wikipedia.org/wiki/Literate_programming https://en.m.wikipedia.org/wiki/Literate_programming
- tmalsburg2 8y agoLiterate programming was esoteric, true, but the concept saw a huge renaissance in academia and data science with the advent of RMarkdown¹ which for many of my colleagues is the default way of preparing technical documents. Another area in which literate programming has become hugely popular is Emacs' Org-mode ecosystem which has fantastic support in the form of Org Babel². I use literate programming for almost everything. Research papers, tech reports, notes, experiments, teaching materials, letters, student evaluations, and so on. It's completely ridiculous how useful it is once you get the hang of it and make it your default document type. [1] https://rmarkdown.rstudio.com/ https://rmarkdown.rstudio.com/ [2] https://orgmode.org/worg/org-contrib/babel/ https://orgmode.org/worg/org-contrib/babel/
- TeMPOraL 8y agoI'm still not sold on writing complete program this way (I did try, with various level of success), but even partially-literate approach is ridiculously convenient if you happen to live in Emacs. I do my task management and note-taking in Org-mode, and recently I found myself doing things like jotting in the middle of my notes[0]: #+BEGIN_SRC http GET address.to.api:123/sth #+END_SRC and tapping CTRL+C twice, to get the actual response of the API I was debugging. Or, the other day I was making notes about gravity batteries, and was wondering how efficient is one startup's solution. I briefly thought about firing up Jupyter, but then simply wrote the following[1]: these guys power a LED (or three?) with a 0.1W, generated through dropping a 12kg weight down 1.8 meters over 20 minutes. Doing some basic math on that: #+BEGIN_SRC elisp (let* ((m 12) (g 9.81) (h 1.8) (_t (* 20 60)) (E (* m g h)) ; E = m*g*h (P (/ E _t)) ; P = E/t (efficiency (/ 0.1 P)) ; efficiency = Pout/Pin ) `("ideal power [W]" ,P "efficiency [1]" ,efficiency)) #+END_SRC Typing CTRL+C twice, out pops: #+RESULTS: | ideal power [W] | 0.17658000000000001 | efficiency [1] | 0.5663155510250312 | (which is automatically rendered as an org-mode table I can operate on, or even reference in other code snippets). Point being, note-taking in org mode makes it ridiculously easy to invoke any programming language you hooked up to Emacs without breaking your flow, and you get to edit the code in the mode specific to that programming language - so everything from autocomplete to linters work. I know Emacs is niche, but I can't recommend it enough. -- [0] - BEGIN/END_SRC block is under convenient autocomplete of "<s TAB". [1] - this is a real note, so if I got the physics wrong, I just made a fool of myself publicly -.-