frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Literate programming tool for any language

https://github.com/zyedidia/Literate
48•LorenDB•4h ago

Comments

tony_cannistra•3h ago
Been around for a long time indeed. I first learned literate programming in college at Tufts, from Norman Ramsey. He wrote noweb[1], an early implementation of Knuth's ideas.

[1]: https://en.wikipedia.org/wiki/Noweb

onair4you•2h ago
Oh you beat me to it!
make3•3h ago
I feel like being able to import notebooks like `import notebook_name` and run jupyter notebooks (more easily) like `python notebook.ipynb` and the analogue in different languages would already get us 99% of the way there
jedimastert•2h ago
There's a pretty direct line between the concept of notebooks and literate programming.
audiodude•2h ago
Is there any intrinsic reason why Jupyter Notebooks can't be imported? You don't know which code blocks to run?
mapcars•3h ago
Literate programming is an intriguing concept, but its hard to compete with modern IDEs. Having build system is good, but can you get proper syntax highlight for the code segments? Or goto-symbol, real-time typechecking?

I feel like it needs its own IDE, because now apart from the coding abstractions you also have named snippets.

corysama•2h ago
Code-as-a-Database is something lots of people would like to have, but not much effort has been put into implementation since... Smalltalk? Could still be a pile of loose text files with markup. Like how https://obsidian.md/ is an informal graph database of loose markdown files.
ModernMech•2h ago
There's an active research community based around this very idea: https://liveprog.org, also https://www.hytradboi.com
codebje•1h ago
I write a bit of literate Haskell, sometimes. It's one of the most well supported literate programming systems out there: the compiler supports it, the language server supports it, using VSCode as an "IDE" means full support for all the things you mentioned. Haskell code formatters don't seem to support literate Haskell, though, and GitHub Copilot, at least, gets confused between prose and code (but that's fine, if I'm taking the time to make my code extra readable and understandable the last thing I want is for an AI to get involved).

Maybe a tool like the one presented here could work as a language server proxy to the underlying language's server. The presence of literate text alone doesn't seem to be the main issue, it's getting the code portions parsed, checked, and annotated with references that matters.

taeric•1h ago
I mean... somewhat yes to all of those? Emacs can even do most of what you are asking for. When I export an org buffer, it even has the syntax highlighting in the html that I was looking at. :D

Obviously, the type checking will be a bit more limited for code snippets you haven't finished. But especially for image based environments, it should have everything that you have in the image just fine.

CWEB, which is the one that Knuth prefers, even supports step debugging. Has supported it for decades, at this point.

WillAdams•59m ago
This is why I use LuaLaTeX for this:

https://github.com/WillAdams/gcodepreview/blob/main/literati...

which allows me to have an ordinary .tex file:

https://github.com/WillAdams/gcodepreview/blob/main/gcodepre...

which outputs multiple .py and .scad files and generates a .pdf with nice listings-based code blocks, ToC, index, hyperlinks, &c.:

https://github.com/WillAdams/gcodepreview/blob/main/gcodepre...

The notable downsides are that the .sty and .tex files have to be customized for the filenames which one can output, and I haven't been able to get auto-line numbering working between code blocks, so one has to manually manage the counters.

svieira•2h ago
The fact that the actual implementation is in `lit` too is really helpful - getting to see how one would actually use this on a larger program does make it much more intriguing than the simple examples (and much more approachable than TeX itself).

https://github.com/zyedidia/Literate/tree/master/lit

groos•2h ago
Ignore the naysayers here. Good job!
jostylr•2h ago
I've been wondering if AI coding agent world makes literate programming valuable again. I got into it with JavaScript being a mess prior to the modern changes. Needed a lot of workarounds. Then they improved the language and it felt like coding could be efficient with them. But if the programmer switched from coding to reviewing, maybe it would be good to be able to have various snippets, with an explanation preceding it and then verifying it. Haven't tried it yet. But I do wonder.
thyrsus•2h ago
If your colleagues just don't feel the benefit of the extra .lit file, is there a way to pull their changes to the derived files into your own .lit files and to keep the .lit files in a parallel version control repo or branch?
taeric•58m ago
Sorta? Noweb and org mode's support of it, at least, has a "detangle" and it worked surprisingly well last time I tried it. You can't edit the comments it puts in the source, for obvious reasons. And I'm sure it has trouble if you tried to get too fancy. But it did allow me to edit the generated source directly and pull those edits back into my literate source. I imagine if this was something people were more often doing, you could make it more reliable, even.
onair4you•2h ago
https://en.m.wikipedia.org/wiki/Noweb
w10-1•1h ago
This doesn't seem to provide any context for literate programming, or the core literate operations?

