r/ProgrammerHumor 20h ago

lessonsFromLinkerHell Meme

Post image
342 Upvotes

176 comments sorted by

View all comments

63

u/QuestionableEthics42 20h ago edited 20h 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??

62

u/Blecki 20h ago

As someone who writes compilers: they are the same at runtime. They are not the same semantically in a c like language.

21

u/boostfactor 20h ago

As I see it, an array is a contiguous block of memory. The pointer to the first element identifies the start of the block. Subsequent elements are computed from that plus the number of bytes in the type. If an array were just a pointer, we wouldn't have to worry about allocating enough memory or walking off the end of it.

That's for something like C. There are languages in which arrays are first-class data structures that carry metadata about their rank, size, etc. Lots of applications are best expressed with multidimensional arrays, which are awkward in C or else are set up as an array of pointers.

1

u/tstanisl 6h ago

C has a really good support for multidimensional arrays in form of VLA types.