News for hackers. Stuff that matters.
Re:I open sourced my game along with a tutorial on how to ma... by sergeykish on Tuesday July 07, 2020 @05:21AM (#23757235)
I am to used to 0-indexing to judge. If it is not clear already - I am not going to participate in who is better. My thread is

>>>> a string will always be:

    s:sub(1, #s)
>>> In a language that used the half-open interval convention we would end up with:

    s:sub(0, #s)
>> You would end up with:

     s:sub(0, #s - 1)
> That would be strange, in Ruby

    s[0, s.length]
Your argument against 0-index is just plain wrong. No one creates such API. It would be to awkward - either #s should be `length + 1` or `sub` should expect `length + 1`.

----

>>>> Once you get used to it, ... you don't need math when grabbing a range.

I assure you once you get used to 0-indexing there is no need for math when grabbing a range

    s[0..s.length] # that is identity through range in ruby 
----

>>>>> 1-index kept throwing me off though

>>>> it does help prevent a whole bunch of off by one errors

You claim superiority, it is not. I can't remember such errors in my life. It may be easier to describe to children but I doubt it. My first encounter with 0-indexing was with ruler - "why it starts with 0?" - pre-school. I can claim 0-index is natural. I would not.

There is no better model just "happy accidents".

There are no comments on this comment yet.