CSc 372 — Comparative Programming Languages Spring 2017 (McCann)

The Great CACM GOTO Argument

In 1968, Professor Edsger W. Dijkstra wrote a letter to the editors of the Communications of the ACM, the flagship publication of the Association for Computing Machinery. He titled it “A Case against the GO TO Statement,” but the editor re-titled it “Go To Statement Considered Harmful.” It grew to become one of the most cited items in the magazine’s history.

• Dijkstra, Edsger W. “Letters to the Editor: Go to Statement Considered Harmful.” Communications of the ACM, Volume 11 Issue 3, March 1968, pp. 147-8. https://doi.org/10.1145/362929.362947

In 1987, Frank Rubin submitted a letter to the editor titled “ ‘GOTO Considered Harmful’ Considered Harmful,” in which he argued that the GOTO statement is often very useful. It was published in the March issue.

• Rubin, Frank. “ACM Forum: ‘GOTO Considered Harmful’ Considered Harmful,” Communications of the ACM, Volume 30, Number 3, March 1987, pp. 195-6. https://doi.org/10.1145/214748.315722

Rubin’s letter prompted a flurry of responses that were published in the May, August, and December 1987 issues. These responses included a response from Rubin to the flurry, a response from Dijkstra to the flurry, and a reponse from Rubin to Dijkstra’s response. We can only imagine the volume and tone of the responses and rejoinders had this occurred today on social media.

• Ashenhurst, Robert L., Ed. “ACM Forum,” Communications of the ACM, Volume 30, Number 5, May 1987, pp. 350–5. https://doi.org/10.1145/22899.315729

• Ashenhurst, Robert L., Ed. “ACM Forum,” Communications of the ACM, Volume 30, Number 8, August 1987, pp. 658–62. https://doi.org/10.1145/27651.315742

• Ashenhurst, Robert L., Ed. “ACM Forum,” Communications of the ACM, Volume 30, Number 12, December 1987, pp. 996–9. https://doi.org/10.1145/33447.315758

The following pages are from scans of the original pages in the CACM. I expect you’ll find these letters to be interesting reading, particularly from your points of view as programmers who were taught programming long after the GOTO statement ceased to be an option in most new languages.

“At the IFIP Congress in 1971 I had the pleasure of meeting Dr. Eiichi Goto of Japan, who cheerfully complained that he was always being eliminated.” — , in “ with go to Statements,” Computing Surveys, Vol. 6, No. 4, December 1974. Go To Statement Considered Harmful dynamic progress is only characterized when we also give to which call of the procedure we refer. With the inclusion of procedures Key Words and Phrases: go to statement, jump instruction, we can characterize the progress of the process via a sequence of branch instruction, conditional clause, alternative clause, repet- textual indices, the length of this sequence being equal to the itive clause, program intelligibility, program sequencing dynamic depth of procedure calling. CR Categories: 4.22, 5.23, 5.24 Let us now consider repetition clauses (like,while B repeat A EDITOR : or repeat A until B). Logically speaking, such clauses are now For a number of years I have been familiar with the observation superfluous, because we can express repetition with the aid of that the quality of programmers is a decreasing function of the recursive procedures. For reasons of realism I don't wish to ex- density of go to statements in the programs they produce. More clude them: on the one hand, repetition clauses can be imple- recently I discovered why the use of the go to statement has such mented quite comfortably with present day finite equipment; on disastrous effects, and I became convinced that the go to state- the other hand, the reasoning pattern known as "induction" ment should be abolished from all "higher level" programming makes us well equipped to retain our intellectual grasp on the languages (i.e. everything except, perhaps, plain machine Code). processes generated by repetition clauses. With the inclusion of At'that time I did not attach too much importance to this dis- the repetition clauses textual indices are no longer sufficient to covery; I now submit my considerations for publication because describe the dynamic progress of the process. With each entry into in very recent discussions in which the subject turned up, I have a repetition clause, however , we can associate a so-called "dy- been urged to do so. namic index," inexorably counting the ordinal number of the My first remark is that, although the programmer's activity corresponding current repetition. As repetition clauses (just as ends when he has constructed a correct program, the process procedure calls) may be applied nestedly, we find that now the taking place under control of his program is the true subject progress of the process Can always be uniquely characterized by a matter of his activity, for it is this process that has to accomplish (mixed) sequence of textual and/or dynamic indices. the desired effect; it is this process that in its dynamic behavior The main point is that the values of these indices are outside has to satisfy the desired specifications. Yet, once the program has programmer's control; they are generated (either by the write-up been made, the "making" of the corresponding process is dele- of his program or by the dynamic evolution of the process) whether gated to the machine. he wishes or not. They provide independent coordinates in which My second remark is that our intellectual powers are rather to describe the progress of the process. geared to master static relations and that our powers to visualize Why do we need such independent coordinates? The reason processes evolving in time are relatively poorly developed. For is--and this seems to be inherent to sequentiM processes--that that reason we should do (as wise programmers aware of our we can interpret the value of a variable only with respect to the limitations) our utmost to shorten the conceptual gap between progress of the process. If we wish to count the number, n say, of the static program and the dynamic process, to make the cor- people in an initially empty room, we can achieve this by increas- respondence between the program (spread out in text space) and ing n by one whenever we see Someone entering the room. In the the process (spread out in time) as trivial as possible. in-between moment that we have observed someone entering the Let us now consider how we can characterize the progress of a room but have not yet performed the subsequent increase of n, process. (You may think about this question in a very concrete its value equals the number of people in the room minus one! manner: suppose that a process, considered as a time succession The unbridled use of the go to statement has an immediate of actions, is stopped after an arbitrary action, what data do we consequence that it becomes terribly hard to find a meaningful set have to fix in order that we can redo the process until the very of coordinates in which to describe the process progress. Usually, same point?) If the program text is a pure concatenation of, say, people take into account as well the values of some well chosen assignment statements (for the purpose of this discussion regarded variables, but this is out of the question because it is relative to as the descriptions of single actions) it is sufficient to point in the the progress that the meaning of these values is to be understood l program text to a point between two successive action descrip- With the go to statement one can, of course, still describe the tions. (In the absence of go to statements I can permit myself the progress uniquely by a counter counting the number of actions syntactic ambiguity in the last three words of the previous sen- performed since program start (viz. a kind of normalized clock). tence: if we parse them as "successive (action descriptions)" we The difficulty is that such a coordinate, although unique, is utterly mean successive in text space; if we parse as "(successive action) unhelpful. In such a coordinate system it becomes an extremely descriptions" we mean successive in time.) Let us call such a complicated affair to define all those points of progress where, pointer to a suitable place in the text a "textual index." say, n equals the number of persons in the room minus onet When we include conditional clauses (if B then A), alternative The go to statement as it stands is just too primitive; it is too clauses (if B then AZ else A2), choice clauses as introduced by much an invitation to make a mess of one's program. One can . A. R. Hoare (case[i]of(At, A2, ... ,An)), or conditional expres- regard and appreciate the clauses considered as bridling its use. I sions as introduced by J. McCarthy (Bi -~ El, B2 --~ E2, ... , do not claim that the clauses mentioned are exhaustive in the sense Bn ---~En), the fact remains that the progress of the process re- that/hey will satisfy all needs, but whatever clauses are suggested mains characterized by a single textual index. (e.g. abortion clauses) they should satisfy the requirement that a As soon as we include in our language procedures we must admit programmer independent coordinate system can be maintained to that a single textual index is no longer sufficient. In the case that describe the process in a helpful and manageable way. a textual index points to the interior of a procedure body the It is hard to end this with a fair acknowledgment. Am I to

