4 ms·
What can you do in C that you can't do in, say, Algol 68? Or even Pascal (once you get to a recent enough version supporting dynamic arrays/first-class pointers
by pcwalton 11y ago
What can you do in C that you can't do in, say, Algol 68? Or even Pascal (once you get to a recent enough version supporting dynamic arrays/first-class pointers)?
I think the situation is not far off from what pjmlp is saying: there were several more or less equally good languages available at the time, and C won by virtue of being in the right place at the right time. There are lots of really nice things about C from a systems point of view, but most languages of the 70s had those too. C was a nice language for the late 70s (not so much today, IMO), but not hugely nicer than its contemporaries.
- AnimalMuppet 11y agoYou 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;