Literate Programming

January 10, 2018 at 10:43 am | Posted in Hacking, Programming | Leave a comment
Tags: , , , , ,

I was reading Knuth’s The Art of Computer Programming, the seminal in algorithms. I was unable to understand some parts of section 1.2.10 (analysis of an algorithm), so I asked on IRC channels (like ##programming, ##c, #haskell etc.) and I came across More Shell, Less Egg. Go read that article and come back here.

I hope you have finished reading that article. A few years back I came to know about Literate Programming. I was curious about it, I read some articles on it and really loved the concept. Fast forward to 2018, I am a full-time computer programmer with several years of experience now and my thinking has changed. So how does literate programming look now ?

I read full article and was quite impressed by the cleverness and experience of both Mcllroy and Knuth. Now Mcllroy is a UNIX guy (he wrote UNIX pipes). UNIX gurus are very practical and wise when it comes to solving problems. But I found myself little bit wrong in comparing a shell script with a full fledged programming language available on a variety of systems. Then I came across this comment by Charles Wolfe:

most comments tend to become useless rather rapidly and having the documents wholly separated from the code make the cross referencing or consultation of docs to understand code difficult most of the time.

I have to agree with that as per my own experience (it may not be valid all the time and this is how most of the industrial code is written). We combine that with another very practical blog post by Franklin Chen. He used 2 pieces of codes to prove his point, first one, normal Haskell code and 2nd, Haskell code written with documentation (something like Haskell’s own WEB system). If you look carefully you can see that one with documentation is not much readable (at least I felt horrible when I tried to read it).

So, What Do I think now in 2018 after working in software industry ?

Let me make it very clear that Knuth is a brilliant guy, I respect him a lot. I even someday want to learn from him by sitting next to him teaching me ūüôā . We are talking here about Software Industry, the commercial interests. I think Literate Programming will not spread into the software industry. First of all, industrial software developers (at least here in India) do not care much about comments. I do write hell lot of comments but that is because I learned my skills on USENET whereas most industrial programmers in India learned from usual engineering colleges where commenting your code well, is not part of the picture. There is no paradigm of “you will write it once and it will be read 10000 times, so help your fellow programmers by telling them what are you doing” (I just industrialized the quote from Knuth: ‚ÄúPrograms are meant to be read by humans and only incidentally for computers to execute.‚ÄĚ).¬† 2nd, there is lot of job-shifting happens in industry. By the time¬† a project comes to its completion, there is a possibility that¬† 1000 different people have worked¬† on it who never communicated with each other, hence,¬† lot of code changes and many times, comments, sooner or later, become irrelevant. Some comments stay same, many don’t. 3rd, managers in industry want solutions fast and even though, most of the time, such attitude hurts the software and hence the company in long term but then I do not think it is their fault because they have pressure on them to deliver. So, if a project takes a month to design, code and test and deliver then you have to get it done by next week. In such cases, all things not related to “fast delivery” are generally ruled out. If it is not a whole project and there is problem you have to solve then¬† because of “fast delivery” requirements, UNIX tools win. I have experienced both. You can’t beat UNIX tools there with a general purpose language.¬† So, I think Literate Programming¬† will never catch up in industry.

Copyright © 2017 Arnuld Uttre, Hyderabd, Telangana Р500017 (INDIA)
Licensed Under Attribution-NoDerivs 3.0 United States (CC BY-ND 3.0 US)


Blog at
Entries and comments feeds.