5 ms·
Can you provide an example of how C is supposedly "closer to the metal" than pascal ? Both are native compiled language, and at least windows used to have its a
by nolok 12y ago
Can you provide an example of how C is supposedly "closer to the metal" than pascal ? Both are native compiled language, and at least windows used to have its api coded in pascal rather than c before that language became dominant.
- Narishma 12y agoThe Win16 API was written in C, not Pascal. But because it didn't have functions with a variable number of arguments, they could use the Pascal calling convention instead of the C one. It was slightly faster and saved a few bytes at each call point, which was a big deal back when memory was measured in kilobytes.
- pjmorris 12y agoIn C, a pointer can point to any old memory address, including core elements of the machine's BIOS and operating system. In Pascal, an array is an array, not necessarily tied to anything in the machine. I think that's the great strength and great weakness of each language.
- pjmlp 12y ago> In C, a pointer can point to any old memory address, including core elements of the machine's BIOS and operating system You mean var buffer : array [0..$3FFF] of byte absolute $B800:$0 ? An array, protected with bounds checking accessing any memory address, provided the OS protection allows it. Don't want bounds checking? Make use of {$R-}
- kjs3 12y agoTo be fair, the rant (and most of the misconceptions) about Pascal are about Wirth defined Pascal, not the much later extended Pascals that introduced things like "byte absolute" types. But you're right in that no one has probably tried to suffer through strict Wirthian Pascal since the last CDC Cyber got shut down except on a bet. (Turbo Pascal on CP/M-80 was my goto for a number of years)
- wirrbel 12y agoC does not semantically separate arrays from pointers, Pascal does this. C uses indexes starting from 0, Pascal does not. Pascal usually does not come with strong memory layout guarantees that one knows from C (packing of structs, unions, etc.) Typecasting in Pascal is a matter of dialect. There are probably more but I cannot remember them because I have not used Pascal in a very long while.
- pjmlp 12y agoNone of those points are "closer to the metal". Only ANSI/ISO C11 does provide strong memory guarantees. Back then there wasn't even a C standard.