Thursday, 1 February 2001

Death of Pascal

Listening to:

Mozart, string trio (divertimento) in E flat, KV 563. And there I was claiming that Mozart’s letter was K. I think the V here is the same as the V in Bach’s BWV, and that it means something like catalogue. The music is great in any case.

Perl Scripts and Pascal

I have re-organised my archived weblog entries so that reading down the page does move the reader forward in time. I have also added next month and last month buttons to them all, just as I have done here. To achieve the reordering I used the following Perl script:

$/ = "<hr>\n";

while (<>) { $foo[$i++] = $_; }
while ($i > 0) { print $foo[--$i]; }

(Historical accuracy forces me to admit to the above, but it would have been even more idiomatic if I’d used Perl’s push and pop functions.) My code assumes that the entries are delimited by <hr> (horizontal rule) elements. There’s also a whole bunch of stuff in front of the listing of the entries (the table setup, etc), and some after it. But this didn’t really matter because I used the facility in Emacs whereby you can select a region of text, pipe it to some external program, and have the program’s output replace what you had there originally. (Lest I be accused of editor-zealotry, let me add that you can do the same thing in vi.)

Before I leave you for the week, let me first say a few words about this article, another one from Salon about programming languages. This one is about the language Pascal, and how it’s gradually dying out. I don’t have too much problem with this report; it seems that Pascal really only holds out in the Delphi product. However, I really barfed at the following paragraph:

Pascal took a very mathematical approach to creating software: It forced the programmer to specify the type of each piece of data. That is, the programmer had to spell out whether variable x held some text, an integer or a real number. This didn’t prevent the programmer from doing something stupid like dividing by zero, but it allowed the compiler to stop the computer from doing something really stupid – like trying to multiply the word “rabbits” by 23. After Pascal’s birth in the early ’70s, the mathematicians in university computer sciences grooved on the complicated hierarchies created by type-checking a program.

As any reasonably qualified computer scientist could tell you, Pascal’s type system is not very mathematical at all. It certainly doesn’t feature any of the complicated hierarchies that get the type theorists going. It’s certainly a deal less sophisticated than the system in C++. But, if you want real sophistication, you use a language like SML, where you don’t need to specify the types of many variables at all, because it figures them out for you, using what’s known as type inference, but where you still get such groovy features as parametric polymorphic and higher order functions. (Check out this outline of a nice talk, for an explanation of what strong typing really is, intended for an audience of Perl people.)

And now for another bogosity:

Meanwhile, Pascal’s development splintered as people argued over the right way to do things. It’s almost as if the Pascal community acted like the French by defending the purity of their language – while the C++ world acted like the English, promiscuously absorbing words from other languages.

If Pascal was splintering, it can hardly be said to have been doing a great job of defending its purity. If it was splintering, it was in fact doing a reasonable job of trying to find itself a niche, with little regard for purity. Maybe Delphi is its only viable niche, right now, but hey, it’s a perfectly reasonable niche. The argument’s crap but just look at the way this author is setting up a really dirty set of connotations with which to tar Pascal. In the first paragraph, it’s academic and mathematical. (Real programmers don’t do maths, sheesh!) In the second, we cunningly associate Pascal with France, that well-known bastion of anti-capitalist un-American head-in-the-sand isolationism.

Disclaimer: Pascal was my first real programming language, but I haven't written in Pascal since 1990, and have no desire to ever do so again.

Comments