this post was submitted on 19 Oct 2024
725 points (98.9% liked)

Science Memes

10905 readers
1903 users here now

Welcome to c/science_memes @ Mander.xyz!

A place for majestic STEMLORD peacocking, as well as memes about the realities of working in a lab.



Rules

  1. Don't throw mud. Behave like an intellectual and remember the human.
  2. Keep it rooted (on topic).
  3. No spam.
  4. Infographics welcome, get schooled.

This is a science community. We use the Dawkins definition of meme.



Research Committee

Other Mander Communities

Science and Research

Biology and Life Sciences

Physical Sciences

Humanities and Social Sciences

Practical and Applied Sciences

Memes

Miscellaneous

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 2 weeks ago* (last edited 2 weeks ago)

It's worth noting that a number of languages comparable C in use case and performance (including its predecessors COBOL, Fortran and ALGOL) start indexing at 1 just fine because they have proper array types and don't make heavy use of pointers poking and peeking wherever they like (eg by using references instead).

Decoupling indices from memory offsets doesn't get in the way of performance and actually often allows better optimization because the compiler knows you aren't sharing pointers between arrays or some other shenanigans; see Fortran, the GOAT of fast array processing. This also allows improved type safety and thus memory safety; see index types in Ada/SPARK and the fact that it's the only 'legacy' language that's gotten comprehensive compile-time memory safety analysis (though the latter is moreso from the less willy-nilly pointers in general)