Hacker News new | past | comments | ask | show | jobs | submit login
Why Pascal Is Not My Favorite Programming Language (1981) [pdf] (cat-v.org)
25 points by kick 25 days ago | hide | past | web | favorite | 62 comments

I used to encounter this article _all the time_ in the late 1990s as an argument against Borland Delphi, which was by far the most widely used Pascal variant then.

You can reply point by point about how it is factually wrong about Delphi:


> There is no break statement for exiting loops.

Delphi has a "break" statement. (1)

> case statement ... there is no default clause

Yes there is, the "else" case. (2)

Many of these "extended syntax" features were likely added due to the criticisms in this paper. So in one sense the paper was valuable in causing that, in another sense it's usefulness was over by the late 1990s.

And then the eventual fallback argument is: "Ok, then Delphi is not Pascal" which was technically true, but then this article is allowed to stand as "an argument against Pascal (not Delphi)"

... and is soon picked up again as an argument against Delphi (because it's "Pascal" ).

Round and round it went. So tiresome and ignorant.

1) http://www.delphibasics.co.uk/RTL.asp?Name=Break

2) http://www.delphibasics.co.uk/RTL.asp?Name=Case

> And then the eventual fallback argument is: "Ok, then Delphi is not Pascal" which was technically true, but then this article is allowed to stand as "an argument against Pascal (not Delphi)"

It wasn't even true for Turbo Pascal before Delphi.

The historical rant against Pascal, where only ISO Pascal is taken into consideration lest not weaken the argumentation, most of the negative issues regarding strings, open arrays, pointer usage and procedure/function pointers were sorted out by UCSD Pascal, Turbo Pascal, Object Pascal (at Apple and later Borland) and ISO Pascal was later reviewed into ISO Extended Pascal.

