From: Louis Krupp Date: 2003-04-11T18:07:44+09:00 Subject: Re: Programming Languages Wiki Ruby entry. In article <20030410172214.GA1378@jupp%gmx.de>, jupp@gmx.de says... > C allows for very complex agglomerates of ++, --, * that at first, > second and third sight look okay but at fourth sight reveal some > unexpected (and perhaps dangerous) side effects. COBOL on the other > hand requires you to write lengthy prosa that is unreadable due to > its length: > > perform test before "test before" is the default and could have been omitted. > varying i from 1 by 1 > until i = 5 > > add i, 1 giving j This line seems to be redundant. > perform test before varying j > from i by 1 > until j > 5 > > if cash(i) > cash(j) then > move branch(i) to tmp1 > move cash(i) to tmp2 > > move branch(j) to branch(i) > move cash(j) to cash(i) > > move tmp1 to branch(j) > move tmp2 to cash(j) > end-if > end-perform > end-perform I think it's perfectly readable. Nice work; I don't think too many people can write COBOL *and* Ruby. > > In Ruby you would probably write this as: > > 1.upto(5) { |i| > i.upto(5) { |j| > if cash[i] > cash[j] > branch[i], branch[j] = branch[j], branch[i] > cash[i], cash[j] = cash[j], cash[i] > end > } > } > > You would not consider using temporary variables, would you? No, but then I'd probably figure out a way to use a sort method. COBOL has a sort verb, too, but it would probably be awkward in this situation. COBOL has its place and is here to stay. I'm not sure you'd want to write a banking application in Ruby; there are performance considerations if nothing else. It would be interesting to speculate on what COBOL would be like if it were designed today. Would it be less verbose? Possibly. Would it be a substitute for, say, Ruby? No, not any more than Ruby could take the place of COBOL. Louis Krupp