Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.sys.apple2 Subject: Re: Any Pascal programmers for Apple II GS? Message-ID: <16114@smoke.brl.mil> Date: 11 May 91 01:20:55 GMT References: <52593@apple.Apple.COM> <14308@ucrmath.ucr.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 62 In article <14308@ucrmath.ucr.edu> rhyde@ucrmath.ucr.edu (randy hyde) writes: >Two comments- most optimizations are language independent. Things like >common subexpressions, loop invariants, etc. That's all correct, within the context of "Algol-like" languages. On several systems, compilers for languages like Fortran, Pascal, and C all share a common "back end" (optimizer and code generator), with only the "front end" (language parsing and semantics) differing. >The fact that Pascal has been around longer than C isn't true. C was >actually created in the late 60's and very early 70's. pascal was invented >shortly thereafter. A preliminary version of Pascal was drafted in 1968, the first Pascal compiler became operational in 1970, the Pascal User Manual and Report was published in 1971, the Revised Report was published in 1973, and the second edition of the Pascal User Manual and Report was published in 1974. C was created in 1972 (via evolution from B, which was written in 1970), and during 1977 work on porting UNIX led to refinements that are reflected in the first edition of K&R's "The C Programming Language", published in 1978. Thus, Pascal is a couple of years older than C. >More research has gone into optimizing C compilers, >which is why C compilers, today, generally produce better code than pascal >compilers (MPW Pascal is an obvious exception). I don't know that any blanket statement can be made, other than that obviously compilers that get more attention have a good chance of producing better code. A lot of Apple developers came from a Pascal heritage (PARC, etc.) and thus cared more about their Pascal compilers than C compilers. In recent years in the IBM PC world, C has received more attention than Pascal. >Second-- Pascal, theoretically, can be optimized better than C. C allows >unbridled use of pointers. It is very difficult to optimize such code >(correctly) I don't know what "unbridled" is supposed to mean, but optimization is not all that difficult, just constrained to take possible aliasing into account. Pascal also supports pointer types. Their main differences from C are: (1) There is no "address-of" operator in Pascal; instead, pointed-to variables (but not the pointers themselves) must be dynamically allocated by "new". (2) There is no automatic conversion of a reference into a pointer. This is particularly evident when passing a parameter to a function. The optimization issues are similar. Pointer value parameters and variable parameters in Pascal can be aliased, and code generation needs to take this into account, just as for C. >If Pascal were commercially viable and people were to put the same research >into Pascal as they do into C, code generators for pascal would probably be >a little better than those for C. Pascal HAS been commercially important, particularly in Europe. Again, I don't think there is any point in trying to make blanket judgements about the quality of code generation for Pascal vs. C.