Story Details

  • Literate programming: Knuth is doing it wrong (2014)

    Posted: 2025-01-13 13:06:42

    The author argues that Knuth's vision of literate programming, where code is written for humans within a narrative explaining its logic, hasn't achieved mainstream adoption because it fundamentally misunderstands the nature of programming. Rather than a linear, top-down process suitable for narrative explanation, programming is inherently exploratory and iterative, involving frequent refactoring and restructuring. Literate programming tools force a rigid structure onto this fluid process, making it cumbersome and ultimately counterproductive. The author proposes "exploratory programming" as a more realistic approach, emphasizing tools that facilitate quick exploration, refactoring, and visualization of code relationships, allowing understanding to emerge organically from the code itself.

    Summary of Comments ( 53 )
    https://news.ycombinator.com/item?id=42683009

    Hacker News users discuss the merits and flaws of Knuth's literate programming style. Some argue that his approach, while elegant, prioritizes code as literature over practicality, making it difficult to navigate and modify, particularly in larger projects. Others counter that the core concept of intertwining code and explanation remains valuable, but modern tooling like Jupyter notebooks and embedded documentation offer better solutions. The thread also explores alternative approaches like docstrings and the use of comments to generate documentation, emphasizing the importance of clear and concise explanations within the codebase itself. Several commenters highlight the benefits of separating documentation from code for maintainability and flexibility, suggesting that the ideal approach depends on the project's scale and complexity. The original post is criticized for misrepresenting Knuth's views and focusing too heavily on superficial aspects like tool choice rather than the underlying philosophy.