Yeah i start my array at 1

>yeah i start my array at 1

Attached: 1566133320682.png (626x744, 404K)

Other urls found in this thread:

cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
twitter.com/NSFWRedditImage

As if we needed any further proof of you being a faggot.

Do you start your X and Y axes at 1?

Attached: pggnBV61SlmzODptJp3V_49288_graph_0505b_lg.gif (981x1024, 48K)

not the same thing, faggot

dilate

[code ]#define 1 0 [/code]
Works on my machine

number system is a social construct

[kode]
array.size == 5
ok I want 5th item
array[5]
system crashes with index out of bounds
[/kode]
Somehow I was supposed to know that 5th item is at 4th index

I swear to god I can't use this board anymore, I'm going to Jow Forums where I'm allowed to hate people for forcing their mental illness down my throat

it's weird how girls with penises are always on your mind user haha

>Le_Funny_Rage_Comic.GIF

If you're going to appeal to maths you're in for a bad time because some would argue that 0 isn't even a proper number. Furthermore, indices usually start at 1 in maths.

Just to clarify, when i say "not a proper number", i meant that it may not even exist.

Bullshit TED-talk tier clickbait non-theory

Ah, a fellow Haskell programmer.

>want to deserialize 1d table to 2d array
mat[math.floor((i + width - 1) / width)][(i - 1) % width + 1] = but[i];

Attached: a33.png (558x614, 45K)

imagine being this retard and liking retarded memes

degenerate

t. MySQL

Let's be honest, arrays SHOULD be 1-indexed. The only reason people use 0-indexing is because it's a convention and they want to feel like they're part of a super cool secret h4x0r programming culture.

We don't 0-index things when counting in real life, do we? We don't say "this is my 0th child", do we? We don't say "take the 1st road on the right" when we actually mean the 2nd road on the right, do we?

Modern programming languages should use 1-indexing. Prove me wrong. You can't.

It starts at zero because its an offset, not a "counting index".
*arr + 0 == *arr == arr[0]
You're programming a machine that stores and manipulates pointers to data.
2 ez

It's okay to start a heap array at 1 to avoid extra calculations.

>We don't 0-index things when counting in real life, do we?
Yes we do.
Everytime you direct someone to go X meters you're using their current position as 'meter 0'.
Array indices are an offset, not a count.

based LuaChad

Attached: hdmi.png (340x374, 233K)

in C, array[0] is syntactic sugar for *(array + 0), which, funnily enough, means 0[array] is valid

no, 0-indexing is for the compiler. the pointer refers to the location of the array plus the offset. so the first item is just where the array is pointed to. it's calculated by array + offset.

if you used 1-indexing you'd have array + offset - 1 which is unnecessary.

also, 0 should be the first natural number, but you clearly aren't ready for that tier of knowledge

>The only reason people use 0-indexing is because it's a convention and they want to feel like they're part of a super cool secret h4x0r programming culture.
No, it was because it was a more sensible way on more lower level languages.
a[b] is literally just syntactic sugar for *(a +b), thus it is very sensible to think about b as an *offset* and not as the b'th element.

It's because of a confusion between offset, a concept closer to the hardware and index, a concept closer to how mathematicians usually think.

>0 is an offset, not a count
Fair enough, and maybe that made sense back in the 70s, but I don't really think it makes sense today, and I for one think arrays should be 1-indexed in modern programming languages.

>imagine being this brainlet
you can translate from any point to any other point, 0 as a point doesn't have any special meaning. Therefore yes, number systems (also the fucking plane you used as """"counterexample"""") are a "social construct" as in I can define the structure as starting point + base the way I fucking want to, there no fixed way to describe it
Go back on sperging about muh left and other retarded shit with your sub-50-iq friends

so you didn't read or understand a single post replying to you, got it

Doing math on an 0-indexed array is much simpler than a 1-indexed array, especially for multi-dimensional arrays.
int array_3d[a][b][c];
assert(
array_3d[1][2][3] ==
*(
array_3d
+ (1 * a * b)
+ (2 * b)
+ 3
)
);

cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

and i just reported you for being nigger cattle

It depends on what kind of language you want to create. In many languages which are more higher level and/or mathematics focused it is already the case that they are 1 indexed, see eg. MATLAB or FORTRAN, both wanted more mathematical representations "matrices" instead of "arrays".
C on the other hand didn't think about "matrices" like FORTRAN but about "arrays", an array is basically just a range in memory and you start with a pointer to the first address, therefore it is very reasonable to conceive of array[0] as the first element + 0 offset, thus the elements itself.
And C has been the most influential programming language in history thus "doing what C does" has been a very common trend in language design at least in languages with no special conception of the "array" as a "matrix".

I personally do not think it matters much at all, both choices are fine and represent a slightly different way to think about programming logic.

Attached: 1549038126075.gif (200x200, 30K)

The correct answer is to have multidimensional arrays built into the language like Fortran (which allows you to set the offset to anything you like, and also allows for array slicing), not to have shit arrays like C where you need to do the multiplication yourself.

I read them all and you don't have an argument, got it.

Attached: smug clarkson.jpg (811x709, 45K)

Arrays? Nah I just allocate the right memory and use pointers for everything bro.

Attached: comment_eRbMDQ356mQ9J4qAp2i0eHNpSsZlgEQC.jpg (391x464, 84K)

it didn't make much of a difference for me until I had to translate some matrix stuff to numpy and constantly switch between math notation and this shit

numpy:
a[3] # get 4th element (counting from the beginning)
a[-3] # get 3rd element (counting from the end)
a[1:4] # get 2nd, 3rd and 4th elements


how it should be:
a[3] # get 3rd element (counting from the beginning)
a[-3] # get 3rd element (counting from the end)
a[2:4] # get 2nd, 3rd and 4th elements

based

...

>yes I do use alloca, how did you know?

Attached: gigachad 6.png (680x626, 153K)

>That's right! How did you guess that I exclusively use statically allocated memory made of contiguous blocks of integers, reinterpreted as other data types on read and write, with new processes being forked and used as data providers when memory allocated for first process isn't enough?

Attached: 1563282032621.jpg (640x640, 59K)

> I start my array
That's not a programmer choice. Every language enforces it, at least to a soft degree (lua will let you bypass this, but then you have to implement your own iteration functions and can't use the size operator).
I can't think of a case where "I start my array at 1" makes any sense. It would be "I use a language with 1-based arrays".
0-based is usually better, but 1-based arrays aren't bad when you get used to them.

Yeah makes sense. I wonder why my CS tutors / professors never told me to think of the 0 as an offset. Or maybe I wasn't paying attention, but I did usually pay attention, and I don't remember them saying this.

Not trolling man. Obviously do what you like, the offset thing makes sense now that I know about it, but modern languages give you many comforts like strings being a base type instead of having arrays of characters, so why not change arrays to be 1-indexed? I'm not saying C should change, I'm just saying I'm surprised that modern languages like Ruby and Python haven't done it. But I guess it's a convention so there's no need. I bet there is some meme language out there that uses 1-indexing though.

Attached: 1541046487077.gif (500x374, 167K)

in memory, the fifth item starts at the address of the first item plus four lengths of the items, hence
myArray + (4 * sizeof(item)); // 5th item
myArray[4]; // 5th item

A default isn't enforcement user.

>hurrrrur muh gauge invariance, therefore going against convention is perfectly fine
don't cry when nobody uses your shit, sperg

>i start counting with 0

Not trolling user, maybe don't get triggered.

It is enforced in most languages, because you'll end up with an unused element at the 0 position regardless of what you feel like doing, and indexing into the size of the array will overrun the buffer. In Lua it's softly enforced, because 0-indexing can cause a lot of unexpected problems, and absolutely every function that touches array-style tables will expect 1-indexing, so you'd have to reimplement every one of them yourself, which is exactly what I said if you bothered to fucking read.

>0 is a natural number
Is it positive or negative? That alone explains why it can’t be considered a natural number

Attached: 1551533495061.jpg (200x153, 13K)

Sorry you're butthurt user, I guess you're triggered by what I said but too dense to say why. Sad!

Attached: 2019-08-23-214031_1366x768_scrot.png (1366x768, 17K)

Attached: 1542045270560.jpg (200x253, 13K)

Imagine being so pathetic that you have an entire folder of trollface images because you're too thick to counter anybody's arguments

Attached: 1522778268767.jpg (395x270, 52K)

This is a criminally based post.

This is false from a mathematical standpoint. 0 is the defined to be the empty set. If the empty set doesn't exist, then no numbers exist and your point is redundant

Why is HDMI so happy?

>Modern programming languages should use 1-indexing. Prove me wrong. You can't.

No, indexing should be user-defined, as Fortran and Ada (which allows even negative starts) do. That way you can use whatever you find more easy to understand in the concrete problem you're working on.

Attached: ada-2012-19-728.jpg (728x546, 74K)

Ah so you ran out of trollface images, how sad and fucking pathetic

Thanks lad

learn how memory works you fucking brainlet

> i dont touch zeroes unless there are at least six of them in a row preceded by the number of millions in my bank account

> zero is not unambiguous in common script, it shares the visual space with the letter o meaning it is a potential source of code bugs and backdoors

> donald trump is a zero, you really want trump in your code?

> zero doesnt actually exist, it is just an abstract idea that makes things overly complicated

> math is hard

> zero was literally made by sandniggers and we just bend over and take zeroes every time we code?

>zero was literally made by sandniggers
Nah, it was a poo in loo concept which the was adapted by the sandniggers.

Although the concept kinda existed even in ancient greek, as even in Euclid the notion of a point, being something without extending in any direction, existed.

I maintain/work on Ada projects at the place I am employed at, and there's a fuckton of arrays where they either start at 0 or 1, it's inconsistent. Doing array'first is not neat either.

Attached: n0Kel2p.jpg (1357x1281, 222K)

>> one is not unambiguous in common script, it shares the visual space with the letters l (lower case L) and I (upper case i) meaning it is a potential source of code bugs and backdoors
Fixed.
Did you see what I did there?

...or lua, matlab, julia, etc..

Why, yes, how could you tell?

Attached: 0sftgilsuw131.jpg (699x700, 43K)

I always use this piece of code everywhere. Staring by 1 is based, maxxaesthetic and redpilled
let arr = [null];

arr.push(1488);

function getRealArrayValue(index){
return arr[index+1];
}

console.log(getRealArrayValue(1)); //ouputs 1488

There being a convention in a first place is a proof of it being socially constructed you imbecile

Feel the power of my cock

It outputs undefined you genius.

Go to bed, Rick

Attached: baste.png (450x399, 221K)

Oh, the irony

>knows nothing about memory
niggers like you should have their hands cutoff

>set THEORY

okay faggot

0,0 Is top left corner you dummy.

you mean bottom left

The convention is to do the transforn beforehand, so that you're already working with an origin at 0.
Otherwise everyone would have to do this transform themselves, which just wastes time.
Origin being at 0 is not a convention, but fundamental property of Cartesian coordinate systems.

hmm, how do you tell the computer when the variable ends? this seems kind of wobbly.

You shouldn't have worked so hard to make it look like real C code, since that's not how pointer arithmetic works in C. RIP confused noobs

You should have typed *(arr + 0) == *arr == arr[0]

>arrays are offsets not indices
no
pointers are offsets
arrays have an index

Julia? more like CHADlia

Attached: images (1).png (467x315, 6K)

You don't. The computer doesn't need to know. Only the routines that read the array need to know.

The index for the array is the offset from the data. If you have data at address 5000, the first byte starts at 5000, not 5001. Hence array[0] is the first byte (5000 + 0). From a computing perspective it doesn't make sense that arrays start at 1.

How to not think about arrays: I want access to the element at INDEX N.
How to think about arrays: I want access to the element at OFFSET N