Volume 11 / Number 3 / March, 1968 Communieations of the ACM I47 judge by whom my thinking has been influenced? It is fairly its sourcedevel distribution. As a result, that efforl5 was bypassed obvious that I am not uninfluenced by Peter Landh~ a~d Chris~ by the people at Bell Laboratories who developed Srvonou This topher Strachey. Finally I s~muld like to record (as I remember i~ latter Ianguage and its software were iacvitM)ly superior, and quite distinctly)how Heinz Zema:~ek a~ the pre-A~c~-oL meeting were immediately available to every~me, b~eluding the right to in early !959 in Copenhagen quite explicitly expressed his doubts make exte~sio~s. Later versions benefitted from "meritorious whether the go to statement should be treated on equM syntactic extra,siena" by "irrepressible young people" at universities, with footing with the ~signment statement. Tn a modest extent t the result that Sxo~o~, today is an important and prominent blame myself for not having then drawn ~he eor~sequenees of his language, while Coast enjoys relative obscurity. remark. Mr. Mooers will find that; new Ta~cdike languages will appear The remark about the undesirability of the go to statement is whose documentatimb because of the trademark restriction, can. far from new. I remember having read the explicit recoam~enda* not mention Tm~c. Textbook references will be similarly inhibited. ~[on ~o restrict the use of the go to statement to alarm exits, but It is unfortunate. I have not been able to trace it; presumably, it has been made by B~:RNaeD A. GaL~ C. A. R. Hoare. In {t, See. 3.Z1.] Wirth and Hoare together UaiversiQl of Michigag make a remark in the same direetion in motivating the case Ann Arbor, Mich. 4810~ eonstruetion: "Like the conditional, it mirrors die dynamic structure of a program more eleaHy than go to statements a~d Mr. Manet's Reply switches, sad it eliminates the need for introducing a large number of labels i~ the program." EDITOR: I~ In !2] Guiseppe aaeopini seems to have proved the (togieM) Professor GMter's let.tar, commenting ca our Rockford Research sl superfluousness of the go to statement. The exercise to translate policy statement on software protection of 25 August 1967, opens t~ an arbitrary flow diagram more or tess meehanicMty into a jmnp- the discussion of what may be a very significant developmeat to p less one, however, is not to be recommended. The~ the resulting our computing profession. This policy statement applies to our flow diagram cannot be expected to be more transparent than the TIRAC CFM) computer-controlling languages. The statement in. originM one. eludes a new doctrine of software protection which may be gen. tl }'~gFNRE NCES : erally applicable to a variety of different kinds of complex corn- i~ 1. WIaT~LN~KL.-~'S~ Axe> }{O.~a~, C A. R A contribution to the purer systems, computer services, languages, and software, a developmen~ of ALGOL. ('cram. A(\~.[ 9 (June 19~i), 413-432. Already it is evident that this doctrine has a number of interesting 2. B{JIH)d~ CORNADO, .aN[)J-kkCOP[N[, GUqSEPeE,. Flow diagrams, legal and commercial implications. It is accordingly appropriate d Turing macNnes and languages with only two formation that it be subiect to critical discussion. >ties, Commo ACM ,9 (May lg@}), 3(~->-371. The doctrine is very simple. For speeifieity, I shall describe it EDSGER Wo I)UKSTRA in regard to the Tm~c languages which we have developed: (1) Technogogicag University Rockford Research has designated itself as the sole authority for Eindhoven, The NegheHa~ds the development and publication of authentic standards and specifications for our TRAC languages; and (2) we have adopted Taac as our commercial trademark (and service mark) for use in connection with our eoraputer-eontrolling languages, our publica- tions providing standards for the languages and any other related goods or services, i The power of this doctrine derives from the unique manner in language Protection by Trademark Ill-advised whieh :it serves the interests of the consuming public--the people K who wilt be using computer services. The visible and recognized Key Words and Phrsaes: TRAC languages, procedure-oriented Te.~c trademark informs this public--the engineers, the soeiol0gy language, proprietary software, protection of software, trade~ professors, the business systems people, and the nonprogrammers marks, copyright protection,patent protection, standardization, everywhere--that the language or computer capability identified I! lice~sing, Mooers doctrb~e by this trademark adheres authentieMly and exactly to a carefully * !i C[~' Categories: 212, 2.2, 4.0, 42 drawn Rockford Research standard for one of our TR:~c languages 'i }:n~Toa : or some related service. This is in accord with a long commercial ~t I would like to comment on a policy published 25 August 1967 and legal tradition. by the Rockford Research Institute Inc., for trademark control The evils of the present situation and the need to find a suitable ~l of ~he T}~Ac language "originated by Calvin N. Mooers of that remedy are well known. An adequate basis for proprietary soft- ~ eorp,ratio>.": "I~ is ~.he belief at Rockford t~meareh that an ware development and marketing is urgently needed, particularly aggresaive cour:~e of action can and should be taker~ to protect the in view of the doubdul capabilities of copyright, patent, or "trade i~tegrity of its carefully desig~ed targuages." Mr. Mooers believes secret" methods when applied to software. Developers of vMuable that "well-drawn standards are not enough to prevent irrespon.- systems--including languages-~-deserve to have some vehicle to sib~e deviatio~v~ in computer ta~guages," and that. there%re give them a return. On the user side the nonexistence of standards "Rnekford Research shall insist ~ha~. all software and supporting in the computer systems area is a continuing nuisance. The services for its T:r{.~e languages arid related services be furnished proliferation of dialects ou wduabte languages (e.g. SNOR0~ or .... for a price by Rockford~ or by sources licensed and authorized by f' O~Tr~~.X) iS sheer madness. The layman user (read "nonprogram" Rockford in a cow,tract arrangement" Mooers' policy, which mer") who now has access to any of several dozen computer applies in academic hastitutions ~s well as commercial ~sem, facilities (each with incompatible systems and diMects) needs includes ":authorized use of the algorithm and prbnitives of a relief. It is my opinion that this new doctrirm of autonomous specific T-~ae language; authorization for experimentatior~ with sta~dardizativm eoupled with resort to eontmereiat trademark can the language , 2' provide a substangiM contribution to remedying a variety of our I ~hir~k that ~his attempt ~o protect a ia~guage a~d its software problems ia this area. by eoatrotlb~g ffhe name is very ill-advised. Orm is remi~ded of Several points of Professor Galter's tatter deserve specific the Co~r tz, ngaage, whose develo~:~r~ (under V. Yngve) reetrieted comment Ih::, full impact of our Rockford Research policy (and

t48 Communieatlo~s ~)f the ACid| Volume 11 / Number 3 / March, 1698 LETTERS Robert L. Aslzedmrst, cditov acmforum

Electronic Mail, Order Entry, Network Noted Taulbee Survey Report Manufacturing, VLSI Design, Cus- I was disappointed in the report by In the “Notable Computer Net- tomer Engineering Dispatch, Prob- David Gries on the 1984-1985 works” article by John S. Quar- lem Reporting and Software Patch Taulbee Survey (Communications, terman and Josiah C. Hoskins Distribution. October 1986, pp. 972-977). Al- (Communications, October 1986, A typical Tandem electronic- though it was well presented, 932-971) a few company networks mail name looks like reasonably laid out and, most are detailed. One such network ‘LaPedis-Ron’, or ‘Payroll’, the likely, accurate, it was not useful which is not detailed seems to be second being a department name information. Data in this form a fairly well-kept secret. This is rather than a person. There is no need commentary to become in- the internal network belonging to need to specify the geographical formation. I often hear of “indus- Tandem Computers Incorporated. location of a mail correspondent. try eating its own seed corn” in This network has 200 Nonstop An on-line telephone book, tele- reference to the hiring of Ph.D.‘s hosts connected via 150 links con- phone messages, and request form away from academia, and of a sisting of microwave, laser, satel- application round out the average shortfall in Ph.D.‘s for computer lite, fiber, and copper running at employee’s interface with the net- science overall. I jumped at the speeds up to 3 Mbit/s. The aggre- work. An article on the Tandem chance to learn from the Gries gate processing power of this vir- network has appeared in Data report. Alas, there were no con- tual machine is 1.6 BIPS (billion Communications magazine (August clusions drawn, no help for all us instructions per second). Both the and September 1985). uninformed. I know that time systems and the network are fault- spent pouring over the data would tolerant. Ron LaPedis give me some feel for the condi- A staff of four employees in Corinne DeBra tion I am concerned over (e.g., po- Cupertino, CA, and one in Ger- Tandem Computers Incorporated tential lack of sufficient Ph.D.‘s), many support the user community 29191 Vallco Parkway but I know I do not have the time of 6500 hard-wired and 2500 dial- Cupertino, CA 95024-2599 and I fear I lack the knowledge to up terminals and PCs. While the draw proper conclusions. network, spanning 23 countries, is “GOT0 Considered Harmful” Roger S. Gourd running 24 hours a day, the sup- Considered Harmful MASSCOMP port staff works normal 40 hour The most-noted item ever pub- One Technology Park weeks. Because of its fault-tolerant lished in Communications was a Westford, MA 01886 nature, communications failures letter from Edsger W. Dijkstra are not critical to network connec- entitled “Go To Statement Con- tivity. sidered Harmful” [l] which at- Response: This ease of maintainability is tempted to give a reason why the Perhaps reader Gourd is right in due to Tandem’s proprietary pro- GOT0 statement might be harm- asking for more commentary and tocol, EXPAND, which is modeled ful. Although the argument was conclusions. Inexperience, a after x.25. Addition, deletion or academic and unconvincing, its reluctance to draw too many moves of hosts do not require a title seems to have become fixed conclusions, and a lack of space all Network Sysgen. When a new host in the mind of every programming contributed to the form and is added to the network, a “ripple manager and methodologist. Con- content of the report. We will try effect” takes place until each host sequently, the notion that the to address this criticism in the knows the best path to the new GOT0 is harmful is accepted al- next report. host. During a network failure and most universally, without question David Gries after the subsequent recovery, or doubt. To many people, “struc- Department of the network performs its own tured programming” and “GOTO- Cornell University rerouting. less programming” have become 405 Upson Hall The network supports over 100 synonymous. Ithaca, NY 14853-7501 production applications including This has caused incalculable

March 1987 Volume 30 Number 3 Communicationsof the ACM 195 Forum

harm to the field of programming, Three of the group regularly By any measure not intention- which has lost an efficacious tool. used in-their work. They ally biased against GOTOs, the It is like butchers banning knives produced seven-line programs two GOTO-less programs are more because workers sometimes cut nearly identical to this: complex than the program using themselves. Programmers must GOTOs. Aside from fewer lines of for i :=I ton devise eIaborate workarounds, dobegin code, the program with GOTOs use extra flags, nest statements forj :=ltondo has only 13 operators, compared to excessively, or use gratuitous sub- if x[i, j]<>O 21 and 19 for the GOTO-less pro- routines. The result is that GOTO- thengoto reject; grams, and only 41 total tokens, less programs are harder and cost- writeln compared to 74 and 66 for the lier to create, test, and modi.fy. ('The firstall-zero other programs. More impor- The cost to business has already row is I, i tantly, the programmers who used been hundreds of millions of dol- break; GOTOs took less time to arrive at lars in excess development and reject: end; their solutions. maintenance costs, plus the hid- The other ten programmers nor- In recent years I have taken den cost of programs never devel- mally avoided GOTOs. Eight of over a number of programs that oped due to insufficient resources. them produced 13 or 14-line pro- were written without GOTOs. As I have yet to see a single study grams using a flag to indicate I introduce GOTOs to untangle that supported the supposition when an all-zero row was found. each deeply nested mess of code, that GOTOs are harmful (I pre- (The other two programs were I have found that the number sume this is not because nobody either incorrect or far more com- of lines of code often drops by has tried). Nonetheless, people plex.) The following is typical of 20-25 percent, with a small de- seem to need to believe that the programs produced: crease in the total number of vari- avoiding GOTOs will automati- ables. I conclude that the matrix cally make programs cheap and i :=I; example here is not an odd case, reliable. They will accept any repeat but typical of the improvements statement affirming that belief, j :=I; that using GOTOs can accomplish. and dismiss any statement oppos- allzero :=true; I am aware that some awful pro- ing it. while (j<=n)andallzero grams have been written using It has gone so far that some peo- dobegin GOTOs. This is often the fault of ple have devised program com- if x[i, j]OO the language (because it lacks plexity metrics penalizing GOTOs thenallzero := false; other constructs), or the text edi- j :=j+l; so heavily that any program with tor (because it lacks a block end; a GOT0 is ipso facto rated more i :=i+l; move). With a proper language complex than even the clumsiest until (i>n) or allzero; and editor, and adequate instruc- GOTO-less program. Then they ifi<=n tion in the use of GOTO, this turn around and say, “See, the thenwriteln should not be a consideration. program with GOTOs is more ('The firstall-zero All of my experiences compel complex.” In short, the belief that rowis I, i-l); me to conclude that it is time to GOTOs are harmful appears to part from the dogma of GOTO-less After reviewing the various have become a religious doctrine, programming. It has failed to GOTO-less versions, I was able to unassailable by evidence. prove its merit. eliminate the flag, and reduce the I do not know if I can do any- program to nine lines: thing that will dislodge such i:=l; deeply entrenched dogma. At least Frank Rubin repeat I can attempt to reopen the discus- The Contest Center sion by showing ,a clearcut in- j := 1; while(j<=n) P.O. Box 1660 stance where GOTOs significantly Wappingers Falls, NY 22590 reduce program complexity. and (x[i, j] =0) do j := j+l; I posed the following problem to i :=i+l; a group of expert computer pro- until(i>n)or (j>n); grammers: “Let X be an N x N ma- ifj>n lrix of integers. Write a program thenwriteln REFERENCE that will print the number of the 1. Dijkstra, E.W."Go to statementconsidered ('The firstall-zero harmful." Commun.ACM 11, 3 (Mar. 1968), first all-zero row of X, if any.” row is' , i-l); 147-148.

196 Communications of the ACM March 1987 Volume 30 Number 3 LETTERS Robert L. Ashenhurst, editor acmforum

gave up after the Council elections PCs and CPs View from Watergate Bridge of 1982 and stopped paying dues. This letter is in response to the I still pay my dues every year and February 1987 President’s Letter The Forum strives for balanced pres- will for as long as Herb is on the in Communications (“Personal Com- entation. One way to achieve this is Council. Unless they kick me out puters and Computing Profession- by soliciting responses to received once this piece is published. als,” pp. 101-102). Right on and letters. Another is to publish all or a The publications boys in New write on, Paul Abrahams. Last representative sampling of subse- York have tricks up the kazoo in summer (1986) ACM-SIGGRAPH quent reader responses to letters. The order to protect their jabs. It has awarded me an educational former expedient was followed for the happened to me and to others that resource grant to assist with the letter from Herb Grosch, to which the a piece is put “on hold” for publi- creation of computer art work- following response refers. The latter cation until the establishment has shops for high school and middle expedient is adopted here, the “bal- thought of enough smart answers school children. Since attending ance” being perhaps skewed by the for publishing the piece with their SIGGRAPH ‘86, I have gone into fact that this was the only response comments. But the original author the classrooms of our children. received. The editor accepts full does not see their comments until These young people know a great responsibility for delaying its pub- he reads them in Communications. deal about personal computers, lication somewhat until it seemed And if he then tries to get a rebut- video technology, computer reasonably certain that no more tal published, it is refused “be- music, . . the electronic world. responses were forthcoming. cause there is no sense in dragging Their heroes, in some cases, are -R. L. Ashenhurst. it out,” as I was once told after the hackers and computer wizards inquiring. We now read that the to whom Abrahams refers in his While reading Herb Grosch’s letter same thing again has befallen letter. I have been able to reach in a recent ACM forum (“An ACM Herb Grosch. It’s the secrecy that young people and have received Watergate,” Communications, Oct. gets ye! They only do what they the support of Parent Teacher 1986, p. 928-930) I was reminded are legally obligated to and not Associations (PTAs) for my use of of an old Dutch expression that what is morally right. I know: that personal computers in the creation my late father used for this sort of is hard to prove, and they prob- of computer art. SIGGRAPH Video situations: “Vechten tegen de bier- ably will scream of slander and Reviews are exciting for children kaai,” he used to say. It meant that libel and threaten legal action to watch, but the opportunity to no matter how hard one fought because their usual response is to see and do creative work on an and argued and obtained agree- hide behind the law and the rules Apple II, Amiga or Macintosh goes ments, the thing would crop up of the Association. It’s the way a long way in educating children. again and again. It was a fight that the staff interprets figures and As a result, it seems like a great without an end. And that is what doctors up reports, hold.ing the in- idea for ACM to find a place for the ACM has become. teresting stuff close to their chests the hardware tinkers and software For those of us who have been and publishing good-to-them items wizards who have made such convinced of the necessity of only. a wonderful contribution to the Chapters and have been fighting Slowly it’s becoming impossible development of young people. for twenty years now for Chapter to say anything or ask q.uestions Theresa-Marie Rhyne Rights and to make life more bear- anymore. Over the years the staff Computer Artist/Art Educator able for the common programmer, and the Council have become P.O. Box 3446 Herb is the only visible and audi- sacred and we, the rank:-and-file Stanford, California 94305 ble voice left, it seems. Most of US members, we are the sacred jack-

May 1987 Volume .?O Number 5 350 Communications of the ACM ACMForum asses who have let them become Then we will have money for i := 1; that holy in the first place. Chapters and local activities. repeat It may be true that the total j := 1; number of members is at an all Jan Matser while ( j <= n) and time high, as Adele Goldberg ACM Arrowhead Chapter Chair (x[i, j] = 0) do (1967) states. And as long as the sign-up j := j,+ 1; ACM San Francisco Peninsula rate of new members is higher i := i + 1; Chair (1977) that the drop-out rate of old mem- until (i > n) or (j > n); bers, that number will continue to if j > n then rise. But the number is deceiving. writeln('The first all “ ‘GOT0 Considered Harmful’ More than half the membership is zero row is ', i); Considered Harmful” Considered Associate and Student members Harmful? who have no vote in the ACM. We I enjoyed Frank Rubin’s letter Both programs, however, serve advertise some 300 Chapters but (“‘GOT0 Considered Harmful’ to point out a missing feature of that number is also deceiving. Considered Harmful,” March 1987, the language. In the first, the auto- Some ZOOare Student Chapters, pp. 195-196), and welcome it as an matic incrementation of a counter and you know how it is at school: opportunity to get a discussion is used, but the end condition can- if the professor says that it will started. As a software engineer, I not be tested with the loop con- help your grade if you pay nine have found it interesting over the struct. In the second, the loop dollars for ACM student member- last 10 years to write programs construct tests for end condition, ship, especially “if you are a both with and without GOT0 but cannot then increment the borderline case” (“and you are all statements at key points. There counter. borderline,” he adds!), then the are cases where adding a GOT0 as The ideal would be to take both whole class joins the ACM. How- a quick exit from a deeply nested good ideas and use them in combi- ever, not many become full- structure is convenient, and there nation: fledged ACM members after they are cases where revising to elimi- have received their diplomas. As nate the GOT0 actually simplifies far as Regular Chapters go, per- found := false; the program. haps some 60 of them show some for i := 1 to n while (A Rubin’s letter attempts to degree of activity. The rest have found) “prove” that a GOT0 can simplify died since 1982 because the lead- do for j := 1 to n the program, but instead proves ers were burnt out by a lack of while (x[i, j] = 0) to me that his implementation administrative and financial sup- do if j = n then language is deficient. In the first port from the National organiza- found := true; solution example the GOT0 pro- tion. Long-time members drop out if found then grammers got the answer very because of disappointment in the writeln('The first all effectively with no wasted effort: ACM. Some months the number of zero row is I, i); members who do not renew their for i := 1 to n memberships is huge. That is what do begin This is not a legal program in Herb refers to when he speaks of for j := 1 to n do Pascal, but the ability to use both membership falling off. And that if x[i, j] <> 0 then a counter and a condition in the was also the reason why they got0 reject; loop construct makes the entire were talking merger with the IEEE writeln ('the job much simpler. The loop count- there for a while. first ing is done (correctly) by the loop- To maintain an oversized office all zero row is I, i); ing construct, as is the exit testing. in a high rent area costs hands full break; I have included a flag to avoid de- of money. That is the main reason reject: end; pending on the value of a loop in- why Chapter services have been dex after exhausting the count, cut to practically nothing. In order In the consolidated second ex- which could be undefined. If a to get funds for Chapters and the ample, the GOTO-less version language specifies the counter to common programmer, I suggest seems somewhat more complex, be left one past the end of range, getting that office out of Manhat- even after the subscript beyond this flag would not be needed. tan and moving it west. This will the end of the array is exchanged I generally prefer GOTO-less accomplish two purposes: lower for a binary flag to determine the code, but will disagree with any- rent, and half of the staff will quit. result: one who thinks there are no valid

May1987 Volume30 Number5 Communicationsofthe ACM 351 ACMForum

uses for the GOT0 in practical en- to read the code twice to find the i := 1; gineering. The GOT0 statement label he was jumping to. done := false; can be easily misused and should Obviously, an occasional need while i <= n and not done therefore be avoided. The hand- arises for some type of GOT0 do coded counters in the second statement. The solution is for the begin example are also easily misused to provide j := 1; and should be avoided whenever a GOT0 statement which has re- while j <= n anti x[i, j] possible. stricted semantics, making it pos- = 0 do The IF and GOT0 are a mini- sible to easily determine the target j := j + 1; mum subset of fea- of the desired branch. For exam- if j <= n then tures, to which the programmer ple, here is Rubin’s example pro- begin can return when the “correct” fea- gram (determining the first all- writeln( "The first ture is not available. GOTO, hand zero row of an N X N matrix of all-zero row is i); coded counters, and extra flags integers), written in C: done := true should all be avoided when possi- end ; ble because their use is error for (i = 0; i < n; i+t) { i :=i+l prone. I would like to challenge for (j = 0; j < n; jH-) end ; language designers to make the if (x[i, j] != 0) For lack of a BREAK Istatement, GOT0 useless by allowing its use break ; I had to use a flag to terlminate the and then providing “better alter- if (j

352 Communications of the ACM May 1987 Volume SO Number5 ACM Forum tened to all the arguments in favor 1968, pp. 147-148) as I‘. . . aca- break of GOTO-less programming, hop- demic and unconvincing . . .” reject: end; ing that one of them would con- without any support or justifica- break: (*etc.*) vince me to give up GOTOs. None tion. Finally, he concludes with has so far succeeded. Such an ar- some example programs which By violating all of the unstated gument would have to show that purport to illustrate the logical assumptions, I was able to produce GOTOs always violate the struc- simplicity of programs which some relatively pleasant solutions ture of a program even when they freely use GOT0 plus BREAK con- to this problem, none of which are used in accordance with good tructs. caused me “to use extra flags, nest programming practices. Obviously Example programs are claimed statements excessively, or use gra- GOTOs are misused, but it is usu- to fit the sample specification “Let tuitous subroutines.” ally not much easier to untangle X be an N x N matrix of integers. The first solution tests addi- heavily nested code than it is to Write a program that will print the tional elements of the matrix X as decipher spaghetti code. first all-zero row of X, if any.” I necessary, is easily changed to Both the overuse and the total had to make several assumptions meet a different specification, uses elimination of GOTOs constitute in order to write the sample multiple procedures, and does not misunderstandings of the relation- program: use either GOT0 or BREAK: ship among syntactic elements in the language does not support a programming language. GOTOs functionallZero:boolean; partial evaluation of logical transfer control just like other, var expressions, related transfer commands (e.g., az:boolean; performance of the final prod- IF.. .THEN). Hence, they should beginaz :=true; uct is not an issue, and be used when other forms would for j := 1 tondo performance in the absence of be inappropriate-by leading to az :=azAND (x[i, j] = any all-zero row is not speci- needlessly complex code, for in- fied-in particular, termination 0); stance. A linguistic analogy can be allZero :=az is not required. found in active and passive sen- end; tences. Active sentences are easier Apparently, there are also sever- procedurefirstZero; to produce and understand in al additional unstated assumptions: begini :=l; relation to their passive counter- the algorithm should test as whilenotallZerodoi := parts. A “passive-less” English 1) few elements of matrix X as i+ 1; would certainly lead to simpler necessary, WRITELN('Firstal1 zero (better?) structures. However, the algorithm need not be eas- row is 1, i) most linguists would agree that 4 ily changed to meet a different end; English would loose a portion of specification, its expressive power. the language does not support The second solution uses recur- Finally, I will continue to do 3) recursion or multiple procedures, sion. With a minor change, the what I have always been doing: the language does support both recursive solution tests minimal listening to GOTO-less arguments 4) GOT0 and BREAK, and values of X. Many reject recursion and writing well-organized and the program should terminate as a viable candidate, but recent commented software that makes 5) if a non-all-zero row is found. evidence [2] confirms that recur- appropriate use of all available sion is indeed faster for many features of a programming language. Rubin’s first example, of a pro- classes of problems. Michael J. Liebhaber gram “. . . where GOTOs signifi- cantly reduce program complex- Child Language Program function allZero(i, j: ity,” will not run on my UCSD 1.1 University of Kansas integer): Pascal system. My Pascal has no 1043 lndiana boolean; BREAK statement. This, however, Lawrence, KS 66044 begin can be circumvented by use of if j > n then an additional GOT0 and label as Frank Rubin’s letter stated that allZero := true follows: I‘. * * GOTO-less programs are else harder and costlier to create, allZero := (x[i, j] = test, and modify.” He describes writeln 0) and allZero(i, Dijkstra’s original letter on the ('the first all zero j + 1) subject (Communications, March row is 1, i); end;

May 1987 Volume 30 Number 5 Communications of the ACM 353 ACM Forum

procedure firstZero(i: 2) locating and computing an FIND(X, n, r, c) = integer); arithmetic mean for all rows Returns the row number of begin which contain nonzero values, the first row of an n by n matrix X if i 5 n then and that has all zeroes if such a row if allZero(i, 1) then 3) locating all rows in which the exists, or the value of n + 1 if the writeln( “First all sum of the elements is odd. row does not exist. It also zero row is ', i) Steven F. Loft Assumes that all rows whose else Computer Task Group index is less than r have at least firstZero(i + 1) 6700 Old Collanzer Road one non-zero element, and that else Syracuse, NY 13057 row r has zeroes as all of its ele- writeln(‘No all zero ments from 1 to c - 1. row') REFERENCES [Assumes (V r’) if r’ c r then 1. Hekmatpour, S. Experience with Evolution- end ; ary Prototyping in a Large Software Project. X[r’][l. .n] # 5) and X[r][l. .c - 11 Software Engineering Notes 12:l. 38-41. = 0, and gives the first r" where r” It seems that Rubin takes issue January 1987. 2 r, X[r”][l. .n] = 0, else it gives with the complexity of deeply 2. Louden, K. Recursion Versus Non-Recur- sion in Pascal: Recursion Can Be Faster. the value of n + 11. nested control structures. Recent SIGPLAN Notices 22:2. 62-67 February work [3] sheds some light on ways 1987. Thus, the Lisp-like, tail- 3. Perkins, G. R.. R. W. Norman. S. Dancic. to cope with such problems. In Coping with Deeply Nested Control Struc- recursive definition of “Given general, poor program layout re- tures. SIGPLAN Notices 22:2. 68-77 an n x n matrix X, print out the February 1987. sults from a failure to understand row number of the first row with an algorithm, not from the lan- all zeroes if there exists such a guage or from the specific tech- row”, is: I would like to comment on Frank niques used for implementation. Rubin’s article on GOTOs. Al- FIND(X, n, r, c) = [[[ I submit that there are two though I agree with him in spirit, c=n+l+r. (fro-m clause 3) issues here: unfortunately he did not give a r=n+l-+r. {from clause 4) Poor and good programming are fair shake to the non-GOT0 camp X[r, c] = 0 + FIND(X, n, r, c + 1). language independent. That for a correct solution. The problem (from clause 1) Rubin is able to reduce the is to find the first row of all zeroes X[r, c] # 0 + FIND(X, yz,r + 1, 1). complexity of poor programs is in an n x n matrix if such a row (from clause 2) not an indictment of the pro- exists. A simple correct solution 111 gramming style, but rather an can be derived from the English indictment of the program- description of the problem/solu- This definition FIND would be run mer(s), and a tribute to Rubin’s tion. First, a practical definition of as “FIND(X, n, 1, 1)” with n al- obvious skill. an algorithm can be given as: ready instantiated as some integer. Modifying programs in which From the definition of FIND, it is if the current matrix element is there is a ‘I. . . conceptual gap 1) easy to write the following pro- equal to zero then look at the between the static program and gram: next element in the row; the dynamic process . . .” (to if the current matrix element is quote Dijkstra’s original letter) 2) not equal to zero then look at r := 1; is generally quite difficult. the first element in the next c := 1; While some advocate scrapping row; while (c<>n + 1) and programs instead of patching (r<>n + 1) do them ([l] is a recent example), But WHOOPS, . . . if X[r, c] = 0 then it seems that writing a program 3) if the column number is equal C := c + 1 as generally as possible can to n + 1, then we have found a else only make it less expensive to row with all zeroes, so write begin modify. out that row number; r := r+ 1; In order to see the real limita- 4) if the row number is equal to c := 1 tions of GOT0 programming, try n + 1, then we have run out of end ; to modify the example programs rows and there are no rows in if r<>n + then in Rubin’s letter. Modifications matrix X that is full of zeroes. writelin('Found the should include: first row with all An English-definition of a pro- zeroes, it is :I, r); 1) locating all rows which are all cedure that accomplishes the zero, above is

354 Communications of the ACM May 1987 Volume 30 Number 5 ACM Forum

This program was written by put- or (X[Y][l. A] = 0 and construct used in that program is a ting the recursive clauses in order quasi-FOR definition where it is in a “if. . . then . . . else if. . . (i@r’)(r < Y, X[r’][l. .n] = 0))). somewhat like a FOR definition etc . . . ,‘I and by putting the escape -which is nothing more than a except. . . . So you have a GOT0 clauses into the while clause pred- conjunction of the loop invariant which can prematurely break you icate location. Since there were with the negation of the while out of the “FOR j := 1 to n do” two escape clauses, we have to loop guard. (This paragraph may loop, and a BREAK that can break differentiate as to which one ter- be clouding the point). you prematurely out of the “for minated the while loop. We do Now I would like to criticize i := 1 to n” loop. These two quasi- this by using an if statement after Rubin’s example programs. In the loops make the program error the loop. third program in his letter, in prone and make proving program which he eliminated the flag, one correctness harder. The loop invariant for the while can tell that the program was writ- In conclusion, although the is: ten and then hodged-podged into derivation of my program may appear contrived, I did derive a There exists no row previous to being hopefully correct. This is similar program in less than five r that is all zeroes, and of row r, its shown by the “i := i + 1;” state- minutes intuitively, except that elements from 1 to c - 1 are all ment. If a row was all zeroes, then the guards for the while loop were zeroes. why increment i? Because it is necessary to make the program not as good as those in the pre- (i(Elr')(r' < Y, X[r'][l. .n] = 5)) work. sented version. Then I thought of Thus, all the statements are not how to systematically derive a and X[Y][l. .c - l] = 0. fully (correctly) utilized, and an correct solution from the problem, unnecessary loop construct seems and thus, the letter. The condition that will be true at to be an unwarranted complica- Incidentally, there are intuitive termination of the while, after 0 tion ways to write non-GOT0 pro- or more iterations is: In the first program (the “pre- grams that will run as efficiently as Rubin’s GOT0 program (or bet- We ran out of rows and there ferred” GOT0 program) the “for j := 1 to n do” behavior is not con- ter). One involves a different data- was no row of all zeroes, or, the structure, which would be an current row r is all zeroes and all sistent with the commonly under- stood definition of the FOR loop. n + 1 by n + 1 matrix containing the previous rows had at least one sentinels in the extra row and nonzero element each. A FOR loop specifies a definite number of iterations. Depending column. (r=n+l and on the data of row i, the FOR j Lee Starr loop may do its body for n itera- 10 Overlook Terrace (i(3r’)(r’ 5 n, X[r’][l. .n] = 0))) tions, or it may do it for less. The Walden, NY 12586

TO OUR MEMBERS: More than 15,000 members ond notices. If you received such are being prepared and will be took advantage of the special a notice, we wish to assure you sent as soon as possible. multiple-year renewal offer in that your payments have been We apologize for any incon- November and December 1986. applied properly and your publi- venience that these processing As a result of this enthusiastic cations will arrive on schedule. problems may have caused you, response, for which we were not In addition, membership cards and urge you to contact the fully prepared, processing of nor- were not sent with the multiple- ACM Member Services Depart- mal membership renewals was year renewal offer because of ment at ACM Headquarters if delayed, and some members the nature of that offer. For you have any remaining unre- who renewed through the spe- those of you who responded to solved problems with your cial offer received incorrect sec- the offer, new membership cards membership.

May 1987 Volume 30 Number 5 Communications of the ACM 355 acmforum

being made acrossthe board in the Don’t Sell Technology Short communication and ethical issuesof computer industry at an increas- Alan Borning’s treatise, “Computer global computer communication, ingly rapid pace. System Reliability and Nuclear and still be general enough in scope Yes, computer system reliability not to be outdated by advances in War” (Communications,February has been, and continues to be, a hardware and architectures. 1087, pp. 112-31), is a remarkably cloud in the SD1sky, but please,let thorough and perceptive piece of Erik Fenna us recognize the very significant work. Its persuasiveexposition of CNCP Telecommunications progressbeing made, continuously, the dangersof over-reliance on com- Toronto, Canada in this crucial area. puters should not, however, deter us from fully utilizing their great and P. E. Borkovitz growing potential for improving Executive Vice President Ain’t Got No Body? weaponscommand and control Advanced Technology I enjoyed Carolynn Van Dyke’s arti- systems. International, Inc. cle, “Taking ‘Computer Literacy’ The threat of nuclear war is in- 350 Fifth Ave. Literally” in the May issueof Com- deed a problem to be solved “in the New York, NY 10118 munications (pp. 366-74), but I was political, human realm,” but in the puzzled by the footnote on the bot- computer technology realm we can Communications, A Matter tom of page 369 which stated, in do something about computer reli- of Course? effect, that computing ha:; no body ability. Every day brings new tools I was pleasedto see the ongoing ef- of great work comparable to literary which, if used properly, will help us fort to guide and encourage excel- culture. In fact, the literature of al- deal with the problem. lence in computer scienceeducation gorithms is quite close to being such Borning’s references to the inter- (AIfs Berztiss, “A Mathematically a body. Algorithms are short; they action/integration difficulties asso- FocusedCurriculum for Computer are not analogousto novels, but per- ciated with projects like the SD1are Science,” Communications,May 1987, haps correspond to short stories or an important case in point. Rela- pp. 356-65). The purposeof teaching even haiku. Competent program- tively new “second generation” tools computer science is not to fill stu- mers must be familiar with this lit- such as those produced by my firm dents with data but rather to teach erature just as competent writers have vastly improved the reliability them how to think, and the curricu- must be familiar with their literary of design work in software engineer- lum propounded by Berztiss cer- culture. ing for large-scalesystems, permit- tainly seemsto emphasize this There are differences between al- ting dozens-potentially even theory. gorithms and other literary works. hundreds-of engineersto do design Although it is difficult to predict The author of a poem or novel need work interactively in a highly reli- accurately what computers will be not publish commentary on that able manner. Within a few months, like and how they will be used a work, but we require that the au- such PDL tools will be superseded decade or two in the future, one thor of an algorithm publi:sh a con- by new CASE (Computer-Aided steady trend in computing has been siderable volume of commentary Software Engineering) tools which the increase in intercomputer com- with the original publication of the will give design engineers accessto munication (witness the inclusion of work. With traditional literature, a single, fully-integrated, monolithic the author’s CSNET address).This most of the credit goesto the author development path. Such tools will field was ignored in the author’s who expressedthe idea, not to the cover software development from curriculum, however, to what I feel original inventor of the idea being architectural design through main!e- is the detriment of computer science expressed.In contrast, we credit the nance, and will he especially geared education. original inventor of an algorithm to the requirements of DOD’SAda A half or full year elective cover- long after the expressionof that al- programming language. ing topics in communication would gorithm has been modified into a Accuracy, reliability, and elimina- go a long way toward exposingstu- form the inventor would no longer tion of “bugs” before a new system dents to the field, and would lay the recognize. even reaches the testing stageare groundwork for those students who Charles Babbageadmonished that, the objectives being realized in this target computer communications as “the man who aspiresto fortune or software design work; work that has a career. The course(s)could cover to fame by new discoveries must he obvious beneficial implications for telecommunication facilities, the content to examine with care the massiveinteractive projects like the OS1model, network concepts, real- knowledge of his contemporaries, or SDI. Improvements of this sort are world problems and solutions in to exhaust his efforts in inventing

656 Communications of the ACM August 1987 Volume 30 Number 8 again, what he will most probably Several automated retrieval sys- What do you say? How about poll- find has been better executed be- terns are provided by the BITNET ing the members and get going fore” (Paragraph 327, On the Economy Network Information Center KWICkly? of Machinery and Manufacturers, 4th (BITNIC), which is located at EDU- Gary D. Knott ed., Charles Knight, London, 1835). COM in Princeton, New Jersey. Two Dept. of Computer Science of these systems,NICSERVE and This appliesequally to the authors University of Maryland of algorithms and to the authors of DATABASE, offer services very sim- College Park, Md. 20742 traditional literary works. ilar to netlib. NICSERVE provides ac- Douglas W. Jones cessto BITNET-related software and Assistant Professor information. DATABASE provides Last month we announced the major keyword accessto a variety of data- Department of Computer Science burden of handling GOT0 letters has bases. The University of Iowa been shifted to Technical Iowa City, IA NIC Service is operated by the Correspondence. However, it seems DDN Network Information Center appropriate that the following letters (NIC) at SRI International in Menlo appear in Forum since they relate to the Park, Calif. Usersmail requeststo first and second batch of responses Md Call serviceesri-nic.arpa. The subject which appeared in the May and June We would like to correct an unfortu- field of the request contains key- issues of Communications.-Ed. nate comment made in Dongarra words that are used to locate the and Grosse’sarticle on “Distribution desired information, which is then GOTO, One More Time of Mathematical Software via Elec- mailed back to the user. tronic Mail” (Communications, May The GOT0 is back, and not only in Interested userscan get more in- the pagesof the ACM Forum! The 1987, pp. 403-7), ;hat there are no formation about these services by Ollie North of languagecommands software distribution services com- contacting the network centers. parable to netlib. is turning up in myriad “end user” There are several comparable au- Dan Oberst tools intended to produce programs BZTNlC at EDUCOM tomated information retrieval sys- without the involvement of pro- tems which use electronic mail as Princeton, NJ grammers.While computer profes- sionals-such as Frank Rubin-may the transport mechanism. Most of Craig Partridge consciously chooseto use the feared these support retrieval of software CSNET CIC (in addition to other retrieval func- BBN Laboratories Inc. GCTO in certain cases,users of spreadsheet,database and other tions). Three of the best known are 10 Moulton St. the CSNET Info Server, the suite of Cambridge, MA 02238 macro languagesoften do so without systemsoperated by the BITNET information on the other constructs available. In the worst cases, BITNIC, and NIC Service. The BITNIC services and the CSNET Info other constructs may not even be Server have been generally accessi- Jack Be Nimble, Jack Be . . . available. ble to electronic mail users for more This letter is a plea to reinstitute the The debate over GOTOism is too than two years. old, much-beloved, “KWIC Index to narrowly defined. A growing per- The CSNET Info Server is a serv- Computing Literature.” I would tol- centageof code is being written by ice of the CSNET Coordination and erate a dues increase just to be able userswhose entire knowledge of al- Information Center (CIC). The CIC is to have a reliable and convenient gorithm design is bound to the syn- administered by the University Cor- index containing a citation to tax of their favorite packages.If poration for Atmospheric Research (nearly) every journal article, book, professionalprogrammers can intro- and operated by BBN Laboratories thesis, and proceedingspaper in the duce subtle errors into program Inc. in Cambridge, Mass. Versions CR categories. code, how much greater is the risk of the server run under the 4.3bsd I do not really find much use for when end usersdo what comesnat- and System V UNIX systemswith Computing Reviews. It is okay, but urally-and let their code jump all either the Sendmail or MMDFZ mail completenessand timeliness are over the place? systems.Users mail requests to what I really want; not reviews. In The new classof “end users” (do- [email protected],where a query pro- fact, I would be happy to trade Com- it-yourself programmers)out there cessorscans the request and sends puting Reviews and two SIG publica- need tools that embody principles of back the desired information (or a tions for a comprehensive KWIC well-structured design.Without suitable error message).The user in- index periodical. such tools, they will only reproduce terface is patterned after that of the Indeed, with KWIC indexing of the expensive maintenance head- MOSIS chip fabrication system de- authors and titles, no further index- achesprofessional programmers are veloped at the USC Information Sci- ing or categorization need be done. so familiar with. The GOT0 will encesInstitute (MOSIS was probably The big job is typing in all the new continue to spreadunchecked. the first major information service entries every month, but a bi- David Foster to rely on electronic mail to transfer monthly or quarterly publication 1730S. Michigan #IO06 data). would be sufficiently up-to-date. Chicago, IL 60605

August 1987 Volume 30 Number 8 Communications of the ACM 659 With the current knowledge in soft- an N X N matrix of integers. Write a Among all the comments appearing ware metrics being as it is, I do not program that will print the number in the May 1987 Forum on Frank believe we are capable of ade- of the first all-zero row of X, if any." R.ubin's "'GOT0 Considered Harm- quately analyzing the problem in a Lott's solution just keeps increment- fill' Considered Harmful" letter purely scientific light-that is, our ing the row number until it finds an (Communications, March 1987, pp. tools for analysis (no matter how un- all-zero row, without checking for 195-6), I am surprised that there biased they may seem) always lack the end of the matrix. Consider: was not one citation of Donald objectivity. In fact, the very nature 1. The program continues examin- Knuth's "Structured Programming of the metrics are always slanted ing memory after the end of matrix with go to Statements" (Computing either for or against unconditional X. It happens to find what it thinks Suweys, December 1974, pp. 261- branch statements simply by the is an all-zero row and terminates, 301).* Knuth clearly illustrated how opinions of their authors. returning the invalid row number. the goals of structured program- For this reason, I suggest to all 2. The program does not happen ming-ease of understanding, main- (myself included) who argue so reli- to find a spurious solution, but con- tainability, and simplification of val- giously on this subject to change the tinues through memory. If the hard- idation, among others-often cannot focus of attack, from the program- ware incorporates address checking be met without GOT0 statements. ming languages used and/or the or memory protection, the program David E. Ross pragmatic attitudes acquired will eventually exceed the limits of 6477 E. Bayberry St. through years of experience, to a its address space and crash with an Oak Park more useful avenue. Let us instead address exception. Agoura, CA 91301 address the issue of developing the 3. In the absence of such hard- appropriate measures for making an ware, the address references and * but see Harrison letter in the Technical Corre- objective judgement as to the merits row counter eventually wrap spondence section. luly 1987. pp. 634-Ed. (or lack of same) of the GOTO. around and the program never ter- Frederick J. Bourgeois, III minates. This is presumably what At risk of being accused of "beating Computer Scientist b Software Lott had in mind, though no one I a dead horse," I feel compelled to Engineer know would consider it acceptable. respond to all of the responses gen- The Eaton Corporation Surely an unterminated loop is a erated by Frank Rubin's "GOTO 31 71 7 LaTienda Dr. programming error-one .which, Considered Harmful etc." It seems Box 5009, M/S 21 6 ironically, is much harder to debug that much attention has been de- Westlake Village, CA 91360 than a wayward GOT0 statement, voted to demonstrating individual since its behavior depends on ob- programming prowess at the ex- scure side effects of the system pense of the author of the original Steven F. Lott's contribution to the hardware and software. program, while overlooking the great GOT0 debate (May 1987, Some things go without saying. A problem-namely the relative mer- Forum, pp. 353-354) left me program should always terminate. its of the GOT0 statement. stunned. In his zeal to solve Frank A program should not crasih. A pro- I have often found myself in the Rubin's sample problem without us- gram should not return incorrect re- position of arguing against the use of ing GOTOs, Lott produces a solution sults. Must these be part of the spec- the GOTO, most notably with stu- which deliberately fails to termi- ification? Let's not lose sight of the dents attempting to learn Pascal. In nate. Apparently Lott thinks this is forest for the trees when discussing this situation it was clear that they OK: "I had to make several assump- the merits of the GOT0 statement. should not be allowed to use the tions," he writes. " . . . performance Lawrence C. Kueke:; GOT0 statement, given their lack of in the absence of any all-zero row is Software Discoveries, Inc. experience in making "mature pro- not specified-in particular, termi- 137 Krawski Dr. gramming decisions" about the use nation is not required." South Windsor. CT 06074 of control structures. Personally, I The GOT0 debate is about pro- use only the limited forms of the gram complexity, reliability, and GOT0 allowed in C, and believe (for maintainability, is it not? In the real The PL/I excerpt in Conrad Weis- "religious" reasons) that others world (I am not talking Turing ma- ert's otherwise thoughtful letter should do the same. chines or finite automata), termina- (June, 1987 issue) contains a danger- This last statement highlights the tion is always required. Lott's first ous assumption. fundamental problem atissue in solution, which does not terminate Unless a language definition and these discussions of "GOTO-less" vs. if there is no all-zero row, is a per- compiler implementation s-pecify "GOTO-ful" programming. The ar- fect example of why non-termina- otherwise, it is generally incorrect to guments are mostly dogmatic, and tion is disastrous. Depending on the assert anything at all about the frequently break down into heated hardware and software environment value of a loop index variable after discussions of the fundamental it's running in, it may (1) return the exiting the loop. For example, the strengths and weaknesses of the pre- wrong answer, (2) crash, or (3) loop Pascal User Manual and Report ex- ferred languages of the authors. forever. The problem is: "Let X be plicitly states, "The final value of

660 Communications of the ACM August 1987 Volume 30 Number 8 the control variable is left undefined commandis used, offline the expressly to prevent this charge that upon normal exit from the for state- compiler cross-referenceis used. I did not simply solve the sample ment” (p 24). Some instructional lan- Visually, it is usually easier to spot problem myself, but rather surveyed guages (such as PL/C) actually pro- the target of a GOT0 than the target other programmers,using only those hibit the use of an index variable in of a CALL. judged expert by their peers. The this manner. By contrast, the problem of first two sample programsare from The fact that the test produces matching each DO with its END and the survey. The third program proper results in many programs is each IF with its ELSE,if any, is showsthat a casual solution using an artifact of compiler pragmatics, much more difficult and error- GOTOs can even beat a carefully but nevertheless is not strictly prone. There can be only one worked-over solution without GOTOs. correct. statement with a given label, but Naturally, I agree with Liebhaber’s Norman E. Cohen there can be numerous ENDS and letter. However, I would like to Manager, Product Development ELSEsbefore you find the matching add one thought. When Dijkstra’s Mclntosh Computer Systems, Inc. one. Once you have found the label, letter first appeared,I took it as a 472 S. Salina St. it stays found, but one END looks joke. When the notion the GOTOs Syracuse, NY 13202 like any other, so you find yourself were harmful began to spread, I did searchingover and over for the not becomealarmed. I felt that Response: samepairs. On a paper listing, you either the notion would be con- I believe the PLI languagedefinition can bracket them in pencil, but on firmed by studies,or it would dis- doesindeed specify otherwise. Upon a terminal that is infeasible. appear. Instead, it has grown with- normal loop exit the index variable is I sympathize with Musciano’s out supporting evidence, and my available and defined in the natural last paragraph where he indicates alarm has grown with it. It is time way. As the example showed, that programs misusingGOTOs can to put this nonsensefirmly be- this convention allows considerable be difficult to modify. However, hind us, and say that GOTOs, prop- economy of expressionand posesno tangled programswithout GOTOs erly used, are a valuable tool that threat to structured programming can be equally difficult. Anecdotal can reduce program complexity objectives. evidence won’t resolve this issue. and improve programmer Norman Cohen’s concern is A disciplined study is needed. productivity. appropriate for other programming The letter from Lott consistsof Let me close with an observation: languagesthat cater more to compiler three unrelated sections. In the first It is easy to find problems where the writers than to user-programmers. part he describeseight assumptions best known solution with GOTOs that he made when solving the permitted is simpler and/or faster -Conrad Weisert sampleproblem. He fails to men- than the best known solution with tion whether he believes the GOTOs forbidden. The opposite is programmersI surveyed made impossible. The huge responseto my GOT0 similar or opposite assumptions,and letter in the March Communications whether he considersthat good or Frank Rubin shows that this issueis alive and bad. The Contest Center hot. I will keep my remarks about In the secondportion he presents 59 DeGarmo Hills Road the first five letters (Communications, sampleprograms that illustrate Wappingers Falls, NY 12590 May 1987, pp. 351-55) brief, as I many of the things I find objection- know there are many more to come. able about GOTO-less program- Moore makes somevalid points ming: extra flags (az), gratutitous I did not react to Frank Rubin’s orig- about programming language subroutines(allzero), and unneeded inal letter [0], confident that all my features. However, my purposewas recursion (secondprogram). Both of potential commentswould be made not to discusslanguages, but to these programsare inefficient and by others. But in the five letters discussthe GOTO. I chose Pascalas complex. The first is also incorrect published two months later [I], I a basefor comparison becauseit is when the matrix has no zero row, found none of them expressed.So, I so widely known, then devised a and likely to produce addressing reluctantly concluded that I had bet- sampleproblem to fit that language. exceptions. ter record my concerns, big and If I had chosen PL/I or C, I would In the third segment,he repeats small. have devised a different sample the usual claim that programswith (0) The problem statement refers problem. GOTOs are harder to modify than to an N by N matrix X; Rubin’s pro- Musciano makes the point that a those without. I dealt with this issue grams refer to an n by n matrix x. In programmer who meets a GOT0 earlier. other contexts this might be consid- must searchfor the target. In most Starr’s letter presentsa very ered a minor discrepancy, but I casesthe target is nearby. When clever GOTO-less solution to the thought that by now professional labels are outdented from the text, sampleproblem. He usesthis as evi- programmershad learned to be they are spotted instantly. If the dence that I did not give a fair shake more demanding on themselvesand label is distant, online the FIND to GOTO-less programming. It was not to belittle the virtue of accuracy.

August 1987 Volume 30 Number 8 Communications of the ACM 661 I shall stick to the capital letters. zero row of X, if any.” Now, concen- professionalprogrammer in 1987: (1) Rubin still starts indexing the trate to begin with on the “if any”; rows and the columns at 1. I thought nothing should be printed if all 6) should recognize that Rubin’s that by now professional program- rows differ from the all-zero row; problem asksto be solved by a mers knew how much more prefera- formally, if nested application of the same ble it is to let the natural numbers algorithm; (Ai: 0 5 i < N: start at 0. I shall start indexing at 0. (ii) should know the theorem of (2) Rubin’s third program fails for l(Aj: 0 5 j C N: X[i, j] = 0)) “The bounded linear search”; N = 0 (in which case his second pro- (iii) should be able to derive that gram succeeds only by accident- The theorem of “The bounded lin- theorem and its proof; see below. I thought that by now ear search” states for any boolean (iv) should not hesitate to use it; professional programmers would function B on the first N natural (VI should not waste his time in know the stuff the silly bugs are numbers (N 2 0) pointing out that the boolean variable d is superfluous; made of. I[ var f: bool; var n: int (3) Rubin’s second program fails to ; f, n := true, 0 (P) (vi) should keep his repetitions detect the first all-zero row if it is ; dofAn#N+f,n:=B(n), simple and disentangled (vii) etc. the last row of the matrix. n+lod (4) Rubin’s third program relies- IP A (lf V n = N)) Evidently, my priorities are not without stating it explicitly-on the II sharedby everyone, for Rubin’s let- “conditional and,” for which, if the with the invariant P given by ter and most of the five reactions it first operand is false, the secondop- evoked were conducted instead in erand is allowed to be undefined. P: Osn

662 Commur~ications of the ACM August 1987 Volume 30 Number 8 I’ve tried, dammit! I’ve endured can reform presidential appoint- After Nineteen Years the Establishment pinpricks: ments be meaningful, and Council I resigned from the ACM Council ef- 11 years of expense account cheap- elects several key people directly. fective the 13th of October. ness, 20 years of agenda trickery, The restrictive budget can be over- I am the last active charter mem- unanswered correspondence. I’ve ridden or reformed, but only by ber of the Association. From 1947 to struggled against censorship and Council authority. 1961 I served on a dozen ACM com- election nastiness. I’ve sat at the Headquarters is neutral-perhaps mittees, usually in connection with Council table and seen my motion even secretly sympathetic-and it is the joint computer conference spon- to reconsider the cut of 63 percent capable. Notably, the publications sorship. After I returned from my in FY ‘88 chapters support fail for staff can keep Communic&ms of the first European sojourn I was elected lack of a second. I’ve watched the ACM and such afloat if the Estab- a Council member, in Spring of Member-Officer Forum, Headquar- lishment editors rebel, and can help 1968. I have served as member-at- ters and regional newsletters, and salvage Computing Surveys from the large, vice president, president, past other channels to and from the academics. president, and for almost eight years membership close down. Council should restore its third as member-at-large again. Some of it really hurt. My wife meeting, and hold it at SIGGRAPH In the 46 years since its founding, Nancy was thrown off the SIG Board to see what ACM people can do and in over 19 years on its Council, I as soon as I was safely out of the when they get free of the Establish- have had a dream of what ACM presidency. I was excluded from ment. A hundred other changes should be. I wanted it to attract participation in the recent ACM could be made-but only if mem- every serious computer person in conference on the history of scien- bers want it to happen and support a America and many others across the tific and numerical computation. I genuine reform movement. world-and by example define the was walled off from the history The Association for Computing word “professional.” I wanted its panel of the sad, little 46th Anniver- Machinery will survive, but unless governance to be open and demo- sary celebration. it reforms itself, it will dwindle to a cratic. I wanted its members to be self-serving bunch of computer mutually supportive: a band of Enough is enough. scientists-an establishment for the brothers and sisters. Now, how about those of you out Establishment. And no one in the I wanted ACM to be concerned there who still want to salvage the whole great world of computing will with the impact of computers and ACM enterprise? It is not impossible, care. computing on society, and to inter- but it cannot be done by genteel act with our industry worldwide complaints. You will have to capture Herb Grosch and with national, regional and local Council. Mies, Switzerland governments. For two decades I An anti-Establishment caucus have wanted us to withdraw from must put together a reform slate of three officers (president, vice presi- AFIPS and work toward a merger Danger Signals with the IEEE Computer Society. dent and secretary), three members- In the August Forum, p. 658, P.E. In the words of the old vaudeville at-large, and four regional represent- atives They must be nominated by Borkovitz predicts, “Within a few joke, “You just can’t get there from months, . . . PDL tools will be super- here!“. The computer science estab- petition, and all 10 must state in seded by new CASE (Computer- lishment stands grimly across the their campaign material that the slate is running as a unit. Aided Software Engineering) tools path, and Council is its tool. Cur- which will give design engineers If elected in 1988, they would find rently, services to the membership access to a single, fully-integrated, three supporters already seated and (other than publications, of course) monolithic development path.” Lit- some sympathy available from two are being cut back on the grounds of erate readers will notice the warn- others-naming the five in this let- economic emergency, while our ing: a boulder is soon to be rolled ter would be counterproductive. bank balance climbs past $9 million, athwart the way where Dijkstra That means reform power: there are and the final figures for FY ‘87 show would have us strew pearls. a million-dollar surplus versus a 24 votes at the table, with the presi- budgeted loss. Meanwhile the lec- dent voting only to break ties. M.D. Mcllroy tureship program, its funding can- The president appoints most board AT&T Bell Labs celled, struggles along on charity and committee chairmen. But, only 600 Mountain Ave. from the SIGs! if he or she has a council majority Murray Hill, N.J. 07974

9% Communications of the ACM December 1987 Volume 30 Number 12 ACM Forum

The algorithm is correct in the suited to the audience and the The World’s Shortest sense that it is free from deadlock material. Mutual Exclusion Algorithm and at most one process can be in (1) Personally, I use both 0- and This algorithm could have been the critical section. Also, it does not l-origin indexing. l-origin is usually published as a paper 20 years ago, unduly delay a process from allow- simpler, e.g. FOR 1 := 1 TO N is but today it looks crazy and can be ing entry to the critical section pro- cleaner than FOR I := 0 TO N - 1. implemented only on a few antique vided it is free. The fairness is left to I use O-origin if it results in simpler processors. Researchers who com- the process scheduler. subscript expressions, e.g. X[I + I] municated to me privately ex- This algorithm does not work on instead of X[I + I - 11. Use deter- pressed their interest in this algo- multiprocessors or on machines mines form. rithm-perhaps because it is the which do not permit instruction (2) I have never encountered a shortest mutual exclusion algorithm, modification. 1 X 1 matrix in practice. If I were shorter than what they knew of. writing a general purpose subrou- They also indicated that it should Sukumar Ghosh tine for widespread use, I would find a place in the published litera- Department of Computer Science either handle that case, or document ture, better late than never. The University of lowa the restriction N > 1. I cannot think of a better forum Iowa City, IA 52242 (3) The final test should be IF than the Forum to publish it. ALLZERO instead of IF I <= N. The fact that so many people responded Last (Gasp!) GOT0 I. Preamble to my letter, but did not see this er- Several new responses to my GOT0 This algorithm for mutual exclusion ror, supports my view that GOTO- letter have appeared in the June and should have been born at least less programming is not inherently August issues of Communications.* 20 years ago for machines like clearer or easier to debug. Michael Harrison’s July letter sug- EDVAC or its immediate successors (4) My example need not depend gests that GOTOs be introduced by branded as antique by the present on any sort of conditional Boolean transforming GOTO-less programs. standard. This algorithm is unlikely connective. The expression can be This seems the wrong way around. to be used in machines designed fully evaluated. This will not cause Why start with a complex program, after 1970. But, this is the world’s a problem unless the programmer then simplify it, when it is easier to shortest mutual exclusion algo- has turned on index range checking. start simple? rithm-shorter than any I have read (5) All of the programmers I sur- Frederick Bourgeois’s August re- about. It uses self-modifying instruc- veyed used nested search loops to ply proposes forbidding the use of tions to implement spin-lock on a solve the matrix problem. To make GOTOs by inexperienced students. multiprogrammed uniprocessor. The comparisons easier, I have trans- The problem here is you only gain algorithm is as follows: lated Dijkstra’s sample solution into experience through use. Instead, I Pascal. 2. The Solution suggest that students be given pro- Let i be a machine instruction. The gressive assignments, where they c := true; write an original program using any symbol #(i) would be used to repre- i := 0; sent the bit pattern corresponding to style and language features they while c and (i ( ) n) the machine code for that instruc- wish. That program can then be do begin tion. modified to add new features, d := true; The following codes would be ex- change output formats, etc . . In j := 0; ecuted by each process contending this way, students discover first while d and (j ( ) n) for the critical section: hand what practices make programs do begin difficult to modify. d := x[i,j] = 0; trick: trick := #(go to trick); I will devote the rest of this letter j := j + 1; critical section; to the response from Edsger Dijkstra end; trick := #(trick := #(go to trick)]; in the August issue. Let me first an- c := not d; swer his numbered criticisms, then 1 := i + 1; The execution of an instruction in remark on his proposed solution to end; a uniprocessor is an atomic action. the matrix problem. if c The first instruction, while executed (0) The upper/lower case argu- then skip by one process, changes itself to go ment is nonsense. Just as I use dif- else print (L - 1); to trick and this blocks all the other ferent styles in my puzzle magazine contending processes by forcing The survey programmers produced and in Communications, so I use dif- them to execute a self-loop. Eventu- both l- and 2-flag versions. Two pro- ferent styles for problem specifica- ally, when the first process com- grammers first wrote Z-flag pro- tions and programs. Each style is pletes the critical section, it restores grams, then eliminated the unneces- the first instruction to its original sary flag. I used the simpler l-flag form. As a result, another process ‘July 1987 Technical Correspondence. pp. 632-4: can enter the critical section. August Forum. pp. 659-62. [continued on p. 1085)

December 1987 Volume 30 Number 12 Communications of the ACM 997 Calls for Papers

Language for Automation: Symbiotic and ity Products International, Rocky Glen Mill, hy f5 Intelligent Robotics, University of Mary- 75 Glen Rd., Sandy Hook, CT 06482; (203) 3rd International Conference on Data and land, College Park, MD, August 29-31. Sub- 426-1875. Knowledge Bases: Improving Usability and mit 4c. of complete papers (20 pages maxi- March 15 Responsiveness, Jerusalem, Israel. June 28- mum) to Prof. P.A. Ligomenides. Electrical 8th International Conference in Computer 30. Organized by Information Processing Engineering Dept., University of Maryland, Science, Santiago de Chile, July 4-8. Submit Association of Israel in cooperation with College Park, MD 20742. IOC. of extended abstract (10 page maxi- ACM SIGMOD. For information concerning submission, contact Katriel Beeri, Data Base March 1 mum) in English, Spanish or Portuguese to Albert0 Mend&on. CSRI, University of To- 88, P.O. Box 29313, Tel-Aviv 65121, Israel, ICDT 1988: International Conference on 02-585266. Database Theory. Bruges, Belgium. August ronto. 10 King’s College Rd., Toronto, Can- ada M5S lA4 31-September 2. Submit 6~. of full paper to May 16 Dirk Van Gucht, Computer Science Dept., March 30 8th Conference on Foundations of Soft- Indiana University. Bloomington, IN 47405. 9th Annual International Conference on ware Technology and Theoretical Com- Information Systems, Minneapolis, Minn. March 15 puter Science, Pune, India. December l4- November 30-December 3. Sponsors: TIM& 16. Sponsor: Tata Institute of Fundamental CONCURRENCY 88, Hamburg, Fed. Rep. of SIMS in coop. with ACM. 4~. of papers Germany, October 18-19. Submit 5c. of pa- Research Developement & Design Centre. (maximum 25 pages) to Margaret H. Olson, Submit 4~. of full paper (maximum 5000 per (25 pages maximum) to Friedrich Vogt. Program Chair, Graduate School of Busi- Fachbereich Informatik, Universitat Ham- words) to K.V. Nori, TRDDC, 1 Mangaldas ness Administration, New York University, Rd., Pune, India: Tel: (212)-61608,Telex: burg, Bodenstedtstr. 16, D-2000 Hamburg 90 Trinity Place, New York. NY 10003. 50, FRG, Tel: +49 40 4123-6060/61. 0145-464. May 10 March i5 3rd International Conference on Fifth OOPSLA 88, San Diego, Calif., September Generation Computer Systems, Tokyo, Ja- Directions and Implications of Advanced 25-29. Submit 5~. of 25 double-spaced pan. November 28-December 2. IX. of 5000- Computing, St. Paul, Minn., August 21. pages (approx. 4500 words). a cover sheet word manuscripts and 250-word abstracts Submit 4~. of complete papers including ab- including authors’ names, addresses and to Hidehiko Tanaka, FGCS ‘88, Program stract (6000 words maximum) to Nancy telephone numbers, and 100 word abstract Chair, ICOT, 28 Mita Kokusai Bldg.. l-4-28 Levenson, ICS Department, University of to Kurt Schmucker, OOPSLA 88, Productiv- Mita, Mianto-ku. Tokyo 108 Japan. California, Irvine, CA 92717.

ACM Forum (continued from p. 997) version in my letter to be fair to the disguised GOTO. The Z-flag pro- in Dijkstra’s reply, which seemed to GOTO-less advocates. grams in my survey avoided this be a scattershot attack on everyone Dijkstra’s solution is similar to the awkwardness by reversing the sense else who wrote. Z-flag versions, with minor differ- of the outer flag, e.g. IF ZERO- ences. All of the survey program- FOUND THEN PRINT. Frank Rubin mers used an IF to test for zero ele- Such differences aside, I do not The Contest Center ments. Dijkstra’s D := X[Z, I] = 0 is see how Dijkstra’s sample program 59 DeGarmo Hills Road syntactically simpler, but obscure. I shows that GOTO-less programming Wappingers Fall, NY 12590 usually avoid that construct. is any simpler or more readable. Dijkstra uses I ( ) N as a loop ter- Rather, the notational quirks of his With this second rejoinder from minating condition. This is often un- example, like starting lines with Frank Rubin it seems expedient to safe, since statements inside a loop semicolons and interleaving assign- bring to a close the publication of might cause I to skip the value N. It ment statements, seem most inscru- correspondence generated by his is better to use I < N. table. I was amused to note that 11 March 1987 Forum letter, greater I presume that the SKIP in the fi- of the 13 programmers in my survey response by far than with any nal IF is some form of null state- produced better solutions than his. other issue ever considered in ment. Thus, it serves as a type of Overall, I was very disappointed these pages-Ed.

December 1987 Volume 30 Number 12 Communications of the ACM 1055