The recent Slashdot 'debates' on whether teaching Java at university is dumbing down the coursework had me thinking about Brian Kernighan's essay Why Pascal is Not My Favorite Programming Language.
Kernighan makes some pretty good points against Pascal, many of which I discovered independently when I first tried to use it for coding a video game and was subsequently forced to use it for a class project. ANSI Pascal was at the time utterly unusable for any serious project because the size of an array was part of its type. There was no way to write a general matrix arithmetic capability in Pascal because you would have to write separate code for arrays of size 2, 3, 4, and so on. String handling was utterly beyond reason.
Pascal became a popular teaching language in spite of these obvious and acknowledged defects. Given the pot shots being taken at Java it is worth remembering how Pascal scored over its competitors in the early to mid 1980s when it became the educational language of choice:
- FORTRAN lacked structured variables, call by reference and structured programming constructs.
- Basic lacked structured programming constructs
- C was considered ugly, in particular the macro processor and the exposure of messy pointer constructs which broke attempts to define a formal semantics as well as being difficult to learn.
- Ada was considered far too complex for use as an introductory language.
- Functional languages such as LISP were not practical on microcomputer class hardware.
- FORTRAN and C compilers were expensive, TurboPascal was dirt cheap.
Pascal was chosen for three reasons then: the compilers were cheap, it supported the language features the courses were meant to teach and it avoided pointers.
These reasons hardly sit well with the reasoning for the claim that teaching Java is destroying Comp Sci by dumbing it down. The only advantage of Pascal over C as a teaching language were cheaper compilers and the lack of pointers
At the time the prejudice against pointers in academia was real. Pointers could not be modeled using any of the formal methods techniques. Pointers were messy, programs that used them tended to be unreliable and difficult to debug.
Pascal did not have the field entirely to itself of course, but the hold outs were for languages that were more like Java than Pascal or C.
MIT has taught programming using LISP in the guise of Scheme for many years, but this probably has more to do with the origin of LISP than its merits as an educational language and course 6.001 is in any case taught as a perisher course. MIT course 6 can get away with it because it is MIT course 6. Most US university departments would be sanctioned for that approach. The students are paying to learn, not to have the professors take an ego trip.
I have also heard of places where smalltalk was taught as the introductory language over Pascal. By the early 90s there were smalltalk environments that would run on a moderately expensive workstation. This approach had become feasible.
The arrival of Java marked the first time ever that a mainstream production programming language was also an acceptable choice as an introductory programming language. It is hardly any wonder that pretty much every introductory course now uses it. Java is clearly the best choice for the task by a long way.
There is a demand for obsolete programming languages. But that alone is not reason for universities to teach them. Most obsolete languages, COBOL, Fortran, etc. should be taught in trade schools if at all. The code you are going to be working with in those languages is almost certainly going to turn out to have been plugged out by a self taught coder, it can be maintained by a self taught programmer.
C occupies a slightly different space, there are times when a high level assembly language is what is needed. I would certainly not teach C as an introductory language but it would certainly be something that a systems programmer should know.