SP/K: a System for Teaching Computer Programming R.C

SP/K: a System for Teaching Computer Programming R.C

Reports and Articles SP/k: A System for Teaching Computer Programming R.C. Holt, D.B. Wortman, D.T. Barnard, and J.R. Cordy University of Toronto SP/k is a compatible subset of the PL/I language 1. Choosing a Programming Language that has been designed for teaching programming. The features of the SP/k language were chosen to Each year many thousands of students take courses encourage structured problem solving by computers, in introductory programming using a variety of lan- to make the language easy to learn and use, to guages, equipment and teaching materials. This paper eliminate confusing and redundant constructs, and to presents a carefully worked-out system intended for use make the language easy to compile. The resulting in these courses. The system consists of a language language is suitable for introducing programming called SP/k, SP/k processors for both minicomputers concepts used in various applications, including busi- and large computers, and textbooks. ness data processing, scientific calculations and non- The first major decision in the development of the numeric computation. SP/k is actually a sequence of system was the selection of a suitable introductory language subsets called SP/1, SP/2,... SP/8. Each programming language. We felt the language should subset introduces new programming language con- meet these criteria: (1) it should be (part of) a "real" structs while retaining all the constructs of preceding programming language used in business, science, and subsets. Each subset is precisely defined and can be government and should be appropriate for introducing learned or implemented without the following sub- programming concepts used in those areas, (2) it sets. should encourage systematic problem solving and Key Words and Phrases: programmer education, structured programming, (3) it should be a small, con- universities, community colleges, high schools, PL/I, venient, easy to master language, and (4) it should be SP/k, minicomputers, programming language design, easy to support by economical, diagnostic language teaching programming, introductory computing processors on a variety of machines including minicom- CR Categories: 1.5, 4.2, 4.12, 4.13 puters. Given the constraint of using a "real" language, Fortran must be considered carefully, because it is one of the original high-level languages and is the de facto standard language in many programming applications. Certainly, it is possible to teach programming using as crude a tool as standard Fortran, but it requires extra time and effort in a programming course. Clumsy lan- guage features too often distract students from learning orderly methods of program construction. In a course directed at teaching programming concepts, and not Copyright © 1977, Association for Computing Machinery, Inc. just language details, it seems appropriate to abandon General permission to republish, but not for profit, all or part of this material is granted provided that ACM's copyright notice is given and standard Fortran in favor of a language that provides that reference is made to the publication, to its date of issue, and to structured and convenient facilities such as while loops, the fact that reprinting privileges were granted by permission of the simple input-output, character string manipulation, Association for Computing Machinery. Authors' address: Computer Systems Research Group, Univer- records, and nested procedure definitions. After pro- sity of Toronto, Toronto, Canada M5S 1A4. gramming and its associated structuring methods have 301 Communications May 1977 of Volume 20 the ACM Number 5 been'mastered, it is a simple matter to learn the limita- SP/k was designed-and PL/I pruned-by omitting tions and idiosyncracies of standard Fortran. and restricting language constructs to minimize: Cobol is also a widely used language that must (1) Redundant constructs. Where PL/I provides eventually be learned by many programmers. How- several equivalent mechanisms, all but one were elimi- ever, its pedagogic and linguistic limitations make it a nated. For example, the PL/I programmer can use poor introductory language. either binary or decimal numbers; this choice is elimi- The fact that Basic is implemented on many mini- nated in SP/k, thereby removing some technical trivia computers and has an extremely simple syntax makes it from the classroom. Generally, constructs were omit- attractive. A student can learn Basic more quickly than ted unless there was a pressing reason for keeping a language like Algol 60. But he is then hampered by them, so the student would have less to memorize and inept language constructs, such as non-mnemonic vari- the compiler could be smaller. able names, when he tries to solve nontrivial program- (2) Unpleasant surprises. Perhaps the best known ming problems. Basic seems to be even less appropriate unpleasant surprise in PL/I is the expression 25+1/3 than standard Fortran for teaching programming con- which evaluates to neither 25 nor 25.333 . but to cepts. 5.333 .... Other notable examples involve anomalies Algol 60, Algol-W [1] or Pascal [17] may be chosen in implicit conversions among decimal numbers, binary because of their cleanliness and elegance. But for many numbers, logical values, and character strings. These educators, students, and employers the advantages of a surprises are weeded out by SP/k constraints upon the more widely accepted language outweigh any advan- offending constructs. These constraints allow an SP/k tages of additional elegance. And the temptation to processor to do a better job of automatically diagnosing invent YATL (Yet Another Teaching Language) which a class of subtle programming errors. is supposedly "ideal" for teaching programming con- (3) Easily misused constructs. Pointers and go to cepts, should certainly be resisted. statements are not appropriately constrained in full The PL/I language has the advantages that it in- PL/I and are eliminated in SP/k. cludes reasonably good programming constructs and is (4) Constructs suited for more advanced program- widely used-though not as widely used as Fortran or ming. PL/I has constructs that are useful in particular Cobol. Because of these advantages, we chose to make programming situations, but are not needed in an intro- our introductory language (SP/k) a subset of PL/I.'The ductory course. Perhaps the most notable examples are disadvantages of PL/I are that the full language in- compile-time processing and concurrent programming cludes peculiar and anomalous features and is expen- (multitasking); these are omitted from SP/k. sive to process [10]. These disadvantages can be over- (5) Difficult to compile constructs. One unpleasant come if PL/I is appropriately restricted, leaving a sub- aspect of full PL/I is its convoluted set of arithmetic set language whose size and elegance is comparable to precision rules. Mechanisms like these greatly compli- Algol 60. (Also see Gries' argument [9] for teaching a cate a compiler, and they also confuse the programmer. subset of PL/I.) Various restrictions in SP/k, especially the omission of scaled arithmetic, remove this confusion and simplify the compiler. Generally, considerations (1) to (4) have 2. Design of the SP/k Language led to a clean, easy to compile language subset; few of the language restrictions of SP/k were dictated by im- plementation concerns, although we kept these con- PL/I satisfies our criterion that the introductory cerns in mind throughout the design of SP/k. language should be a "real" language, and PL/I in- As (1) to (5) show, in many ways a "less is better" cludes modern constructs, such as while loops, which attitude was taken in designing SP/k. Very briefly, we help in writing well-structured programs. However, it will now give the restrictions on and omissions from full must be extensively pruned to produce a subset that PL/I. In SP/k every variable must be declared. These satisfies our other criteria that the language be easy to declarations are not allowed to specify number bases learn and use and easy to process. (binary versus decimal) or precisions. Implicit conver- The subset language should be "complete," mean- sions are not allowed among numeric, logical, and ing that it should be a language in its own right (inde- character types. Constructs implied by the following pendent of omitted PL/I constructs) and it should be keywords are omitted: binary, complex, initial, exter- convenient for programming at the introductory level. nal, pointer, goto, on, and begin. The following con- It should be a small, clean language, so a student structs are eliminated: fixed-length character strings, spends less time memorizing and choosing among lan- label variables, operations on entire arrays or struc- guage constructs and more time concentrating on pro- tures, pseudo-variables, data-directed input-output, gramming, and so he can master the language, gain static allocation, controlled and based allocation, mul- confidence in using it as a problem-solving tool, and titasking, and compile-time processing. These omissions progress to more important matters such as algorithm and restrictions characterize SP/k as a pruned version design. of PL/I; in the next section, we describe SP/k as a 302 Communications May 1977 of Volume 20 the ACM Number 5 language in its own right by listing its included constructs. duces arithmetic: plus, minus, multiply, divide, sin, Although many constraints are placed upon PL/I, square root, etc. The only statement is put list, which is the SP/k language remains a compatible subset of PL/I, used to print either values of numeric expression s or meaning that correct SP/k programs generally run with character string literals. This subset gives the student the same results under a variety of manufacturer-sup- immediate access to the computer. This access is fun, plied PL/I processors. SP/k is also a compatible subset but more importantly, it provides concrete examples of of the PL/I language as it is presently defined by the concepts such as "program preparation," "source pro- international PL/I standards committee [7].

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us