this post was submitted on 12 May 2026
995 points (98.6% liked)

memes

21745 readers
3277 users here now

Community rules

1. Be civilNo trolling, bigotry or other insulting / annoying behaviour

2. No politicsThis is non-politics community. For political memes please go to !politicalmemes@lemmy.world

3. No recent repostsCheck for reposts when posting a meme, you can only repost after 1 month

4. No botsNo bots without the express approval of the mods or the admins

5. No Spam/Ads/AI SlopNo advertisements or spam. This is an instance rule and the only way to live. We also consider AI slop to be spam in this community and is subject to removal.

A collection of some classic Lemmy memes for your enjoyment

Sister communities

founded 3 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] SorryQuick@lemmy.ca 4 points 1 month ago (1 children)

Says who?

By definition, an index is

a number or symbol or expression (such as an exponent) associated with another to indicate a mathematical operation to be performed or to indicate use or position in an arrangement

Since the arrays offsets alao tell us about the items’s position in the array, is it not then an index?

People take these terms way too seriously. Hell, many languages have their “list” implemented as an array. What then do you call the index/offset?

[–] lime@feddit.nu 1 points 1 month ago* (last edited 1 month ago) (1 children)

if you want my opinion (<- see now you can't tell me i'm wrong, it's an opinion) then the difference is that an array is by definition a memory address that's designated as the beginning of an array, and it's got an offset because the first element is at that specific address and further items are offset from that address. so you add the offset to the address to get the nth item. a list, meanwhile, can be basically any implementation under the hood, but it's commonly a linked list. the way you get the nth index there is you count up from the first position. since the implementation is opaque and may be spread out in memory you can't arithmetic your way to an index, you need to follow the pointers.

java's arraylist is a list backed by an array. java's vector is a list backed by a linked list.

[–] SorryQuick@lemmy.ca 3 points 1 month ago (1 children)

That doesn’t really address what you call it. Names only really just exist to get your point across. Inexperienced devs may not know what an offset means (or why we use that), so index does the job. An experience dev knows how it works anyway, so whether you say index or offset won’t matter. By virtue of the common denominator, I simply use index everywhere.

[–] lime@feddit.nu 1 points 1 month ago (1 children)

depends on the area you're working in. it's a pretty important distinction in embedded software.

[–] SorryQuick@lemmy.ca 3 points 1 month ago (1 children)

Why? I’ve worked as an embedded dev for a few years and nobody in my team cared what it was called.

[–] lime@feddit.nu 1 points 1 month ago (1 children)

because making sure offsets are correct come up a lot when you're memory-mapping IO.

[–] SorryQuick@lemmy.ca 2 points 1 month ago (1 children)

Right but whether they’re correct or not doesn’t depend on the name you use. Every programmer worth his name knows arrays start at offset zero even if you don’t call it that.

[–] lime@feddit.nu 1 points 1 month ago* (last edited 1 month ago)

except if you use lua.

...which doesn't have arrays, but still.