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

Well... I wrote a snake game in python and lua.

0 based array (python) : screen_pos = x + y * width

1 based (lua) : screen_pos = 1 + x + y * width

shrug

So 0 based seems to work a little better for arithmetic based array references. But really you'll never resolve this to perfection. Assembly language programmers are very unlikely appreciative of 1-based.

Its all about what you're comfortable with.

Those wanting pointers can imagine a base address added to each calculation. 1-based then needs a -1... which is then a strange thing to advocate for.



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

Search: