Hacker News new | ask | show | jobs
by larschdk 549 days ago
When C was conceived, CPU architectures and platforms were more varied than what we see today. In order to remain portable and yet performant, some details were left as either implementation defined, or completely undefined (i.e. the responsibility of the programmer). Seems archaic today, but it was necessary when C compilers had to be two-pass and run in mere kilobytes of RAM. Even warnings for risky and undefined behavior is a relatively modern concept (last 10-20 years) compared to the age of C.
2 comments

When C was conceived, it was made for a specific DEC CPU, for making an operating system. The idea of a C standard was in the future.

If you wanted to know what (for instance) memcpy actually did, you looked at the source code, or even more likely, the assembler or machine code output. That was "the standard".

I think it's reasonable to assume that GP clearly meant the C standard being conceived, as, obviously, K&R's C implementation of the language was ad hoc rather than exhibiting any prescribed specification.
No, K&R's book was the standard.
First came the language, then a few years later they described it in a book.
> Seems archaic today ... run in mere kilobytes of RAM

There is an entire industry that does pretty much that... today. They might run in flash instead of RAM, but still, a few kilobytes.

Probably there are more embedded devices out there than PCs. PIC, AVR, MSP, ARM, custom archs. There might be one of those right now under your hand, in that thing you use to move the cursor.

> There is an entire industry that does pretty much that... today.

Which industry runs C compilers on embeded devices? Because that is what the part you elipsised out was talking about.

Oh... yes. You are right. My bad.
many do tho. i have targetted c89 and maybe c99 on several embedded devices
They cross compile. No one is compiling code on these machines.
But you're running the compiler on the device rather than cross-compile?
I doubt you're running C compilers on those devices.