cf leo editor for literate programming in python [0]

Yes, markdown has code blocks, and notebooks have embedded code in documentation since Mathematica in the 1980's. It is possible to get IDE support in such blocks.

But for literate programming, weaving/tangling sources is needed to escape the file structure, particularly when the build system imposes its own logic, and sometimes one needs to navigate into the code. Leo shows how complicated the semantics of weaving can get.

Eclipse as an IDE was great because their editor component made it easy to manage the trick of one editor for many sources, and their markers provided landmarks for cross-source navigation and summaries.

[0] https://leo-editor.github.io/leo-editor

nico•1h ago
Great concept and very relevant today[1]

It’s interesting that using LLMs is making very explicit that “someone” needs to read the code and understand it. So having good comments and making code readable is great both for AI and humans

1: “Writing documentation for AI: best practices” https://news.ycombinator.com/item?id=44311217

amanwithnoplan•1h ago
Another interesting implementation of literate programming with _bidirectional sync_ between documentation and source code is Entangled (https://entangled.github.io/). This allows you to use all your normal tooling on the normal source code files, and the changes are reflected back to your Markdown documentation files.
seanwilson•1h ago
Maybe I'm missing something but how often is the English in literate programming repeating what's already written in the code? Does it work for large projects where it's often hard to explain all the parts in a linear way in the style of an essay?

I avoid code comments where I can because English is way less precise than code, it's an extra chore to keep the comments and code in sync, and when the comments and code inevitably get out of sync it's confusing which one is the source of truth. Does literate programming sidestep this somehow? Or have benefits that outweigh this?

juliangmp•1h ago
I'm not sure who first coined this idea or put it in a book or where I've read it, but for code comments I generally like the "explain why, not what" philosophy. The "what" is answered by the code itself and should be easy enough to comprehend if your design is simple and your names meaningful. The "why" is much more important. Why does this parser check for some magic numbers at this specific offset and change some parameters if it finds them? If you don't explain that its because of e.g. compatibility with some legacy format, its gonna be a mystery to the reader.
taeric•1h ago
I think this certainly happens a fair bit. Not at all uncommon to have a section that largely says what is going to happen next, which, fair that what is going to happen is what happens.

I think where it shines, is where it helps you break the code up, without having to break it up in a way that makes sense for the computer. Show an outline, but then drill into a section. The overall function can then be kept as a single unit, and you can sort of punt on sub sections. I tried this just recently in https://taeric.github.io/many_sums.html. I don't know that I succeeded, necessarily. Indeed, I think I probably should have broken things into more sections. That said, I did find that this helped me write the code more than I expected it to. (I also was very surprised at how effective the goto style of thinking was... Much to my chagrin.)

I will have to look again at some of the code I've read this way.

To directly answer the question of if it helped keep the documentation in sync, as it were, that is tough. I think it helps keep the code in a section directly related to the documentation for that section. All too often, the majority of code around something is not related to what you were wanting to do. Even the general use of common code constructs gets in the way of reading what you were doing. Literate programming seems the best way I have seen to give the narrative the ability to say "here is the outline necessary for a function" and then "this particular code is to do ..." Obviously, though, it is no panacea.

billfruit•11m ago
I prefer to add huge amounts of comments, explaining in as much detail as I can, sometimes it will be a mini-essay in there. I write most of it before I write the code. It helps me formulate the code better. Later it serves as explanatory text.

Usually the problem with comments is that there is too less of it.

JAHDIEL1•1h ago
Español
bilalq•1h ago
I actually did some small hobby projects using Literate Coffeescript a long time ago. Looking at the source code today, and I can't help but feel like the proponents of literate programming were really onto something. I'm coming back a decade later, but I can easily see what's going on and why at a glance. Compared to many other projects that I've written in the past without documentation, it's a completely different vibe. The Gulpfile in particular is such a treat to read.

Yeah, it can look a bit repetitive if the code is already clear, but the context of why a thing is being done is still valuable. In the modern era with LLM tools, I'm sure it could be even more powerful.

txgvnn•1h ago
If you are interested with Literate programming, you should try Emacs. Some packages are org-mode, eev and even elisp are best for literate programming. Example https://www.youtube.com/watch?v=dljNabciEGg
smitty1e•9m ago
Org-babel[1]:

"Literate programming (LP) offers 2 classical operations:

    Tangle: Extract the source code blocks and generate real working code files for further compilation or execution, eventually outside of Emacs.

    Weave: Export the whole Org file as literate, human-readable documentation (generally in HTML or LaTeX)."


[1] https://org-babel.readthedocs.io/en/latest/

Show HN: I wrote a new BitTorrent tracker in Elixir

https://github.com/Dahrkael/ExTracker
119•dahrkael•3h ago•7 comments

Infinite Mac OS X

https://blog.persistent.info/2025/03/infinite-mac-os-x.html
48•kristianp•2h ago•15 comments

Open source can't coordinate

https://matklad.github.io/2025/05/20/open-source-cant-coordinate.html
25•LorenDB•1h ago•6 comments

Compiling LLMs into a MegaKernel: A path to low-latency inference

https://zhihaojia.medium.com/compiling-llms-into-a-megakernel-a-path-to-low-latency-inference-cf7840913c17
160•matt_d•7h ago•44 comments

FedFlix — Public Domain Stock Footage Library

https://public.resource.org/ntis.gov/index.html
9•bookofjoe•1h ago•1 comments

Literate programming tool for any language

https://github.com/zyedidia/Literate
49•LorenDB•4h ago•28 comments

Show HN: ATAC, an event verification platform evidence based

https://atac.seraum.com
3•seraum•1h ago•1 comments

Octobass

https://www.atlasobscura.com/places/octobass
18•keepamovin•3d ago•3 comments

Andrej Karpathy: Software in the era of AI [video]

https://www.youtube.com/watch?v=LCEmiRjPEtQ
1125•sandslash•1d ago•626 comments

Curved-Crease Sculpture

https://erikdemaine.org/curved/
159•wonger_•12h ago•27 comments

Sunsonic 986-II – A Thai Famicom clone with keyboard and mini CRT built-in

https://mastodon.gamedev.place/@pikuma/114711138512697712
10•sohkamyung•3h ago•0 comments

Show HN: A DOS-like hobby OS written in Rust and x86 assembly

https://github.com/krustowski/rou2exOS
149•krustowski•12h ago•35 comments

Show HN: EnrichMCP – A Python ORM for Agents

https://github.com/featureform/enrichmcp
88•bloppe•8h ago•25 comments

Homegrown Closures for Uxn

https://krzysckh.org/b/Homegrown-closures-for-uxn.html
75•todsacerdoti•8h ago•9 comments

How OpenElections uses LLMs

https://thescoop.org/archives/2025/06/09/how-openelections-uses-llms/index.html
86•m-hodges•10h ago•37 comments

Guess I'm a Rationalist Now

https://scottaaronson.blog/?p=8908
224•nsoonhui•16h ago•658 comments

Extracting memorized pieces of books from open-weight language models

https://arxiv.org/abs/2505.12546
51•fzliu•3d ago•47 comments

Show HN: RM2000 Tape Recorder, an audio sampler for macOS

https://rm2000.app
31•marcelox86•2d ago•12 comments

String Interpolation in C++ Using Glaze Stencil/Mustache

https://stephenberry.github.io/glaze/stencil-mustache/
18•npalli•3d ago•0 comments

Show HN: Claude Code Usage Monitor – real-time tracker to dodge usage cut-offs

https://github.com/Maciek-roboblog/Claude-Code-Usage-Monitor
198•Maciej-roboblog•16h ago•110 comments

Giant, All-Seeing Telescope Is Set to Revolutionize Astronomy

https://www.science.org/content/article/giant-all-seeing-telescope-set-revolutionize-astronomy
9•gammarator•3h ago•3 comments

Public/protected/private is an unnecessary feature

https://catern.com/private.html
54•PaulHoule•2d ago•54 comments

DNA floating in the air tracks wildlife, viruses, even drugs

https://www.sciencedaily.com/releases/2025/06/250603114822.htm
72•karlperera•3d ago•62 comments

Flowspace (YC S17) Is Hiring Software Engineers

https://flowspace.applytojob.com/apply/6oDtY2q6E9/Software-Engineer-II
1•mrjasonh•9h ago

What would a Kubernetes 2.0 look like

https://matduggan.com/what-would-a-kubernetes-2-0-look-like/
147•Bogdanp•14h ago•232 comments

We Can Just Measure Things

https://lucumr.pocoo.org/2025/6/17/measuring/
65•tosh•2d ago•50 comments

Star Quakes and Monster Shock Waves

https://www.caltech.edu/about/news/star-quakes-and-monster-shock-waves
36•gmays•2d ago•4 comments

Testing a Robust Netcode with Godot

https://studios.ptilouk.net/little-brats/blog/2024-10-23_netcode.html
31•smig0•2d ago•12 comments

Visual History of the Latin Alphabet

https://uclab.fh-potsdam.de/arete/en
113•speckx•2d ago•67 comments

Munich from a Hamburger's perspective

https://mertbulan.com/2025/06/14/munich-from-a-hamburgers-perspective/
109•toomuchtodo•4d ago•88 comments