{"id":45,"date":"2002-03-08T19:16:00","date_gmt":"2002-03-09T03:16:00","guid":{"rendered":"http:\/\/www.netjeff.com\/wp\/?p=45"},"modified":"2007-12-30T22:17:38","modified_gmt":"2007-12-31T06:17:38","slug":"real-programmers-write-in","status":"publish","type":"post","link":"https:\/\/www.netjeff.com\/wp\/?p=45","title":{"rendered":"Real programmers write in&#8230;"},"content":{"rendered":"<p> A recent article devoted to the macho side of programming made the bald and unvarnished statement:<\/p>\n<p><em>Real<\/em> Programmers write in FORTRAN.<\/p>\n<p>Maybe they do now,<br \/>\nin this decadent era of<br \/>\nLite beer, hand calculators, and &#8220;user-friendly&#8221; software<br \/>\nbut back in the Good Old Days,<br \/>\nwhen the term &#8220;software&#8221; sounded funny<br \/>\nand Real Computers were made out of drums and vacuum tubes,<br \/>\nReal Programmers wrote in machine code.<br \/>\nNot FORTRAN.  Not RATFOR.  Not, even, assembly language.<br \/>\nMachine Code.<br \/>\nRaw, unadorned, inscrutable hexadecimal numbers.<br \/>\nDirectly.<\/p>\n<p>Lest a whole new generation of programmers<br \/>\ngrow up in ignorance of this glorious past,<br \/>\nI feel duty-bound to describe,<br \/>\nas best I can through the generation gap,<br \/>\nhow a Real Programmer wrote code.<br \/>\nI&#8217;ll call him Mel,<br \/>\nbecause that was his name.<\/p>\n<p><a name=\"cutid1\"><\/a><!--more-->I first met Mel when I went to work for Royal McBee Computer Corp.,<br \/>\na now-defunct subsidiary of the typewriter company.<br \/>\nThe firm manufactured the LGP-30,<br \/>\na small, cheap (by the standards of the day)<br \/>\ndrum-memory computer,<br \/>\nand had just started to manufacture<br \/>\nthe RPC-4000, a much-improved,<br \/>\nbigger, better, faster &#8212; drum-memory computer.<br \/>\nCores cost too much,<br \/>\nand weren&#8217;t here to stay, anyway.<br \/>\n(That&#8217;s why you haven&#8217;t heard of the company,<br \/>\nor the computer.)<\/p>\n<p>I had been hired to write a FORTRAN compiler<br \/>\nfor this new marvel and Mel was my guide to its wonders.<br \/>\nMel didn&#8217;t approve of compilers.<\/p>\n<p>&#8220;If a program can&#8217;t rewrite its own code&#8221;,<br \/>\nhe asked, &#8220;what good is it?&#8221;<\/p>\n<p>Mel had written,<br \/>\nin hexadecimal,<br \/>\nthe most popular computer program the company owned.<br \/>\nIt ran on the LGP-30<br \/>\nand played blackjack with potential customers<br \/>\nat computer shows.<br \/>\nIts effect was always dramatic.<br \/>\nThe LGP-30 booth was packed at every show,<br \/>\nand the IBM salesmen stood around<br \/>\ntalking to each other.<br \/>\nWhether or not this actually sold computers<br \/>\nwas a question we never discussed.<\/p>\n<p>Mel&#8217;s job was to re-write<br \/>\nthe blackjack program for the RPC-4000.<br \/>\n(Port? What does that mean?)<br \/>\nThe new computer had a one-plus-one<br \/>\naddressing scheme,<br \/>\nin which each machine instruction,<br \/>\nin addition to the operation code<br \/>\nand the address of the needed operand,<br \/>\nhad a second address that indicated where, on the revolving drum,<br \/>\nthe next instruction was located.<\/p>\n<p>In modern parlance,<br \/>\nevery single instruction was followed by a GO TO!<br \/>\nPut that in Pascal&#8217;s pipe and smoke it.<\/p>\n<p>Mel loved the RPC-4000<br \/>\nbecause he could optimize his code:<br \/>\nthat is, locate instructions on the drum<br \/>\nso that just as one finished its job,<br \/>\nthe next would be just arriving at the &#8220;read head&#8221;<br \/>\nand available for immediate execution.<br \/>\nThere was a program to do that job,<br \/>\nan &#8220;optimizing assembler&#8221;,<br \/>\nbut Mel refused to use it.<\/p>\n<p>&#8220;You never know where it&#8217;s going to put things&#8221;,<br \/>\nhe explained, &#8220;so you&#8217;d have to use separate constants&#8221;.<\/p>\n<p>It was a long time before I understood that remark.<br \/>\nSince Mel knew the numerical value<br \/>\nof every operation code,<br \/>\nand assigned his own drum addresses,<br \/>\nevery instruction he wrote could also be considered<br \/>\na numerical constant.<br \/>\nHe could pick up an earlier &#8220;add&#8221; instruction, say,<br \/>\nand multiply by it,<br \/>\nif it had the right numeric value.<br \/>\nHis code was not easy for someone else to modify.<\/p>\n<p>I compared Mel&#8217;s hand-optimized programs<br \/>\nwith the same code massaged by the optimizing assembler program,<br \/>\nand Mel&#8217;s always ran faster.<br \/>\nThat was because the &#8220;top-down&#8221; method of program design<br \/>\nhadn&#8217;t been invented yet,<br \/>\nand Mel wouldn&#8217;t have used it anyway.<br \/>\nHe wrote the innermost parts of his program loops first,<br \/>\nso they would get first choice<br \/>\nof the optimum address locations on the drum.<br \/>\nThe optimizing assembler wasn&#8217;t smart enough to do it that way.<\/p>\n<p>Mel never wrote time-delay loops, either,<br \/>\neven when the balky Flexowriter<br \/>\nrequired a delay between output characters to work right.<br \/>\nHe just located instructions on the drum<br \/>\nso each successive one was just past the read head<br \/>\nwhen it was needed;<br \/>\nthe drum had to execute another complete revolution<br \/>\nto find the next instruction.<br \/>\nHe coined an unforgettable term for this procedure.<br \/>\nAlthough &#8220;optimum&#8221; is an absolute term,<br \/>\nlike &#8220;unique&#8221;, it became common verbal practice<br \/>\nto make it relative:<br \/>\n&#8220;not quite optimum&#8221; or &#8220;less optimum&#8221;<br \/>\nor &#8220;not very optimum&#8221;.<br \/>\nMel called the maximum time-delay locations<br \/>\nthe &#8220;most pessimum&#8221;.<\/p>\n<p>After he finished the blackjack program<br \/>\nand got it to run<br \/>\n(&#8220;Even the initializer is optimized&#8221;,<br \/>\nhe said proudly),<br \/>\nhe got a Change Request from the sales department.<br \/>\nThe program used an elegant (optimized)<br \/>\nrandom number generator<br \/>\nto shuffle the &#8220;cards&#8221; and deal from the &#8220;deck&#8221;,<br \/>\nand some of the salesmen felt it was too fair,<br \/>\nsince sometimes the customers lost.<br \/>\nThey wanted Mel to modify the program<br \/>\nso, at the setting of a sense switch on the console,<br \/>\nthey could change the odds and let the customer win.<\/p>\n<p>Mel balked.<br \/>\nHe felt this was patently dishonest,<br \/>\nwhich it was,<br \/>\nand that it impinged on his personal integrity as a programmer,<br \/>\nwhich it did,<br \/>\nso he refused to do it.<br \/>\nThe Head Salesman talked to Mel,<br \/>\nas did the Big Boss and, at the boss&#8217;s urging,<br \/>\na few Fellow Programmers.<br \/>\nMel finally gave in and wrote the code,<br \/>\nbut he got the test backwards,<br \/>\nand, when the sense switch was turned on,<br \/>\nthe program would cheat, winning every time.<br \/>\nMel was delighted with this,<br \/>\nclaiming his subconscious was uncontrollably ethical,<br \/>\nand adamantly refused to fix it.<\/p>\n<p>After Mel had left the company for greener pa$ture$,<br \/>\nthe Big Boss asked me to look at the code<br \/>\nand see if I could find the test and reverse it.<br \/>\nSomewhat reluctantly, I agreed to look.<br \/>\nTracking Mel&#8217;s code was a real adventure.<\/p>\n<p>I have often felt that programming is an art form,<br \/>\nwhose real value can only be appreciated<br \/>\nby another versed in the same arcane art;<br \/>\nthere are lovely gems and brilliant coups<br \/>\nhidden from human view and admiration, sometimes forever,<br \/>\nby the very nature of the process.<br \/>\nYou can learn a lot about an individual<br \/>\njust by reading through his code,<br \/>\neven in hexadecimal.<br \/>\nMel was, I think, an unsung genius.<\/p>\n<p>Perhaps my greatest shock came<br \/>\nwhen I found an innocent loop that had no test in it.<br \/>\nNo test. None.<br \/>\nCommon sense said it had to be a closed loop,<br \/>\nwhere the program would circle, forever, endlessly.<br \/>\nProgram control passed right through it, however,<br \/>\nand safely out the other side.<br \/>\nIt took me two weeks to figure it out.<\/p>\n<p>The RPC-4000 computer had a really modern facility<br \/>\ncalled an index register.<br \/>\nIt allowed the programmer to write a program loop<br \/>\nthat used an indexed instruction inside;<br \/>\neach time through,<br \/>\nthe number in the index register<br \/>\nwas added to the address of that instruction,<br \/>\nso it would refer<br \/>\nto the next datum in a series.<br \/>\nHe had only to increment the index register<br \/>\neach time through.<br \/>\nMel never used it.<\/p>\n<p>Instead, he would pull the instruction into a machine register,<br \/>\nadd one to its address,<br \/>\nand store it back.<br \/>\nHe would then execute the modified instruction<br \/>\nright from the register.<br \/>\nThe loop was written so this additional execution time<br \/>\nwas taken into account &#8212;<br \/>\njust as this instruction finished,<br \/>\nthe next one was right under the drum&#8217;s read head,<br \/>\nready to go.<br \/>\nBut the loop had no test in it.<\/p>\n<p>The vital clue came when I noticed<br \/>\nthe index register bit,<br \/>\nthe bit that lay between the address<br \/>\nand the operation code in the instruction word,<br \/>\nwas turned on &#8212;<br \/>\nyet Mel never used the index register,<br \/>\nleaving it zero all the time.<br \/>\nWhen the light went on it nearly blinded me.<\/p>\n<p>He had located the data he was working on<br \/>\nnear the top of memory &#8212;<br \/>\nthe largest locations the instructions could address &#8212;<br \/>\nso, after the last datum was handled,<br \/>\nincrementing the instruction address<br \/>\nwould make it overflow.<br \/>\nThe carry would add one to the<br \/>\noperation code, changing it to the next one in the instruction set:<br \/>\na jump instruction.<br \/>\nSure enough, the next program instruction was<br \/>\nin address location zero,<br \/>\nand the program went happily on its way.<\/p>\n<p>I haven&#8217;t kept in touch with Mel,<br \/>\nso I don&#8217;t know if he ever gave in to the flood of<br \/>\nchange that has washed over programming techniques<br \/>\nsince those long-gone days.<br \/>\nI like to think he didn&#8217;t.<br \/>\nIn any event,<br \/>\nI was impressed enough that I quit looking for the<br \/>\noffending test,<br \/>\ntelling the Big Boss I couldn&#8217;t find it.<br \/>\nHe didn&#8217;t seem surprised.<\/p>\n<p>When I left the company,<br \/>\nthe blackjack program would still cheat<br \/>\nif you turned on the right sense switch,<br \/>\nand I think that&#8217;s how it should be.<br \/>\nI didn&#8217;t feel comfortable<br \/>\nhacking up the code of a Real Programmer.<\/p>\n<p>[<strong>1992  postscript<\/strong> &#8212; the author writes: &#8220;The original submission to the net  was not in free verse, nor any approximation to it &#8212; it was straight  prose style, in non-justified paragraphs. In bouncing around the net it  apparently got modified into the &#8216;free verse&#8217; form now popular. In  other words, it got hacked on the net. That seems appropriate,  somehow.&#8221; The author adds that he likes the &#8216;free-verse&#8217; version better  than his prose original&#8230;]<\/p>\n<p>[<strong>1999 update<\/strong>: Mel&#8217;s last name is  now known. The manual for the LGP-30 refers to &#8220;Mel Kaye of Royal McBee  who did the bulk of the programming [&#8230;] of the ACT 1 system&#8221;.]<\/p>\n<p>[<strong>2001<\/strong>:  The Royal McBee LPG-30 turns out to have one other claim to fame. It  turns out that meteorologist Edward Lorenz was doing weather  simulations on an LGP-30 when, in 1961, he discovered the &#8220;Butterfly  Theorem&#8221; and computational chaos. This seems, somehow, appropriate.]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A recent article devoted to the macho side of programming made the bald and unvarnished statement: Real Programmers write in FORTRAN. Maybe they do now, in this decadent era of Lite beer, hand calculators, and &#8220;user-friendly&#8221; software but back in&#8230; <a href=\"https:\/\/www.netjeff.com\/wp\/?p=45\" class=\"readmore\">Read more<span class=\"screen-reader-text\">Real programmers write in&#8230;<\/span><span class=\"fa fa-angle-double-right\" aria-hidden=\"true\"><\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-45","post","type-post","status-publish","format-standard","hentry","category-programming","content-layout-full"],"_links":{"self":[{"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/45","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=45"}],"version-history":[{"count":0,"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/45\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=45"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=45"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.netjeff.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=45"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}