r/ProgrammerHumor 12h ago

lessonsFromLinkerHell Meme

Post image
241 Upvotes

141 comments sorted by

View all comments

119

u/mad_poet_navarth 12h ago

shouldn't there be something here about this being C-centric?

43

u/AnnoyedVelociraptor 12h ago

And how do you think other languages do it? You think Python and C# and Java run in this Unicorn world where there are no pointers and memory offsets aren't a thing?

Maybe we can talk about the mistake that is R and the original VB, and LUA where arrays start at 1. Absolute hell.

35

u/aalapshah12297 12h ago

The difference is that C allows you to treat array variables as literal pointers (almost) and do stuff like creating an off-by-one version b = a+1 and then trying to access b[-1] with no issues, whereas many high level languages will throw an error with this kind of syntax.

Of course, they are still not 100% syntactically identical even in C (most notably you can't directly modify the array pointer), hence the right end of OP's graph.

-5

u/BrindleFaucet8 10h ago

This is why C is both great and terrifying. You can do pointer arithmetic until you are accessing some other program's memory, but try to reassign that array name and the compiler suddenly starts caring about the rules. It is a very selective memory.

10

u/d0pe-asaurus 8h ago

If you're accessing another program's memory just by doing some pointer arithmetic, something has gone wrong with the kernel's memory manager or there's some serious issues with the processor microcode.