Hacker News new | past | comments | ask | show | jobs | submit login

I haven't got time to read all this dissertation on an interesting topic at the moment, but I was surprised to find that the relevant work of the other great "Donald" (Knuth) is not mentioned. He called it 'literate programming'. Here's a reference: https://www-cs-faculty.stanford.edu/~knuth/lp.html



I’ve known literate programming only as a way to structure programs.

What code navigation features are part of literate programming and would be appropriate for inclusion in this dissertation?


As DK puts it himself: "The main idea is to treat a program as a piece of literature, addressed to human beings rather than to a computer." I think code navigation would naturally fall out from this approach.


On the contrary, literate programming is heavily used in notebook environments (ipython, RMarkdown, Mathematica, etc) and in practice, code structured this way seems to implode once it gets above a few kloc. Narratives just don't seem to do a good job of hierarchy / modularization / separation of responsiblity, which is the key to programming in the large.


> literate programming is heavily used in notebook environments (ipython, RMarkdown, Mathematica, etc)

Do any of those actually implement Literate Programming as DK intended? As in "you can move the code around to wherever makes most sense for your narrative"? As best I know, almost all "literate programming" today is just the intermingling of code and text blocks (e.g. Docco et al) in the same order the code would have to be anyway (i.e. there's no TANGLE, only WEAVE.)


Note that literate programming and "modularization/separation" are both techniques for organizing your code, but they aren't mutually exclusive (though I understand the temptation to use only one). (Aside: what are now called "sections" in literate programming were originally called "modules".) (Disclaimer: I'm not sure I know what you mean by literate programming in notebook environments.)


I think code navigation would naturally fall out from this approach.

That could be.

Are there any novel navigation approaches that have fallen out?


Knuth wrote programs with pen/pencil on paper (https://news.ycombinator.com/item?id=10172924) (and from all I can tell, still does so), so Knuth-style Literate Programming's facilities for code "navigation" are all paper-based: at the back of the book there is an index to all the variables (where each variable is defined and all the places it's used), and (in the published books) there are even mini-indices on each two-page spread, restricted to just the variables that occur on those pages. The cross-references (like "See also sections 163 and 927" or "This code is used in section 4") are also meant to help you "navigate" to the respective pages.

In one of the "internals of TeX" videos, Knuth mentions how when he got to a particular section of the code, he had to move to a larger desk (yes, desk) so that everything could stay in sight. If you're comfortable with such a style of programming, paper gives you a lot of freedom: you can have a very large number of (literal) "tabs", cover parts of pages, make throwaway annotations while reading, etc.

Anyway, as far on-screen navigation goes, with pdfTeX there are hyperlinks: you can navigate from the mention of any section to its actual code, and backwards. (E.g. start at section 4 http://texdoc.net/texmf-dist/doc/generic/knuth/tex/tex.pdf#p... and go to one of the mentioned sections, and back from them to 4.) (It would be nice for there to be even more hyperlinks, but no one seems to have implemented them as Pascal isn't exactly popular these days.)

And to answer your question most concretely: the (recent) online version of the Literate-Programming book Physically Based Rendering: From Theory To Implementation has some innovative navigation aids IMO. (Random "page" / section from the book: http://www.pbr-book.org/3ed-2018/Camera_Models/Realistic_Cam...)


Interesting point, thank you! I have always liked the ideas behind literate programming. For my next piece of work on this I think I can use LP to really motivate the need for such tools.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: