4 ms·
You can do it in those languages (at least you can in a modern Pascal; I don't know enough about Algol to say). But remember, the original claim by pjmlp was "
by AnimalMuppet 11y ago
You can do it in those languages (at least you can in a modern Pascal; I don't know enough about Algol to say).
But remember, the original claim by pjmlp was "It is a big flaw to ignore what other language communities were doing. Other systems programming languages older than C did it properly." That doesn't apply to the Pascal you speak of, because at the time C arose, Pascal wasn't "once you get to a recent enough version supporting dynamic arrays/first-class pointers". It was Pascal with the size of an array being part of the type of an array. That's type safety, sure. But it also means (to use an example that I have personal experience with), if you're writing a numerical simulation on a 2D array, and you want to let the user specify how big the mesh is, and then allocate memory to hold the mesh, you have a problem. You can't define a variable-sized array at all in the Pascal of the time.
Now try to think about how you'd write a memory allocator in that. Good luck.
Another example: We were on an embedded system. To write to hardware registers, we had to call an assembly-language subroutine. In C, we would have simply used a pointer to an absolute memory address.
This is what C gave you - you could just do things without the language getting in the way. Yes, you could cut yourself on C's sharp edges, whereas Pascal protected you. But when you needed the sharp edges to cut something, Pascal didn't have them, and you were stuck.
Again, I don't know enough about Algol to meaningfully compare it to C. The Pascal of the day wasn't the answer, though.
- pjmlp 11y agoYou are assuming hardware registers were available via memory mapped address. Many machines used only IO ports. Where are the C features for that? Pascal was originally used for teaching it doesn't count. The first time it was used for writing an OS, was with the Object Pascal dialect for the Mac OS. What counts were Algol 60, Algol 68, Algol W, PL/I, PL/M, Mesa among many others. As for the statement of only C being usable without Assembly, check the B5000 from the Burroughs Corporation, developed in 1961. EDIT: where => were
- AnimalMuppet 11y ago> You are assuming hardware registers were available via memory mapped address. I'm not assuming it. The environment I was in had memory-mapped IO. > Many machines used only IO ports. Where are the C features for that? C compilers for machines that only had IO ports typically had a library function to do it. At least, by the era of Turbo C, they did. (The x86 architecture is the first one I was familiar with that did IO that way, and Turbo C was the first C compiler I had on it. I presume that, if earlier architectures did IO that way, C compilers for those architectures had similar capabilities, but I do not know that first-hand. > Pascal was originally used for teaching it doesn't count. I was replying to pcwalton, who asked what you can do in C that you can't do in Pascal. So it may not count to you (four comments upthread from here), but it counted to the comment I was replying to (two comments upthread from here). Perhaps your comments would be better addressed to him/her. > As for the statement of only C being usable without Assembly, check the B5000 from the Burroughs Corporation, developed in 1961. I didn't say that only C was usable without assembly. I said that using Pascal, in order to write to memory-mapped IO registers, you had to call a function written in assembly, and that in C you didn't have to do that. I never said only C was usable that way. Please stop putting words in my mouth that I didn't say.
- pjmlp 11y ago> I said that using Pascal, in order to write to memory-mapped IO registers, you had to call a function written in assembly, and that in C you didn't have to do that. I never said only C was usable that way. Please stop putting words in my mouth that I didn't say. In what language do you think the Turbo C library functions for port IO and all those handy BIOS and MS-DOS calls were written on? Assembly, of course. As for doing memory mapped IO with Pascal, you could something like this in Turbo Pascal. Other dialects had similar extensions. var videoMem : array [0..255] of byte absolute $A0000; begin videoMem [0] := 12; end;
- AnimalMuppet 11y ago> In what language do you think the Turbo C library functions for port IO and all those handy BIOS and MS-DOS calls were written on? Assembly, of course. Of course. But they still looked like just another function call in C, and they came with the compiler, so the programmer writing in C didn't care. In my Pascal example, there was no such function, so we had to write it, so we had to care. You seem to be consistently trying to make my words say things that I am not saying, and then arguing against positions that are only in your own mind. It's getting quite tedious.
- nickpsecurity 11y agoPascal does count because people wrote real software in it, it was better than C, Pascal/P was one of the best portability hacks ever, UCSD P-system used it, and Modula-2 built a real OS with a lot of same features. That said, if people counter Pascal, we can remind them of its purpose as you did if the limitation was due to that purpose. Modula-2 is my goto reference in these discussions because it's closest to C's niche: resource-constrained, system programming w/out garbage collection. And better than C w/ successors that were all better than C. :) "As for the statement of only C being usable without Assembly, check the B5000 from the Burroughs Corporation, developed in 1961." Good call. First great, overall system as I see it. Might also remind them that Wirth's and Jurg's Lilith workstation ran on Modula-2 and assembly. Most comparable to UNIX in terms of hardware and personnel constraints. Shows even constrained teams could do better than C or UNIX. The Oberon systems used Oberon and assembly, as well, with a GC'd OS and software. That helps in another recurring debate about OS's in "managed code." ;) So, yes, that C is necessary for systems programming is a long-running myth refuted by examples which were better because they didn't use it.