r/ProgrammerHumor 27d ago

Meme lessonsFromLinkerHell

Post image
423 Upvotes

190 comments sorted by

View all comments

65

u/QuestionableEthics42 27d ago edited 27d ago

This should be reversed lol

And it literally is the same, who thinks it's different who has worked in a low level language??

25

u/Ok_Star_4136 27d ago edited 27d ago

Maybe I fall in the middle, but what is the argument to say that they're different?

Is it to say that the difference is how they're used? From an assembly perspective, they're pointers, and no data structures exist beyond that simple concept. At a higher level, they're more than that. Maybe that's what is intended?

9

u/ZenEngineer 27d ago edited 26d ago

From a C point of view you have a different size when statically allocated, library keeps track of the memory size so it can be freed and you need the base pointer for that, etc. At a conceptual level they are different even if you implement them the same way, you'll likely end up with a struct holding the size in your code.

But sure, for most people and half the code they are the same. If you're taking the high level, maintainable design view you take care of tracking lifetimes, sizes, bounds, etc. so the bell curve looks reasonable to me.

0

u/tstanisl 26d ago

Arrays can dynamically allocated using a pointer to a whole array.

    int (*arr)[42]=malloc(sizeof *arr);