17

"The C programming language was specifically designed to abuse the von-Neumann architecture"
- Some guy on StackOverflow

Comments
  • 3
  • 1
    Does it say anything more than that? I'd like to hear the because part if there is any.. link perhaps?
  • 0
    @Pyjong Sorry, I've read it a long time ago somewhere on StackOverflow
  • 1
    Well AVR-GCC shows that C works also with Harvard. There's nothing in C that would require von Neumann.
  • 0
    @Fast-Nop Harvard has two address spaces. Pointers can't natively deal with that. I also don't know if code is generally writable in Harvard which it theoretically is in von-Neumann. E.g. a JIT: Write some instructions into memory and jump to it to execute them
  • 0
    @12bitfloat Well if you write code to memory and execute that, this means basically aliasing some data pointer and function pointers, and that's technically undefined behaviour anyway.

    It's just that some machine specific hacks that are outside the abstract C machine may happen to work better on von Neumann than on Harvard.
  • 0
    @Fast-Nop Writing instructions to memory and jumping to them is well defined behaviour (that's what JITs do). I don't argue that it's impossible compiling C code for Harvard, obviously that's possible (with some caveats), but I believe that C was fundamentally designed for Neumann-like machines
  • 1
    @12bitfloat it's undefined behaviour as far as the C standard is concerned. Obviously, because what you can even write to memory and execute is machine specific, and that wouldn't be the case for standard conforming C.

    You can't even do that in C without casting some data pointer to a function pointer, and that's not allowed, technically.

    Also, this is not a typical use of C. Everything that you typically use C for works as well on Harvard.

    AVR needs the PGM hack only because on embedded, you want to access constant data from flash because RAM is scarce. In that regard, Harvard is a bad choice for such a target. But bigger machines don't have that issue.
Add Comment