3 ms·
I grew up on languages that were 1 indexed - BASIC, VB, VB.Net. It took me a long time to get used to 0 indexed, primarily in college and later in working with
by donatj 6y ago
I grew up on languages that were 1 indexed - BASIC, VB, VB.Net. It took me a long time to get used to 0 indexed, primarily in college and later in working with more C inspired languages, yet I think 0 indexed is superior. Why?
Numbers in programming start at 0, even in the languages with 1 indexing. Period. When I initialize an integer, unless I explicitly set a value, it’s 0.
From a purely pragmatic standpoint, making the first number an invalid location in a list just adds unnecessary complexity and increases the odds of off-by-one errors. On the same token, there’s nearly no benefit to starting at one.
- IlliOnato 6y agoNo, no "period". There are plenty of languages that either require you to initialize your variables, don't allow to use a variable until it's initialized, or give an uninitialized variable a special value like "undef" or "Nil". I agree that BASIC is inconsistent, but there are many languages beyond Basic and its descendants... I'm afraid your argument still sounds like "C does it, so it is right" mentality.
- secondcoming 6y agoI'm pretty sure that VB is/was 0-based, but that was controllable per-module via Option Base https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa266179(v=vs.60)?redirectedfrom=MSDN https://docs.microsoft.com/en-us/previous-versions/visualstu...