4 ms·
My least favorite thing so far was indices starting at 1. It seems blasphemous, in a way. On a more serious note, I agree that R being too charitable in interp
by sva_ 5y ago
My least favorite thing so far was indices starting at 1. It seems blasphemous, in a way.
On a more serious note, I agree that R being too charitable in interpreting things (seemingly without warning) seems to be a problem. You'll have to do some debugging to make sure it actually does what you intended it to do. I've only dabbled in it a bit though.
- ekianjo 5y ago> It seems blasphemous, in a way. It's more natural. You never count from zero with real life objects.
- hashimotonomora 5y agoIt’s pretty standard in math software such as Matlab and Octave.
- Mikeb85 5y agoIt's standard because indexes start at 1 in Fortran. Not sure why it's an issue, especially because you never need to use loops in R anyway.
- CornCobs 5y agoHonestly indices starting from 1 fits really nicely in most situations. 1-based indexing together with ranges and inclusive range-based indexing makes loops and subsetting code really readable IMO
- kergonath 5y ago> My least favorite thing so far was indices starting at 1. It seems blasphemous, in a way. In the real world we start counting from 1. CS people cannot stop complaining about it but it makes sense in languages used for mathematics and statistics. Zero-indexing is not very relevant if you don’t care about memory layout.
- sva_ 5y agoI know plenty of mathematicians who insist 0 ∈ ℕ. It's a bit of a joke, like arguing over tabs vs. spaces though. May I recommend you this fabulous short essay by Dijkstra: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E... It has nothing to do with memory layouts.
- kergonath 5y ago> It's a bit of a joke, like arguing over tabs vs. spaces though. It is taken very seriously, though. This “issue” comes up very often when some people come and lecture others about how stupid the language they use is. > May I recommend you this fabulous short essay by Dijkstra That essay is not fabulous, it is obnoxious. I know you either love or hate Dijkstra and he enjoyed being a contrarian, but he’s unconvincing. The only point that surfaces during arguments on 0-indexing is iterating over 1..N-1 instead of 0..N. That’s basically what he wrote himself. This could have been solved with just a bit of syntax if it were really a problem, and it remains largely because C did it that way to simplify pointer arithmetics. It does not change the fact that for the vast majority of people, the first element in a list is, well, first. The proper way of handling this is to allow for arbitrary indices, because you will always find contexts where a different scheme makes sense (e.g. iterating from -10 to 10 is sometimes natural, and would otherwise require some index gymnastics). Insisting that one narrow view is the correct one is just annoying.
- sva_ 5y agoI dunno, it seems you misunderstood me, or idk. I clearly said that it is completely arbitrary to choose one over another, and expressing a preference over either one is just a way of poking fun at people who are anal about choosing a specific one. So there isn't really any disagreement, though I'm always amazed at what lengths people go to, to express what they think, while they're really just arguing about the definition of some thing. > It is taken very seriously, though. And those who do take it terribly seriously deserve being poked at ;)
- ProjectArcturis 5y agoThat's my favorite thing for R relative to Python. Far more intuitive to start at 1 rather than 0.
- epgui 5y agoMany languages are like that. I learned recently that indices also start at 1 in PostgreSQL / PLpgSQL.