Programming languages where the default array starting index is one
Posted by jpluimers on 2026/02/18
Every now and then I end up in arguments with people at what bound an array index should start. The usual options are one-based or zero-based indexing, but there are enough languages that allow defining a different starting index of an array.
In my opinion, in language where you can define the starting index, it should depend on the problem to be solved. I prefer languages that allowing for an arbitrary starting index as they allow specifying the problem domain best.
Often the argument used by others is “zero” as starting index is that it is more efficient. My counter arguments usually are that
- with compiler optimised iterators nowaways, indexing often is moot
- people learn to count starting with one for various reasons (for one because they use their digits to count) which makes it hard for them to unlearn and always count from zero, causing off-by-one mistakes doing so
- counting from 1 to 10 is acquired at age 2 to 3 years old, the concept of zero or empty about a year or two later
- the concept of zero is way younger than the concept of one, see 0: history and 1: history on Wikipedia
- zero based indexing is only more efficient in languages supporting multidimensional indices that can be folded in a single dimension and that the transofmration between the single folded dimension and the equivalent multidimensional index is easier when both are zero based
- for single dimensional arrays, there is no efficiency argument as most compilers and interpreters will optimise that away
- there are plenty of programming languages not having a default starting index of zero
I usually forget the last list, so below here are a few links with sources and discussions.
Before reading the list, always remember: code is about representing problem domains and problem domains are not about math, compilers are.
Oh, and on the concept of zero, this is a good read: [Wayback/Archive] What Is the Origin of Zero? | Scientific American
- Comparison of programming languages (array) – Wikipedia has a nice section “Array system cross-reference list” which you can sort showing these groups:
-
- index based on custom index type
Ada, AWK, Ada, D, Fortran, Hack, Haskell, Julia, Nim, Object Pascal, Pascal, PHP, PL/I, classic Visual Basic, Visual Basic, Visual Basic .NET
- default can be one based
ALGOL 68, APL, AWK, CFML, COBOL, Fortran, FoxPro, Julia, Lingo, Julia, Mathematica, MATLAB, PL/I, RPG, R, Ring, Sass, Smalltalk, Wolfram Language, XPath/XQuery, classic Visual Basic (on a module level by specifying
Option Base 1) - default can be zero based
APL, BASIC, C, Ch, C++, C#, Cobra, Common Lisp, D, F#, FreeBASIC, Go, Hack, Haskell, IDL, ISLISP, J, Java, JavaScript, Nim, Oberon, Oberon-2, Objective-C, OCaml, Perl, Raku, PHP, Python, Ruby, Rust, S-Lang, Scala, Scheme, Swift, Windows PowerShell, classic Visual Basic (on a module level by specifying
Option Base 0or not specifying that at all), Visual Basic .NET, Xojo - base index can be specified
Ada, ALGOL 68, APL, C#, F#, Lua, Object Pascal, Pascal, Perl, PHP, PL/I, Ring, Visual Basic .NET
- index based on custom index type
Note that some languages are in more than one group, especially classic Visual Basic. In a sense that makes it a versatile language.
-
- [Wayback/Archive] E.W. Dijkstra Archive: Why numbering should start at zero (EWD 831) ans summarised at [Wayback/Archive] Why numbering should start at 0 | Lambda the Ultimate
…When dealing with a sequence of length N, the elements of which we wish to distinguish by subscript, the next vexing question is what subscript value to assign to its starting element. Adhering to convention a) yields, when starting with subscript 1, the subscript range 1 ≤ i < N+1; starting with 0, however, gives the nicer range 0 ≤ i < N. So let us let our ordinals start at zero: an element’s ordinal (subscript) equals the number of elements preceding it in the sequence. And the moral of the story is that we had better regard —after all those centuries!— zero as a most natural number.Remark Many programming languages have been designed without due attention to this detail. In FORTRAN subscripts always start at 1; in ALGOL 60 and in PASCAL, convention c) has been adopted; the more recent SASL has fallen back on the FORTRAN convention: a sequence in SASL is at the same time a function on the positive integers. Pity! (End of Remark.)…This was in 1982, when compilers were not yet smart enough to optimize away array start/end indexing. - [Wayback/Archive] coding style – Are there any programming languages that starts counting from 1? – Stack Overflow pointed to
- [Wayback/Archive] Why are zero-based arrays the norm? – Software Engineering Stack Exchange with a great discussion
- [Wayback/Archive] Are there other common “c-like” or non “c-like” languages with non zero index array position? – Stack Overflow with most re-iterating what’s already in the Wikipedia link above
- [Wayback/Archive] Which Programming Languages Index by One? – The Renegade Coder adds one to the the entries in the Wikipedia article and includes relevant links
- ALGOL 60 (same as ALGOL 68)
then summarises nicely:
At the end of the day, it doesn’t really matter how a programming language approaches indexing.
- [Wayback/Archive] Programming Languages where indices start from 1 (NOT 0) shows that manually typing over a list is not a good idea: hello ALGOL 98!
Query: [Wayback/Archive] which programming languages have arrays start at one at DuckDuckGo
--jeroen






Leave a comment