• HaraldvonBlauzahn@feddit.orgOP
    link
    fedilink
    arrow-up
    22
    ·
    edit-2
    7 days ago

    This is a fantastic discussion between John Ousterhout and Robert Martin on the issue of commenting code, but more of understanding code.

    In brief: Robert “Bob” Martin aka “Uncle Bob”, author of “Clean Code”, could not explain an algorithm he published himself in his own book. He generally advocates to minimize comments, and published it without comments.

    When asked by Ousterhout, he was also not able to change it without breaking it, because he did not understand the invariants in the code he published.

    Bonus points for that he copied the algorithm - which is an efficient algirithm for finding prime numbers - from Don Knuth, who published it as an example for his lucid invention of “Literate Programming” - a method to better explain code and its pre-conditions and invariants, by interspersing explanatory text with the actual code, and providing a tool that extracts the program code from it.

    Extra bonus points for that the algorithm which Don Knuth documented was first published by grandmaster Edsger W. Dijkstra in “Notes on Structured Programming”. A brilliant book chapter which explains once and for all invariants in code and data structures.

    Both Don Knuth’s article on “Literate Programming" and Dijkstras book chapter in “Notes in Structured Programming” are available online, I can only encourage to take the time to read them - both of them are timeless masterpieces on writing computer programs.

    (And also, Ousterhouts book “A Philosophy of Software Design” is a really good and nice book on modern software engineering - highly recommended.)