Indexing from Zero: Part 1

Indexing from Zero: Part 1

First, we’ll take a look at the transcript (or you’re welcome to open the image above):

Starting with index 1 is meaningful only in cases you’re not doing any computation on the index value itself… but then you could start from 14 too without much problems either.

If the actual numeric value of the index is used for computations then you will find that in most cases the correct index for the first element is 0 (e.g. polynomial terms where the index is also used in exponent).

So when doesn’t matter you can use 1 (2 or 42), but when it does you really need to use 0. Then why not using 0 always?

The number 0 was a great discovery, if you’re teaching please don’t cripple your students brain making them thinking in roman numerals, you’re not helping them.

One time, I thought it would be fun to write an article about a common problem I was noticing in my introductory Java classes: I was constantly having to remind students that the substring method uses an inclusive starting index and an exclusive ending index. While the math behind that convention is sound, the convention itself is counterintuitive.

Unfortunately, some folks would prefer you didn’t challenge the status quo. In particular, this guy went out of his way to write me three comments that look just like this one. Alarmingly, these are the only three comments he’s ever made on the platform. Apparently, I really set him off.

If you came from the Wall of Shame, here are links to the previous and next comments. Also, here’s a link back to the Wall of Shame.

Jeremy Grifski

Jeremy grew up in a small town where he enjoyed playing soccer and video games, practicing taekwondo, and trading Pokémon cards. Once out of the nest, he pursued a Bachelors in Computer Engineering with a minor in Game Design. After college, he spent about two years writing software for a major engineering company. Then, he earned a master's in Computer Science and Engineering. Today, he pursues a PhD in Engineering Education in order to ultimately land a teaching gig. In his spare time, Jeremy enjoys spending time with his wife, playing Overwatch and Phantasy Star Online 2, practicing trombone, watching Penguins hockey, and traveling the world.

Recent Content