has a number of flaws. Naming of internal functions I don't count
as one of them--that's a quirk
, not a flaw. I can deal with irregular
function names. (And Even the unix creators admit that creat
of their biggest mistakes.)
No, pascal has much more serious problems. As others have noted, Borland's Turbo
Pascal fixed a lot of problems with pascal. Most of these complaints
are more relevant to UCSD pascal and BSD pascal.
Let me repeat myself, since Strawberry Frog didn't read the previous comment the first time. These complaints refer to the original pascal made available by UCSD, BSD, and
others. Even late versions of Turbo Pascal, prior to Delphi fixed some of
these, and no, Delphi is Delphi, NOT pascal. It's a
different language. That's like saying that complaints about C are wrong because C++ fixes them. No. As to
moving this to the the node on Kernighan's paper, that would
be wrong too, as this is NOT a summary of his complaints,
but my own list, in my own priority order, with a few of
his (that I agree with) added.
Here's the flaws
I remember and some fragments from Brian Kernighan's paper
Why Pascal is Not my Favorite Programming Language which is well
worth reading, and better organized than this rant.
- The standard library has functions with a variable number of
arguments, but the language doesn't support creating new ones.
- The standard library has a very limited number of useful functions,
and not enough to make it easy to add new ones. (Borland fixed this
Overall, pure pascal is not extensible,
and any attempts to fix this make it unportable.
- The syntax of the language is weak in the area
of function/procedure declarations and array types, and thus forces you
to create type aliases just so you can pass arrays and other complex
types. Variable sized
arrays are not supported. Even ForTran does this better.
- Sometimes you need a ; and sometimes you don't. Putting in an extra
one could change the meaning of the statement (like in C), but usually
it's a syntax error. The rules for this are non-trivial, and confusing
to many beginning students. Perhaps it makes them pay attention to
detail, but it's very annoying.
- If you separately create two type aliases that are identical, you
still can't assign a variable of one type to the other, even though they
are identical. Some implementations may fix this.
- Some input formats are impossible or nearly impossible to read with
pascal's I/O primitives. Similar things can be trivial in C.
(Specifically, reading an input stream with unpredictable mixed numbers
and text is impossible without reading it character by character and
reimplementing pascal's number reading primitives.) But at least you
don't have to do an implied do loop to read in an array from a file,
like in ForTran.
- A well kept secret: pascal has pointers. They are horrible to
work with. The syntax is ugly and confusing, and they don't do very much.
(And I *like* pointers in C.)
- String handling in pascal is cumbersome, at best. Not because of
misnamed functions, but because of strict type checking.
Some pascal implementations add a string type, which helps slightly.
- Initializing an array must be done by individual assignments.
You can't have a big blob of pre-initialized data, like in C. This is
unbelievably annoying when it is needed. Even ForTran did better than this.
- Kernighan complaints about lack of goto, break, and return.
I can excuse goto, but break and return are
very important, and the lack of them causes more contorted code than
the presence of goto.
- Kernighan complains about lack of short cut logic operators (like &&
and || in C), which makes it impossible to do both bounds checking
on an array index and check a value in the array in the same logic expression.
- Kernighan complains about lack of default in case,
undefined loop indexes outside of the loop,
total lack of type casting,
and missing bitwise operators. The last two prevent pascal from
being a good systems programming language (along with the other flaws).
Pascal was designed to be a learning language. It is fairly good for that,
although it is being displaced by something better -- Java.
Pure pascal without Borland's extensions is completely useless for anything
else, mostly because it has no means for extending the language.
Even with Borland's extensions, most of the problems above are not fixed,
but it is at least usable outside of the teaching environment.
The strongest measure of a language is, of course, can you write a compiler
for it in itself. I think it is telling that most pascal compilers are
written in C.
Kernighan's biggest complaint about pascal is that there
is no way to extend it--including separately compilable
or externally linkable object code. His next biggest
complaint is that all attempts to fix these problems were non-standard and therefore unportable. Delphi fits into
this latter catagory. As to Turbo Pascal fixing most
of these, last I checked, it hadn't, and if it fixes any of 1, 3, 4, 7, 8, 10, or 12 above, it has mangled it beyond
it being pascal (which would be a good thing admittedly).