title: Cobol: science and fiction
body: <p>There are a few threads about the relevance of the Cobol programming language on this forum, e.g. <a href="https://stackoverflow.com/questions/2633159/the-unmentioned-parts-of-cobols-history">this thread</a> links to a collection of them. What I am interested in here is a frequently repeated claim based on a study by Gartner from 1997: <em>that there were around 200 billion lines of code in active use at that time</em>!</p>
  
  <p>I would like to ask some questions to verify or falsify a couple of related points. My goal is to understand if this statement has any truth to it or if it is totally unrealistic.</p>
  
  <p>I apologize in advance for being a little verbose in presenting my line of thought and my own opinion on the things I am not sure about, but I think it might help to put things in context and thus highlight any wrong assumptions and conclusions I have made.</p>
  
  <hr>
  
  <p>Sometimes, the "200 billion lines" number is accompanied by the added claim that this corresponded to 80% of all programming code in any language in active use. Other times, the 80% merely refer to so-called "business code" (or some other vague phrase hinting that the reader is not to count mainstream software, embedded systems or anything else where Cobol is practically non-existent). In the following I assume that the code does not include double-counting of multiple installations of the same software (since that is cheating!).</p>
  
  <p>In particular in the time prior to the y2k problem, it has been noted that a lot of Cobol code is already 20 to 30 years old. That would mean it was written in the late 60ies and 70ies. At that time, the market leader was IBM with the <a href="http://en.wikipedia.org/wiki/System/370" rel="nofollow noreferrer">IBM/370 mainframe</a>. IBM has put up a <a href="http://www-03.ibm.com/ibm/history/exhibits/mainframe/mainframe_PP3145.html" rel="nofollow noreferrer">historical announcement</a> on his website quoting prices, configuration and availability. According to the sheet, prices are about one million dollars for machines with up to half a megabyte of memory.</p>
  
  <p><strong>Question 1:</strong> How many mainframes have actually been sold?</p>
  
  <p>I have not found any numbers for those times; the <a href="http://findarticles.com/p/articles/mi_m0EIN/is_2001_March_7/ai_71313802/?tag=rbxcra.2.a.33" rel="nofollow noreferrer">latest numbers</a> are for the year 2000, again by Gartner. :^(</p>
  
  <p>I would guess that the actual number is in the hundreds or the low thousands; if the market size was 50 billion in 2000 and the market has grown exponentially like any other technology, it might have been merely a few billions back in 1970. Since the IBM/370 was sold for twenty years, twenty times a few thousand will result in a couple of ten-thousands of machines (and that is pretty optimistic)!</p>
  
  <p><strong>Question 2:</strong> How large were the programs in lines of code?</p>
  
  <p>I don't know how many bytes of machine code result from one line of source code on that architecture. But since the IBM/370 was a 32-bit machine, any address access must have used 4 bytes plus instruction (2, maybe 3 bytes for that?). If you count in operating system and data for the program, how many lines of code would have fit into the main memory of half a megabyte?</p>
  
  <p><strong>Question 3:</strong> Was there no standard software?</p>
  
  <p>Did every single machine sold run a unique hand-coded system without any standard software? Seriously, even if every machine was programmed from scratch without any reuse of legacy code (wait ... didn't that violate one of the claims we started from to begin with???) we might have O(50,000 l.o.c./machine) * O(20,000 machines) = O(1,000,000,000 l.o.c.).</p>
  
  <p>That is still far, far, far away from 200 billion! Am I missing something obvious here?</p>
  
  <p><strong>Question 4:</strong> How many programmers did we need to write 200 billion lines of code?</p>
  
  <p>I am really not sure about this one, but if we take an average of 10 l.o.c. per day, we would need 55 million man-years to achieve this! In the time-frame of 20 to 30 years this would mean that there must have existed two to three million programmers constantly writing, testing, debugging and documenting code. That would be about as many programmers as we have in China today, wouldn't it?</p>
  
  <p><strong>EDIT:</strong> Several people have brought up automatic templating systems/code generators or so. Could somebody elaborate on this? I have two issues with that: a) I need to tell the system what it is supposed to do for me; for that I need to communicate with the computer and the computer will output the code. This is exactly what a compiler of a programming language does. So essentially I am using a different high-level programming language to generate my Cobol code. Shouldn't I work with that other high-level language instead of Cobol? Why the middle-man? b) In the 70s and 80s the most precious commodity was memory. So if I have a programming language output something, it should better be concise. Using my hypothetical meta-language would I really generate verbose and repetitive Cobol code with it rather than bytecode/p-code like other compilers of that time did? <strong>END OF EDIT</strong></p>
  
  <p><strong>Question 5:</strong> What about the competition?</p>
  
  <p>So far, I have come up with two things here:</p>
  
  <p>1) IBM had their own programming language, <a href="http://en.wikipedia.org/wiki/PL/I" rel="nofollow noreferrer">PL/I</a>. Above I have assumed that the majority of code has been written exclusively using Cobol. However, all other things being equal I wonder if IBM marketing had really pushed their own development off the market in favor of Cobol on their machines. Was there really no relevant code base of PL/I?</p>
  
  <p>2) Sometimes (also on this board in the thread quoted above) I come across the claim that the "200 billion lines of code" are simply invisible to anybody outside of "governments, banks ..." (and whatnot). Actually, the DoD had funded their own language in order to increase cost effectiveness and reduce the proliferation of programming language. This lead to their use of Ada. Would they really worry about having so many different programming languages if they had predominantly used Cobol? If there was any language running on "government and military" systems outside the perception of mainstream computing, wouldn't that language be Ada?</p>
  
  <p>I hope someone can point out any flaws in my assumptions and/or conclusions and shed some light on whether the above claim has any truth to it or not.</p>