Code on a Harvard architecture differs mainly in that instructions and data live in separate memory spaces with separate address paths, so a program cannot treat instruction bytes as ordinary data or jump into a data buffer the way it can on a classic von Neumann machine; the practical consequences show up in linking, pointer types, self-modifying code, and how constants are stored.

That is the core answer, but it needs unpacking, because "Harvard architecture" describes a family of designs rather than one rule. Many chips sold as Harvard machines are actually modified Harvard: they keep separate instruction and data paths on the inside while presenting a single flat address space to the programmer. Whether your code must change depends on which kind you are targeting and how the toolchain exposes the split.

The distinction the question is really asking about

In a strict Harvard machine, the instruction stream and the data the program reads and writes are held in physically distinct memories. The processor has one bus (or set of buses) for fetching instructions and another for loading and storing data. Because these paths are independent, a fetch and a data access can happen in the same cycle, which is the classic performance argument for the design.

In a von Neumann machine, instructions and data share one memory and one address space. A byte at address 0x1000 is just a byte; whether it is "code" or "data" depends entirely on how the program uses it. That fungibility is what makes self-modifying code, computed jumps into generated buffers, and treating a function pointer as an integer all straightforward.

The Harvard split removes that fungibility. An address in instruction memory is not the same kind of address as an address in data memory. On a strict Harvard part, an instruction like "load the byte at the address of this function" has no single meaning, because the function's address belongs to a different space than the load instruction expects.

What actually changes in the code you write

Separate address spaces mean separate pointer types

On a strict Harvard microcontroller, the compiler often exposes distinct pointer types or address-space qualifiers. A pointer to a function or to a constant table in program memory is not interchangeable with a pointer to a RAM variable. Code that assumes void * can point at anything may fail to compile, or may compile and then behave incorrectly if the address is silently truncated or reinterpreted.

A concrete pattern appears on 8-bit microcontrollers such as parts of the AVR family, where program memory and data memory are separate and a special instruction sequence (often wrapped in a library macro) is needed to read a byte from flash. Reading a string constant stored in flash requires a different access path than reading a string in RAM. On such a part, a naive const char * pointing into flash may not do what a programmer coming from a flat-memory background expects.

Constants and read-only tables may live in instruction memory

Because data memory is often small and instruction memory larger, embedded Harvard toolchains frequently place constant tables, string literals, and lookup arrays in program memory by default, or offer a qualifier to request it. The source code may look identical, but the linker and startup code decide where the bytes go, and the access routines differ. This is a linker-and-runtime concern more than a syntax concern, which is why two programs that look the same can behave differently across architectures.

Self-modifying code and JIT compilation become difficult or impossible

The most dramatic difference is that generating machine code at runtime and then executing it requires the CPU to fetch instructions from memory the program just wrote. On a strict Harvard machine, writing to data memory does not make those bytes visible to the instruction fetch path. Some modified-Harvard designs provide a mechanism to copy a block from data memory into instruction memory and then flush caches or synchronize, but that is an explicit, often privileged operation, not a normal pointer cast.

This is why just-in-time compilers, dynamic code generation, and some interpreters are awkward on strict Harvard parts and routine on von Neumann ones. On a desktop processor with a modified-Harvard cache design, the hardware and operating system cooperate to make the programmer's view flat, so ordinary code generation still works.

Function pointers, jumps, and call/return

Branch and call instructions take addresses in instruction space. If a language runtime stores function pointers as ordinary integers in data memory, the value is fine as long as it is only ever fed back to a call or jump instruction. Problems arise when code tries to compare a function pointer to a data pointer, hash it alongside data addresses, or serialize it and read it back as data. On strict Harvard parts those operations cross the space boundary and are either rejected by the compiler or produce meaningless results.

Important ambiguity: strict versus modified Harvard

The phrase "Harvard architecture" is used loosely. Three situations are commonly conflated:

1: Strict Harvard at the programmer's view. Separate memories, separate pointer spaces, explicit instructions to move data between them. Small microcontrollers are the usual example. 2: Modified Harvard at the programmer's view. A single flat address space, but separate instruction and data caches internally. Most general-purpose CPUs and many digital signal processors work this way. Ordinary C, C++, and most high-level code compile and run without special treatment; the split is a microarchitectural detail. 3: Harvard-style separation only for caches or buses, with hardware coherence. The programmer sees one memory, and the hardware maintains consistency, sometimes with explicit synchronization instructions after code is written.

So the honest answer to "how is code different" is: it depends on whether the separation is exposed to software. On a modified-Harvard desktop CPU, your source code is essentially the same as on a von Neumann machine, apart from cache-maintenance calls in the rare case you generate or patch code. On a strict Harvard microcontroller, the differences are real and appear in pointer types, memory qualifiers, library access routines, and linker placement.

Where confusion comes from

A frequent source of confusion is that the same source file can compile for both kinds of target. A const array declared in C looks identical either way, but on a strict Harvard part the compiler may route it to program memory and generate special read sequences, while on a flat-memory part it lands in ordinary read-only data. The code "works" in both cases only because the toolchain hides the difference; the moment you take the address of that array and pass it to a function expecting a generic data pointer, the hidden assumption surfaces.

Another confusion is the claim that Harvard machines "cannot" run certain languages or patterns. They can run C and C++ and many higher-level languages; the constraints are on specific operations (runtime code generation, unrestricted pointer punning across spaces) rather than on the language as a whole. A strict Harvard part with a good toolchain handles ordinary application code fine.

A third confusion is treating cache separation as if it were the same as memory-space separation. Separate instruction and data caches on a modern CPU do not change the language's pointer model; the hardware and OS handle coherence, sometimes requiring an explicit instruction-cache flush after writing code. That is a maintenance step, not a different programming model.

A concrete comparison

Aspect Strict Harvard (exposed split) Modified Harvard (hidden split) Von Neumann
Pointer model Distinct instruction/data pointers or qualifiers Single flat pointer Single flat pointer
Reading constants from program memory Special access routine or qualifier Ordinary load Ordinary load
Runtime code generation Difficult; needs explicit copy/flush Possible; needs cache synchronization Straightforward
Self-modifying code Generally not supported Possible with synchronization Supported
Main source-code impact Pointer types, memory placement, library calls Rare cache-maintenance calls None from the architecture

The table is illustrative of the categories, not of specific chips; individual parts vary in which features they expose.

How this plays out in practice

If you are writing portable C for an embedded strict-Harvard target, the practical rules are: do not assume a function pointer is a data pointer; use the platform's program-memory qualifiers for constant tables when data memory is tight; use the provided access macros rather than dereferencing flash addresses directly; and do not rely on generating code at runtime. If you are writing for a general-purpose CPU, none of this applies to your source except in the narrow case of JIT or self-patching code, where you follow the platform's documented instruction-cache synchronization procedure.

The deeper point is that "code" is not a fixed category across architectures. On a von Neumann machine, code is just data with a particular use. On a strict Harvard machine, code is a separate kind of thing stored in a separate place, and the language and toolchain have to acknowledge that separation. Most of the time the compiler absorbs the difference; when it cannot, that is where the code genuinely differs.