{"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 \"user-friendly\" software<br \/>\nbut back in the Good Old Days,<br \/>\nwhen the term \"software\" 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'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't here to stay, anyway.<br \/>\n(That's why you haven'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't approve of compilers.<\/p>\n<p>\"If a program can't rewrite its own code\",<br \/>\nhe asked, \"what good is it?\"<\/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'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'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 \"read head\"<br \/>\nand available for immediate execution.<br \/>\nThere was a program to do that job,<br \/>\nan \"optimizing assembler\",<br \/>\nbut Mel refused to use it.<\/p>\n<p>\"You never know where it's going to put things\",<br \/>\nhe explained, \"so you'd have to use separate constants\".<\/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 \"add\" 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's hand-optimized programs<br \/>\nwith the same code massaged by the optimizing assembler program,<br \/>\nand Mel's always ran faster.<br \/>\nThat was because the \"top-down\" method of program design<br \/>\nhadn't been invented yet,<br \/>\nand Mel wouldn'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'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 \"optimum\" is an absolute term,<br \/>\nlike \"unique\", it became common verbal practice<br \/>\nto make it relative:<br \/>\n\"not quite optimum\" or \"less optimum\"<br \/>\nor \"not very optimum\".<br \/>\nMel called the maximum time-delay locations<br \/>\nthe \"most pessimum\".<\/p>\n<p>After he finished the blackjack program<br \/>\nand got it to run<br \/>\n(\"Even the initializer is optimized\",<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 \"cards\" and deal from the \"deck\",<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'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'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'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't kept in touch with Mel,<br \/>\nso I don'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'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't find it.<br \/>\nHe didn'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's how it should be.<br \/>\nI didn't feel comfortable<br \/>\nhacking up the code of a Real Programmer.<\/p>\n<p>[<strong>1992  postscript<\/strong> &#8212; the author writes: \"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 'free verse' form now popular. In  other words, it got hacked on the net. That seems appropriate,  somehow.\" The author adds that he likes the 'free-verse' version better  than his prose original&#8230;]<\/p>\n<p>[<strong>1999 update<\/strong>: Mel's last name is  now known. The manual for the LGP-30 refers to \"Mel Kaye of Royal McBee  who did the bulk of the programming [&#8230;] of the ACT 1 system\".]<\/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 \"Butterfly  Theorem\" 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 \"user-friendly\" software but back in the Good Old Days, when <a class=\"more-link\" href=\"https:\/\/www.netjeff.com\/wp\/?p=45\">Read More &#8230;<\/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"],"_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}]}}