DEV Community

Cover image for Why Do Most Programming Languages Index From Zero?

Why Do Most Programming Languages Index From Zero?

Lucia Cerchie on November 08, 2020

This morning I was counting the number of days from an appointment on my calendar. "0, 1, 2, 3..." I muttered under my breath. Good thing I said it...
Collapse
 
genuinerex profile image
Rex Bloom

I think pointers, and pointer arithmetic, in low level languages, is another source of influence for this decision.

Collapse
 
tbroyer profile image
Thomas Broyer

Fwiw, in France, as seen in Emily in Paris, (probably many other countries), we name floors "from 0" too (floor 0 being called rez-de-chaussée), so the 5eme étage is the 6th floor.

Collapse
 
cerchie profile image
Lucia Cerchie

This is so cool to hear about! Thanks for letting me know about this part of French culture that's analogous to so many programming languages.

Collapse
 
kirkcodes profile image
Kirk Shillingford

Concise, fun, and informative! Always nice to learn new things on a Sunday :)

Collapse
 
onlyphantom profile image
Samuel Chan

I teach math and one thing I learned is that some mathematical languages (like Matlab and R) starts at index 1.

items[1] actually returns the first item in that array / list.

So perhaps that has got to do with the founding motivation of the language — all the way back to its founding philosophy.

Collapse
 
cerchie profile image
Lucia Cerchie

It's really cool to hear about this from the perspective of someone who uses Matlab and R! Yeah I'd think so -- these founding fathers of computer science were philosophers as well.

Collapse
 
isarisariver profile image
Marian

TIL. Thanks for sharing :)

Collapse
 
_bkern profile image
Barry

It is funny it bugs me a lot when languages start at 1 but I think I have only ran into one a while ago in my personal experience.

Collapse
 
filmil profile image
Filip Filmar

There's also this, which gives a bit of a different story: exple.tive.org/blarg/2013/10/22/ci...

Collapse
 
gustvandewal profile image
Gust van de Wal

You've managed to not once spell Dijkstra's first or last name correctly

Collapse
 
cerchie profile image
Lucia Cerchie

I've edited accordingly. :)