Indexing - Teaching Things Better

Ryan Palo on April 13, 2017

I want to talk about indexing. More importantly, I want to talk about how we are explaining indexing to new programmers. But first, I need to l... [Read Full]

Hi, since I am apparently half of your audience :) I'd like to thank you. I work in a language that is one-based and for the life of me I could not imagine why on earth anyone would like to start counting at zero. I have read religious stories on why one is better than the other, but none of them convinced me.

In the language I work with (OpenEdge 4GL) strings are 1-based. The reasoning behind this is that indices in OpenEdge do not surround the letters, but you merely indicate which letter you want to have. The first letter of a word is letter number ONE, so you specify ONE: SUBSTRING('beans',1,1) gives 'b'. And if you want to have 'an' from 'beans' you would have to use SUBSTRING('beans',3,2).

I still don't think one of the methods is better than the other. They both exist, but your explanation actually makes it easier to understand. It's not that I now find it 'better' than 1-based counting, but at least it is explainable. Thanks!

Interesting! I've done some work in MatLab and I think you can set it up similarly. It always threw me off to go back and forth, but I agree, I can see the benefits of both as long as there is a reasoning behind it.

Hi, I must be the other one of you audience...

Anyway this is a great content for me as I'm teaching programming to my daughters. I'm going to use your post as part of our curriculum.

100% of goal met! 😬 Glad I could help!

code of conduct - report abuse