clarity-lang / reference

The Clarity Reference
146 stars 34 forks source link

Start indexing at one #43

Open njordhov opened 3 years ago

njordhov commented 3 years ago

Computers count from zero; people count from one. Zero-based indexing can be confusing for non-developers and programming novices. Humans generally find one-based indexing more intuitive, where in the list (1 2 3) the first item is found in position one rather than at index zero.

Discussing the intent of Clarity contracts with non-programmers will benefit from one-based indexing.

Choosing between zero-based and one-based indexing is a programming language design decision. Programmers should be able to adapt to either. While many programming languages, and close to the metal systems languages in particular, typically uses zero-based indexing, major programming languages used for mathematics have one-based indexing, including Mathematica, Matlab, and R. Other languges with one-based indexing includes Julia, Lua, Erlang, Smalltalk, Many high-level domain-specific languages also use one-based indexing.