Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It doesn't matter how cool the slice notation is when people have trouble accessing single elements!

1 based is better for human counting and 0 is better for certain mathematical expressions, usually when thinking about offset from the start rather then list position.

Clearly it is a judgement call, but I personally think counting is more important for the same reason PI is wrong. We are confusing ourselves because easy things aren't intuitive.

Imagine you have:

var list = ['first','second', 'third']

`list[2]` should clearly be the second element (not third), just as PI / 2 should mean half a circle (not 1/4).

We wonder why there aren't as many computer science / math grads. Well in every intro class in the world people are getting confused by this.



Depends on how you read `list[2]` "Start at the beginning and move two elements along" works perfectly well.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: