>arrays are 1-indexed
literally a garbage-fire language that belongs in the trash
>arrays are 1-indexed
literally a garbage-fire language that belongs in the trash
Other urls found in this thread:
cs.utexas.edu
godbolt.org
twitter.com
arrays being 1 indexed actually makes sense, 0 index is just a holdover from shit like C where arrays are just pointers in disguse
Hey, that's my name! :3
But they still are.
most languages dont decay arrays into pointers anymore, no
If you work with math 1-index is fantastic to translate formulas with summation directly into code
What do they do instead?
they remain an array
depends if the language/framework/library was developed with FP in mind
R/Julia yes (also they are both 1 indexed)
Python+Pandas """decays into a pointer""" since the dataframe is often edited in place
I don't get it. If they don't "decay into a pointer", how are they represented?
how do you think that array is stored and accessed in the memory
>Getting this mad over a small, insignificant, arbitrary detail that can easily be adapted to
1-index arrays raise up
this boy needs a shorter haircut
like computer programmer begin autistic
Hmmm ...
It doesn't matter if that behavior is accessible to the user, it's still done that way under the hood.
it doesn't matter that it's done that way under the hood, what matters is how it's represented to the programmer, if arrays dont decay into pointers there's no reason to use 0 based indexing apart from tradition
If being 1 indexed is wrong, I don't wanna be right
*sips*
They are not, it's only a function arg thing with the C ABI. godbolt.org
I bet you want to remove increment and decrement operators because they're confusing.
Most onions languages do so he probably does
/thread
I don't find 0 indexed arrays confusing, there's just objectively no reason for them to be that way
It doesn't matter how an array is stored in memory, or how args are passed between functions for that matter if you don't have access to either.
I think that hair is perfect for boys user, it's really cute
Based. Even Lisp unfortunately fell to this bad meme.
Indexing should really start at 1. It's more straightforward. It makes more sense. It's more logical.
I understand the rationale behind starting at 0 (offsets), but that's something a compiler should be able to deal with.
A high-level language should really allow you to start indexing at 1, as it should be, and let the implementation take care of translating it.
Not him, but using them inside expressions is retarded.
They are fine if used in isolation in a single statement.
Define "onions language".
>t. I have never used a low level language
What kind of low-level language do you use?
C, assembly, and C++
Only one of them is a low-level language, and it doesn't have increment and decrement operators which you can use inside expressions.
I didn't imply assembly has that operator, I was replying to your question on what languages I use
You implied C and C++ are low-level languages.
0:2e-3:2π .|>d->(P=
fill(5
No, I had implied you hadn't used one
literally retarded to start at 0
what programs list shit as 0 - x? (not programming languages) name shit that the user fucking sees the 0, maybe 1% of programs.
Do line numbers in text editors start at 0? no..
nothing fucking does
yet when you start your gay fucking array you have a fucking 0 that nobody wants right fucking there.
>>What kind of low-level languages do you use
>C, assembly, and C++
>I didnt imply C and C++ were low level
I didn't, you're drawing an arbitrary conclusion like an untrained AI. How are you getting past the Captcha?
>arbitrary conclusion
>what kinds of x do you use
>y, z, w
>no, i never implied y and w are x
>stating what you literally said is an arbitrary conclusion
Your backpedaling is embarrassing to say the least.
1-indexing doesn't sound like a bad idea until you find off-by-2 errors in your colleagues' code.
Honestly, there are tradeoffs either way.
I love having to write "i
The thing is, these kinds of errors would exist only because programmers have been brainwashed for decades into believing 0-indexing is normal. That's not an intrinsic problem of 1-indexing.
1-indexing is the *right* way to index any list-like data structure. It's the logical way someone would number elements in a list were it not for programming languages that use 0-indexing.
0-indexing is an unfortunate leftover of C. Even older languages, such as Fortran, use 1-indexing, because it makes more sense.
The only argument in favor of 0-indexing is that
>it more closely maps to array offsets when compiled down to assembly
However, that only applies for raw arrays, contiguously allocated in memory. There is no reason why, say, a linked list in Python, should start at 0 other than historical reasons. It doesn't even correspond to the actual implementation.
>off-by-2 errors
wouldn't that still be an off by 1 error with 0 indexing?
The real disadvantage of 1-indexing is it introduces an "invalid" index when using an unsigned integer.
array[0] has to become some special error case in the language.
Not to mention that a lot of the mathematics in computer science also uses zero indexing.
based and redpilled
0-based indexing was a mistake
You could so something like Python does with list[-1], returning the last element.
sure thing, tranny
Now THAT is fucking retarded.
array[0] just becomes the end of the array, or you handle it like any other language does when accessing an out of bounds index.
The are just as many, if not more, mathematical functions which start their index and 1. Either way you need to offset for whatever the series requires.
And ALGOL supports arbitrary indexing... C wasn't the first language with zero indexed arrays so your µ-rant is worthless.
C wasn't the first language with 0-indexing, but it's definitely the one that popularized it.
>you need to offset for whatever the series requires
or let the compiler do what it does well.
Homo
Your compiler won’t fix your math being wrong if your series assumes 1 based indexing.
why doesn't using whatever indexing your calculation requires fix the problem?
Someone sucks at natural numbers.
Only if you are OK with having the 0th element empty, and be careful to not to let that cause bugs elsewhere.
All statistical languages use one based indexing. Its much more intuitive. Many algorithms are shorter with it (no plus ones everywhere, and arrays length is equal to it's last element, etc.) If you actually look at the history of why 0 based indexing is common, it was just a small compiler optimization. There's literally no reason to keep it.
get real
kys you're self incel
For math based languages (C is not), 1 index makes more sense
gets it
not every language has to use the same data structures with offsets from the first element
Why does Julia not have a waifu mascot yet?
0 indexing is literally retarded
t. never done any statistical or mathematical programming of any kind
The 1-indexing is actually a marketing strategy. The creators of the language knew it would keep the discussion about it going.
Same question.