Reading this essay about Pascal recently (July 2001) was an odd experience. I have been programming seriously in Delphi since 1995 or thereabouts, and I
wondered if Brian Kernighan and myself are talking about the same language here. Many would claim that we aren't - see Object Pascal.
However this subtle distinction is far beyond many geeks- I regularly see posts on Slashdot claiming that Delphi is bad because of "Why Pascal Is Not My Favorite Programming Language". In most of the cases, Kernighan's criticisms are flat wrong with respect to what we use today:
- There is no 'break' statement for exiting loops - you mean except for the break and continue
No default cases on a case statement - yes there is, there is an else case - I use it regularly.
- There is no 'return' statement - you mean aside from
Result := SomeValue; exit;
- There is no goto, in case you need it. Wrong.
- No bitwise operators. Likewise wrong.
- Initializing an array must be done by individual assignments. Nope, wrong again.
- Then there is the infamous "there is no way out" statement,
which claims that Pascal has no hard type coertion, for those sticky situations
when you just have to get down & dirty and mung a pointer into an int or
back again. What is
liSomeInt := Integer(pSomePointer);
then? It works for me.
- Variable sized arrays are not supported Uh, nope, another wrong one.
I could go on here but it is repetitive.
These may have been valid criticisms in 1981, but
they weren't in 1995, and they sure aren't now. The original Pascal was intended for purely teaching purposes, and it is likely that these features
appeared as it grew into a fully-fledged general-purpose programming language.
This article was at best some valid criticism that was addresed
many years ago and is no longer valid, even though the hacker's dictionary claims otherwise. The fact
that it is still read and has some credibility in geek circles can perhaps be ascribed to
Eric Raymond's endorsement if it in The hacker's dictionary entry for Pascal, and is
a triumph of hero-worship of both Kernighan and Raymond over fact.
Kernighan's most valid point is that these changes, not being past of the original standard language, will be addressed by mutually incompatible extensions by different vendors but thereby destroy Pascal's portability and
standardisation. Sadly, this has in fact happened, and Borland/Inprise is the only Pascal vendor left of any significance in the Windows world. In fact, Borland Pascal is a de-facto standard Pascal these days.
Object Pascal is a language with some legacy baggage and some regretable quirks, but nothing on the scale of the flaws claimed here.
So why wasn't standard Pascal extended? It's creators went on to Modula, Eiffel and Oberon instead, which unfortunately never caught on to the extent that Pascal did.
Java is a better teaching language these days, and far more sought after in the job market. However, any graduate in Computers should know several languages, in order to understand their differences and commonalities.
This writeup has been hotly disputed by some.
Ariels says: None of your comments on Kernighan's paper are correct. You refer to Delphi, a single vendor nonportable mutation of Pascal. All his points (except variable-sized arrays) hold in Pascal. Extensions are always a bad idea. It's basically as nonportable as you can get, unlike C or even Fortran.
In that case, Pascal is a dead language - long live Delphi, and other languages derived from Pascal.
While Ariels has a point, I would prefer a usable language over a portable and standard one that was unusuable. What Ariels would consider to be the rot set in in Borland Turbo Pascal, long before Delphi. And yes, Pascal is unfortunately no longer a standard language. (Though Object Pascal is currently portable to Win32 and x86 Linux.)
Ariels, being a mathematician, defines pascal as an old standard, and does not admit a looser definition, in which the strongest decendant has claim to the language's title. Unfortunately the looser definition is also in common use, so many people seem to think that Kernighan's criticisms apply to languages in use today.