nmouawad@watmath.waterloo.edu (Naji Mouawad) (01/04/91)
Having to prepare for my Comprehensive Exams, I had to read MacLennan's "Principles of Programming Languages: Design, evaluation and implementation:". While the book is written for an introductory course in Programming Lanuguages, it reads like a novel. Maclennan opted for a historical presentation, starting with Fortran and closing with Prolog. The book could serve as an excellent example to anyone who wants to write a manual, or a technical book. Maclennan motivates each chapter carefully; enough to keep us reading, not too much to bore us with sublte details. His writing is synthetic, meaning that he always favors a panoramic view of a given language over in-depth study of some aspects of the language. This aproach has the added advantage of easy comparisons of language's feature (Common blocks in Fortran, blocks in Algol and variant records in Pascal). I'd recommend this book to anyone who is interested in or curious about the birth (and death ?) of Programming Langugages. All that is very nice, you might say, but what does it have to do with comp.lang.pascal ? Glad you asked :) MacLennan lists a set of Principles that should govern the creation and development of a good language. I tend to agree with most of them and while reading the book, I was constantly applying these rules to Turbo Pascal and to C. How each fared ? I'll let you find out. Here is the set of Principles. Being a person who believes that 'objectivity' is nothing more than 'polite subjectivity' :) I've put a star [*] in front of those principles I think are important. Enjoy ! 1. Abstraction [*] : Avoid requiring something to be sated more than once factor out recurring patern [e.g. use procedure, functions and don't be forced to declare a variable more than once (contrary to Fortran)] 2. Automation [*]: Automate mechanical, tedious, or error-prone activities. [e.g. Tubro Vision :) ] 3. Defense in Depth [*]: Have a series of defenses so that if an error isn't caught by one, it will be caught by another. [e.g. first defense is syntax checking, second is range checking, etc] 4. Information Hiding [*]: The language should permit modules designed so that (1) the user has all of the information needed to use the module correctly and nothing more; (2) the implementor has all of the information needed to implement the module correcly and nothing more. [e.g. units] 5. Labeling [*] : Avoid arbitrary sequences more than a few item long; do not require the user to know the absolute position of an item in a list. Instead, associate a meaningful label with each item and allow the items to occur in any order. [e.g no fixed order in the paramerter passing. procedure f(var x, y real; c : char); could be used as follows: f(c => ch, x => RealPart, y => ImaginaryPart); where ch, RealPart, ImaginaryPart are three variables declared in the calling environment of 'f'. ] 6. Localized Cost [*]: Users should only pay for what they use: avoid distributed costs. [e.g. no side effect, and no global variables changed in the body of a deeply nested sub-routine.] 7. Manifest Interface [*]: All interfaces should be apparent (manifest) in the syntax. [Ahem ... sorry guys, but I cannot but think of how takes care ot that one :)))))))) ] 8. Orthogonality [*]: Independent functions should be controlled by independent mechanisms. [left as an excercise :) ] 9. Portability: Avoid features or facilities that are dependent on a particular machine or a small class of machines. [Well, we all know what this one means, don't we ?] 10.Preservation of Information[*]: The language should allow the representation of information that the user might know and that the compiler might need. [e.g. readalbe and efficient code ...] 11.Regularity[*]: Regular rules, without exceptions, are easier to learn, use, describe and implement. [No comment.] 12.Security[*]: No program that violates the definition of a language, or its own intended structure, should escape detection. [No comment.] 13.Simplicity[*]: A language should be as simple as possible. There should be a minimum number of concepts with simple rules for their combination. [No comment.] 14.Structure[*]: The static structure of a language should correspond in a simple way with the dynamic structure of the corresponding computation. [This is a rule agains binding by name, for those of you who know the difference between by name, and by reference.] 15.Syntactic Consistency[*]: Similar things should look similar; different things different. [Yep. One of the reasons why I like Pascal.] 16.Zero-One-Infinity[*]: The only reasonable numbers are zero, one and infinity. [That is, there should not be a rule that works for special number like '3' or '47']. That's it folks. I sure am happy to program in Turbo Pascal ! --Naji. -- ------------------------------------------------------------------- | Naji Mouawad | nmouawad@watmath.waterloo.edu | | University |---------------------------------------------------| | Of Waterloo | "The Stranger in us is our most familiar Self" |