Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!usc!orion.cf.uci.edu!uci-ics!ucla-cs!math.ucla.edu!sonia!pmontgom From: pmontgom@sonia.math.ucla.edu (Peter Montgomery) Newsgroups: comp.lang.misc Subject: Re: Which language to teach first? Message-ID: <1610@sunset.MATH.UCLA.EDU> Date: 23 Aug 89 07:27:18 GMT References: <193@enea.se> Reply-To: pmontgom@math.ucla.edu (Peter Montgomery) Organization: UCLA Mathematics Department Lines: 48 In article <193@enea.se> sommar@enea.se (Erland Sommarskog) writes: >Herman Rubin (cik@l.cc.purdue.edu) writes: >>The fundamental operations are not limited to those in C, and the operations >>in a language are not all fundamental, for a specific computer. Students >>should learn that which operations are hardware, and how fast they are, >>affect the algorithm to be used. > >Certainly not in their first year anyway. I'd say that the newly >graduated should have some understanding of these topics, however >there are much more important things like data abstraction, writing >reuauble code etc. One reason is that not all the student will ever >face that kind of problems. If you into information systems, you're >interest in the hardware operations are low. There are so many other >complexities that you could live without another. > I resent that this was NOT covered in my first course, a FORTRAN/ALGOL course in 1967. Two years later, without having taken another course, I was vending machine manager at my dormitory and took a poll on who liked which candy bars. For each member and candy bar, the program had an array element identifying whether he liked it, i.e., like(John, Snickers) = 1 if John likes Snickers, else 0 The program tallied not only the number of votes for each item but also the statistical correlations between who likes what (e.g., are Hershey's and Nestle's Milk Chocolate liked by the same folks?). So for every pair of candy bars c1 and c2, I computed SUM like(p, c1) * like(p, c2) (p runs over all ballots) p The run cost about $30, a considerable amount in those days. What I did not know (but learned when I took an assembly language class) is that the machine (a CDC 6400) lacked an integer multiply (even though the languages had that operation): the operands had to be converted to floating point, multiplied together (a slow operation), and converted back every pass though the main loop. Since all values were 0 or 1, I could have used a bitwise AND in place of the multiply, but I had not been taught this operation (admittedly, it is not standard FORTRAN). This alone would speed the program considerably; the program could be shortened much more by using one AND in place of 60 multiplications (with appropriate change in storage of data) and by using the machine's population count instruction in place of 59 additions. -------- Peter Montgomery pmontgom@MATH.UCLA.EDU