Hacker News new | ask | show | jobs
by mjcohen 538 days ago
Fortran has arbitrary-based indexing forever (as does Ada). The default is 1 but it can be specified as anything. I don't see why this capability is so rare.
1 comments

I think it's one of those features where the original intended audience of the programming language are supposed to be non-programmers (or presumably, 1-based indexing is intuitive?) but for seasoned programmers who have been used to 0-based indexing, the change is quite stark.

It's the same concept with AutoHotKey and the original intention of Lua (super small user-defined script for the masses).

Whereas Fortran and Ada probably had some forethought that went into enabling that functionality. I will have to check but I remember my algorithm class started with 1-based indexing and the reason was it was intuitive to explain. But when experienced with C/C-inspired languages, the old adage becomes relevant: "There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors."

> the original intention of Lua (super small user-defined script for the masses).

Lua was originally intended to be a language/data format for a Brazilian oil company geology software.

https://www.lua.org/history.html