Hacker News new | ask | show | jobs
by waitingkuo 3930 days ago
I've tried to learn R several time, but its index started with 1 always stop me from learning.
3 comments

I've always wondered why Julia went this route too. They more or less said "because matlab does it"
Source? One of the best arguments, that is personally relevant to the work I do, is that indexing in math often starts at 1 (e.g. the indexing of rows and columns of a matrix). Translating this to code results in a mental overhead of mapping the math-index to the code-index, a cost I don't pay in Julia.
https://github.com/JuliaLang/julia/issues/558

  > There is a huge discussion about this on the mailing list; please see that. If 0 is mathematically "better", then why does the field of mathematics itself start indexes at 1? We have chosen 1 to be more similar to existing math software.

A post above also appeals to mathematica. It's been a while since I've had to internalize the "cost" of zero indexing, so this never felt very compelling.
Fortran indexes from 1. Fortran is the original higher than assembly level scientific computing language and a lot of scientists alive today got their first programming experience in Fortran. I suspect that they all follow from Fortran.
Fortran also gives you the option to define any starting index, when you declare an array. (Even negative.)

But it's true, indexing from 1 is common, or idiomatic, in Fortran.

What a trivial issue to reject R.
And Python's index starts at...what?
I tried to learn Python but my computer was turned off so I gave up.
zero