Yes, they each sorted them out. (I'd mention VMS Pascal, too.) But they sorted them out differently, so if you were, for example, writing Software Tools in Pascal, as Kernighan had, you couldn't use their solutions; they were incompatible from one system to the next. ISO Extended Pascal did not solve this problem even when it was published in 1991, ten years after this paper, because even today it's not universally supported; for example, FreePascal still doesn't support it.

In a few cases, like TeX and STiP, the solution was to write in standard Wirth and Jensen Pascal, despite the inconveniences. Most people instead resigned themselves to writing nonportable code.

By the way, I see that the comment window has closed, but I'm still interested in your thoughts on https://news.ycombinator.com/item?id=22083468 — it represented a fair bit of effort on my part, and it's disappointing that you haven't answered at all.

Yeah that is the other typical argument, where it gets "forgotten" that outside UNIX in 1981, C was equally non-portable with dialects of K&R C everywhere like Small-C, RatC and plenty of others, taking yet another 10+ years for a standard to come up and respective compilers to catch up with it.

So? Does that make anything kragen said untrue? This is just whataboutism, only on technical rather than political topic.

[Edit: On reflection, you're addressing a different topic. The question the rest of us are talking about is "was Pascal that bad?". And the answer is, "yes".

You want to talk about something else - Pascal vs. C. But in C, you could at least do "#ifdef Compiler_A" to achieve "portability". Yeah, it's not very good portability, but you could get to one source file that would compile with different compilers. For Pascal, so far as I know, you couldn't do even that much.]

All Pascal dialects supported conditional compilation.

They did? I don't remember that. What was the syntax?

Or was it that all post-Jensen-&-Wirth dialects supported conditional compilation, and I don't remember it because I was stuck on Jensen & Wirth?

Amsterdam Compiler Kit Pascal compiler used the UNIX preprocessor.

Object Pascal (Apple) and Turbo Pascal used {$if ...}

VMS Pascal used %IF.

UCSD Pascal used {$B}.

I grant they weren't uniform, but they were available.

You keep talking about what Pascal was. That no longer matters. What matters is what Pascal is today.

Both Free Pascal and Delphi support conditional compilation and have done for a long time:



pjmlp said "supported", no "support". He and I were talking about the past. We're allowed to do that - to have the subject be what we want, rather than what you think it should be.

In fact, the article was about Pascal circa 1981, so I'm not sure why you think the discussion ought to be about present-day Pascal.

Because the criticisms from 1981 are no longer relevant and haven't been relevant for a long time. Turbo Pascal had conditional compilation since at least 1987.

Then just let the whole article pass as being irrelevant, and go comment somewhere else, where they're talking about current languages. The discussion we're having here isn't the one you want to have.

Look, these are just the practical realities and no amount of you trying to define what the discussion is (whatever that's supposed to mean) will change that. Pascal is nice. Get on board:



That is definitely false.

Your statement would be more convincing if you provided a counterexample...

Turbo Pascal 6.0 was a fantastic programming environment for DOS. The inline assembler feature (the "asm" statement) was awesome! It allowed you to build demo scene-quality effects for the VGA while doing most of the grunt-work in high-level Pascal. This is why e.g Fast Tracker, Crystal Dreams II (Triton) and Second Reality (Future Crew) were all built in a combination of Turbo Pascal and inline asm.

IIRC Turbo Pascal 7.0 (aka Borland Pascal 7.0; I never unstood the difference) added syntax highlighting but mostly focused on adding Windows support (meh).

I wrote my first web apps as BP7 win-cgi apps back in 1995.

I wrote a co-operative multi-tasker for Turbo Pascal 7, back in the day. I needed to be able to pipe things between a few filter routines, and it helped make everything work. In the middle of compute heavy code, you sprinkled calls to "Yield"... and it worked.

Windows support was added in Turbo Pascal for Windows.

Turbo products were the "community/student", while the Borland were the "professional" variant with more tooling and compiler optimisations.

> Turbo products were the "community/student", while the Borland were the "professional" variant with more tooling and compiler optimisations.

Ah.. Over here in northern Europe we'd typically just pirate everything from our school's installation so we weren't really aware of any marketing differences. Thanks for clearing up a long-time mystery :). (We ended up with an install that had both bp.exe/tp.exe and bpc.exe/tpc.exe, and they seemed to behave identically. bp/tp.exe was the IDE, bpc/tpc.exe was the commandline compiler.)

> Windows support was added in Turbo Pascal for Windows.

I think Turbo Pascal for Windows was like a branch, but then TP7/BP7 brought it into the mainline. Just before the mainline was reworked into what became Delphi.

Not sure about the timeline anymore, just that I bought TPW shortly after it came out.

Me neither, it was a long time ago.

In the 80's, I put a Z80 card in my Apple 2, just so I could run CP/M and Turbo Pascal. This.. wasn't that unusual.

Turbo Pascal, Wordstar, and dBase were the three killer apps that justified by buying a Z80 card for my Apple II back in the mid-80s.

TIL there there wasn't a 6502 version of Turbo Pascal, while there was a Z80 version. (And that was even the original target CPU.)

My programmer career started in my teenage years when my uncle lend me a book about programming serial/parallel ports on an IBM compatible PC. The book would explain a certain concept and then give different code examples in two languages BASIC and Pascal. However the variable names in the Pascal examples where in German, those from BASIC where in English. My teenage self therefore thinking Pascal was a 'German' programming language so I stuck with the BASIC examples, learning programming was complex enough without having to learn German as well. Only later in school when I got lessons in Pascal it struck me it was just as English as BASIC.

I miss pascal. It was a language that was easy to read, unlike C.

And who's stopping you to write things in Pascal these days? Lazarus + Free Pascal has plenty of platforms as target. Heck you can run Lazarus on Raspberry Pi and create stuff for Rasbian right there on your RPi device.

There's also Ada, which is not the same language but which was heavily influenced by Pascal.

I did too... but plowed forward with a project in Python... until it stalled.... took about 20 hours and re-implemented it in Lazarus/Free pascal, and haven't looked back since.

It's not quite as solid as Delphi was, but then again I don't have $5k to dump on a compiler right now.

I miss it too; Pascal (Delphi) used to be one of my favourite compilers; until Dennis in tech support refused to reset my version 10.2 license registration limit the other day.. Time to move on I guess.

I started on Pascal too. These days I like Go, in big part for its readability.

Wirth's languages are beautiful even if C-like languages won the syntax war for the most part.

Nonetheless Pascal-like languages have had some moderate success over some 40+ years from original Pascal to Turbo Pascal to Object Pascal to Delphi (not to mention many other languages from Ada to VHDL.)

Wirth's Oberon ecosystem is also beautiful and uses Pascal-like languages to describe everything from his RISC CPU (specified in Lola) up to entire operating system and user environment (written in Oberon.)

Personally I enjoy reading Pascal/Delphi/Modula-3/Oberon code, and I'm fascinated by the Oberon system as an example of how things can be small yet also clear and capable.

That is about historical Pascal that existed at 1981. I don't know does that Pascal version run on current computers anymore.

Nowadays there is FreePascal and Lazarus, that support many platforms and have a lot of features.

Of all the nails that could be used to seal Pascal’s coffin, the one I use is that I can’t write ‘writeln’ in Pascal. Other than that, it was great in it’s time (mid 70’s for me).

How do you write malloc() and exit() in C?

You don't, it has to be in Assembly or calling underlying OS APIs.

So also a nail in C's coffin.

malloc: Have a big static block of uint8_t and return pointers from it.

exit: longjmp.

Funny, malloc() implemented that way is UB and doesn't work in all cases, specially when passing pointers around dynamic loaded libraries or threads.

So exit() gets to call longjmp() which definitely can only be done in Assembly, back to step 1.

Isn't this how malloc was done on classic MacOS?

Classic MacOS was written in a mix of Assembly and Apple Pascal.

C was a guest language via MPW, and plugged into those APIs.

> malloc: Have a big static block of uint8_t and return pointers from it.

According to C99 section 6.5 paragraphs 6-7 that would be undefined behavior. The declared type of the object is uint8_t and you're accessing it through an lvalue expression which is not compatible with uint8_t. (You can access any object through a character-type lvalue, but the reverse is not true.) The malloc() function is required to return memory which is disjoint from any other object—that includes your uint8_t array.

Besides aliasing concerns, your character array may not be properly aligned for whatever type is being stored there and there is no way within the C99 standard to determine the alignment of the array or the required alignment for the stored type.

> exit: longjmp.

That might work, in a single-threaded program, if you longjmp() back to main() and return. There's no telling what might happen if you did that from another thread, of course, but then C99 doesn't really cover threads.

Put the block in a struct and use allignment keywords.

If you're lucky enough to be using C11 or C18, sure. There are no alignment keywords in C99. However, that still leaves the aliasing issue, and the fact that objects allocated with malloc() are defined not to overlap with any other object.

well you also need another static block for the allocation bitmap or whatever structure you're going to use. How would the pointers that you're generated be aliased if they're unique according to your free map.

They're aliased with the array that you allocated them from. The compiler is free to assume that elements in an array with a declared type of uint8_t won't be accessed via any other type of lvalue (other than another character type). Doing so is undefined behavior, which means there are no guarantees about how any part of the program behaves before or after such an access. In many cases you can get away with it, of course, but a strictly conforming C program can't rely on that.

You use "array of const" to write the equivalent of a regular C variadic function in modern Pascal implementations such as Delphi and Free Pascal:


That said, as far as at least Free Pascal goes, there isn't actually even a specific function called `writeln` with a real body that you can go and look at somewhere.

It's a magic language-level intrinsic that gets broken down into calls to various other intrinsics by the compiler based on what's passed to it.

> I can’t write ‘writeln’ in Pascal

Let's not talk about Pascal from over 40 years ago, let's talk about today's Pascal. Why can't you write "writeln" in today's Pascal?

According to Rosetta Code [1], “Standard Pascal does not allow variadic functions” — though specific implementations have proprietary extensions which allow this.

[1]: https://rosettacode.org/wiki/Variadic_function#Pascal

None uses that "standard" when writing stuff in Pascal. Real world uses either Delphi or Lazarus+FreePascal. Both of them have Writeln and variadic functions

Note, I think the point wasn't that Pascal didn't have writeln, rather that you couldn't write (implement) writeln in Pascal (presumably due to missing variadic functions).

So having writeln isn't really the issue, the issue is that writeln is magic/a built-in.

Is free pascal self hosted?

You could write something along the lines of `writeln` using `array of const` with today's Free Pascal. It's still strictly better that it's actually implemented as a built-in for various reasons, though.

Also, yes, Free Pascal is entirely self-hosted from the bottom up, making use of inline assembly blocks in some places where it's necessary. It is to Pascal what GCC is to C and C++, basically (which is to say, it has no real dependencies on toolchains other than itself).

> Is free pascal self hosted?


Which compiler are you going to use for "standard pascal"? The Pascal compilers you're going to use in practice are either Free Pascal or Delphi. They are what Pascal is today:


Things such as "implement the 'writeln' function" fall under the umbrella of "operating system interop" or "Foreign function interface", don't they?

Any general-purpose programming language, pascal or not, will eventually have that. But it might not be in a general language standard.

I think the point is that it’s not so rare that one might run into this type of situation. The article even mentions one.

> It is unfortunate that there is no way to make this convenience available to routines in general.

The damage this viewpoint was massive.

Pascal could have been our present, but now we live the mistake of base so much on top of C/C++, and because we never learn, repeat with JS.

This viewpoint? Listen, I've had the misfortune to work in a non-enhanced (Jensen & Wirth-ish) Pascal, and what this article says is true. And it's true that the problems describe get in your way, sometimes annoyingly, and sometimes really badly.

The damage to Pascal was from Pascal, not this paper or the viewpoint it represents.

(I'm not going to defend JS, though...)

> to work in a non-enhanced

That is like to work in first generation C.

But the viewpoint cause massive damage: Pascal get a reputation based in the first version with a limited scope, despite have very good points at his favor.

In a modern example, is like dismiss GO because lack of generics and verbose error handling, and consider C better for some OTHER reasons, that is what actually happened with pascal and other langs.

ie: Happens ofter that some critize lang/tool for X (could be truth) ignore Y (that is a good point) and still choose Z (for other reasons).

In the case of C: Is more popular, can I do funky things with pointers, my OS is made on that.

I worked in C just before and just after my gig in Pascal. While C had flaws, it was a more usable language than Pascal. First version C, first version Pascal. That's what Pascal apologists never want to admit. They still, 50 years later, either don't understand it or won't accept it: C was more usable than Pascal. Pascal's story may have been better, it's theory may have been better, but when it came to actual ability to write programs, C was better.

Now, Pascal improved. Various versions fixed various flaws in various nonstandard ways. But the same was true of C.

Link for previous discussion (2014)


Based on the earlier discussion, I have to wonder why C requires forward declarations if it's using a compiler that performs 4 passes and has dependency checking that even other languages defer (and compile) to. Is it standardization?

Applications are open for YC Summer 2020

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact