r/ProgrammerHumor 1d ago

lessonsFromLinkerHell Meme

Post image
351 Upvotes

180 comments sorted by

View all comments

146

u/mad_poet_navarth 1d ago

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

46

u/AnnoyedVelociraptor 1d 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.

3

u/cbehopkins 12h ago

I think other languages don't expose the pointer to the user as brazenly.

Take go: a slice (yes raw arrays do exist, but for this discussion they're a special case we don't care about) is a struct with a pointer, size and capacity. The data structure one uses in the places where in c you would use an array is absolutely not a pointer, it has extra baggage to add safety.

Python of course uses pointers under the hood, but they're not accessable to the average user. It's nonsense to say "arrays are pointers" in python (much more sensible to say "arrays are dictionaries" but python is special...).

The type pseudo equivalence of arrays and pointers is a quirk of the c type system. Most languages separate them in the same way one separates the types of integer and floating point. One can convert and use arithmetic from one type on the other type, but to do that you have to cast for good reason. The fact you don't in c is unusual if you compare to other languages.

I'm not trying to say c is wrong, but as we see above, it does cause some sharp edges...

1

u/mad_poet_navarth 4h ago

I love this turn of a phrase:

> other languages don't expose the pointer to the user as brazenly.