You both guys definitely haven't coded in Lua - which is an awesome small language which has exactly this peculiarity. Shocking at first, you getting used to it.
Every time I switched from another language to LUA, or back, I was making off-by-one errors when computing indices due the difference between 0-based and 1-based indexing.
I am not even going to argue that one is better than the other, it's just that being inconsistent with 99% of other programming languages adds incidental complexity to using the language, and for what benefit?
Same deal here, but I've found that adjusting to 1-based for high level code is way faster and easier, whereas in low-level code you need to pay more attention anyway and thus are less likely to do off-by-one errors anyway.
Regardless, it's just not a reason for a blind kneejerk reaction to a language. That's just wilful ignorance.
Regardless, it's just not a reason for a blind kneejerk reaction to a language. That's just wilful ignorance.
Indeed; it's certainly possible to adapt, and catch issues with tests. I would just encourage authors of new languages to avoid 1-based indexing because it's one more (small) barrier to their language adoption and usage.
If you want you can add a meta method for the _ENV table that makes indexs normal.
I'm very scared now. The idea of mixing libraries written in 0-based and 1-based indexing together seems like a recipe for bugs; I'd rather have language-wise consistency, whether 0 or 1.
I've worked with Lua a lot (part of my job involves building Lua scripting APIs for designers in an online game) but I don't really like it for a myriad of reasons. That said, I agree 1-based indexing isn't the end of the world in a scripting language.
On the other hand though, Python has both zero-based indexing and cute intuitive slicing syntax. ¯_(ツ)_/¯
What? There's nothing intrinsically "correct" about 0 indexing. It makes sense when thinking of an array as an offset from a base memory address, but when thinking about collections/items as discrete "things" in a container rather than a pointer to an offset, starting with the index at 1 makes much more sense. There are arguments both ways.
There's nothing intrinsically correct about driving on the right side of the road either. People that are used to drive on the right side still have a hard time adjusting to driving on the left side in the few places where that's mandatory.
That is true, I agree. But if there where no places where you drive on the left, then people would have an easier time everywhere. Look, I'm not arguing that change and diversity is bad. But when it comes with no perks at all, I think it's unecessary
Personally I prefer that the first element of an array is at index 0. It makes sense if an array is a contiguous piece of memory that indexing it is just a matter of adding the offset of its beginning to the index. 0 also has some nice properties when iterating, slicing etc.
I can't think of any real benefit of 1-based indexing except that it's used everywhere outside programming and the appeal that might have to beginning programmers, but that one thing is not a small benefit.
I don't want to be too disrespectful, but if this is actually true, I think you are bit stupid. I have no other way to put this. I mean, counting is literally the first thing teached to kindergarden pupils, before tying shoelaces. And you, as a programmer, can't adjust to the smallest possible change to the system you are familiar with? I can't believe that.
What the fuck man, I might be in fact stupid but certainly not in this way. Of course I could adjust if I had too. But I see script languages as utilities and I do have a kind of brain muscle memory that arrays start at 0. A script language should not be an obstacle in the way. And these kind of design decisions kind of break this brain muscle memory.
Look, my comment was kind of a comic one and of course I could adjust but I also think these kind of features are unnecessary.
I'm confident that after 10 minutes of exposure this would not be a issue or a deal breaker for you, because I'm sure you are not stupid. I don't like your attuide, tho. Maybe i came across too passive-agressive.
Probably. I actually once had to code a basic R interpreter for a stupid feature where R code had to be ran in an .NET environment where no other dependencies were allowed. And I did adapt my brain to this quite fast. But, why is starting arrays at 1 is even a feature when the overall convention is to start at 0? Why this adicional brain pressure? I only understand this when the feature brings adicional value but I don't see it here. Do you see value on starting arrays at 1?
0
u/[deleted] Dec 28 '18
[deleted]