This is why you should use -1 based indexing like DreamBerd.
@NewSchattenRayquaza6 ай бұрын
Ma man here is cooking some world peace right here
@CEOofCulturalMarxism6 ай бұрын
Or BS
@Dekharen6 ай бұрын
Whenever I feel bad I go and read the dreamberd specifications 😆
@NithinJune6 ай бұрын
literally
@Sameer.Trivedi6 ай бұрын
Number line starts at -infinity that's the only correct way of indexing.
@MrRobix136 ай бұрын
Man doing live reactions, he won.
@fus3n6 ай бұрын
Actually kind of weird... i feel like he is trying not to put effort into this place, everyone came to see him give advice and stuff after all, i am sure he got permission for these videos or the youtuber doesn't mind anyways, but... yea... you could have at least make one presentation for this.. doesn't matter ig, everyone will gobble whatever's showed to them
@rodrigohmoraes6 ай бұрын
@@fus3n most (all?) of his content is reaction, what did you expect him to do? A circus show?
@ciziadevos6 ай бұрын
@@fus3n nobody forces you to stay in the damn room, or on this damn video, if you don't like it
@fus3n6 ай бұрын
@@rodrigohmoraes No, i expected him to do what usually happens in these kinds of conference/meetups or talk videos how many times have you see this kind of videos where the guy literally reacts to a youtube video? We could say they didn't expect to go there just to see someone react... it feels effortless as if they wanted to do that they could just watch his videos, as you said which is fine too.
@fus3n6 ай бұрын
@@ciziadevos Yes... and i said nothing about him forcing anyone to watch this or be in that room...
@ZingsVideos6 ай бұрын
0 makes sense because it's an offset. If you want someone to stand still, you don't tell them to walk 1 mile.
@spacecadet29266 ай бұрын
Never thought of it like that. Makes sense
@jhny06 ай бұрын
very good analogy
@mAcCoLo6666 ай бұрын
I guess that started with c, c++ and pointers. When you think of items 1 would make more sense.
@samuelswatson6 ай бұрын
The whole point is that 0 makes sense when your index is functioning as an offset, and 1 makes more sense when it isn’t.
@SkyyySi6 ай бұрын
That makes sense for as long as you think about arrays as memory addresses, rather than lists (as in, like, an actual list). So basically just a rephrasing of the "0-based indexing is right because pointer arithmetic" argument
@heyrim726 ай бұрын
Fun fact already on minute two. In Germany we are actually counting floors starting with a a zero floor. "Erdgeschoss": ground floor, "1. Etage" is up one level from ground floor (and now I am already confused what it is in English). So 0 based index systems have been working well for a couple hundred years.
@porky11186 ай бұрын
But nobody actually calls it 0. It's usually E.
@DJKav6 ай бұрын
We use the same notation in the UK.. Ground Floor / Floor 0. Then it could be 1st Floor. Or at my local hospital, -1 (A+E, Radiology) / 0 (Ground Floor, Main Entrance / 1st Floor / 2nd Flor / 3rd Floor / 4th Floor Hospital is built on a slight incline, so A+E is still on the ground, but the rest of the main hospital extends above it, level with the upper ground.
@markus.schiefer6 ай бұрын
True, and works well for elevator buttons, but if you tell me that it never caused confusion during conversations, you must be living in a bubble. ;-)
@AntsanParcher6 ай бұрын
@@porky1118 That's merely a matter of notation.
@cybernetic-ransomware14856 ай бұрын
@@porky1118 exept elevators
@asdfghyter6 ай бұрын
my favorite example of 1-based indexing is used where it makes zero sense is intervals in music. if you add together two third intervals you get a fifth interval. 3+3=5. 5+4=8. the first interval, the unison, is a zero offset
@drdca82636 ай бұрын
Yes! This makes music theory way more confusing. I pretty much have to convert what people say in whatever tutorial into 0 based before listening in order to understand it
@GlueC6 ай бұрын
I can't believe how long I went without ever considering 0-based scales. I feel like there are other things that can be done with that. Whoah.
@p-y82104 ай бұрын
Music theory is fucking bonkers.
@denysholovatyi31492 ай бұрын
I've been playing music for over 20 years, programming for 7, and I've never thought about this. This is a stroke of pure genius. Thank you for pointing this out.
@voskresenie-Ай бұрын
@@drdca8263 that is ridiculous. just learn it properly. it might stretch your brain a little, but you're better off becoming smarter than performing constant conversions.
@mgdotdev6 ай бұрын
Imagine going to a conference in person, to see a speaker lecture in person and still watching a recording
@jsonkody6 ай бұрын
.. still watching IRL react video :D
@ChristofferLund6 ай бұрын
This format is insane, yet for me on KZbin it's exactly the same as it was
@jarylsim19736 ай бұрын
Conferences? Is that what they call real life Twitch?
@blackspitit6 ай бұрын
conference? it seems more like a comedian to me. A conference is not with a video.
@Lolimov6 ай бұрын
Prime at its Prime. I felt the emotions in the end. This is a man truly talking about what is important to him and he does not hide his feelings about this. I admire this fucking guy.
@powercore20006 ай бұрын
I felt that ending in my soul man. It was a beautiful message to end on.
@ChristofferLund6 ай бұрын
I think him having gone through what he’s done is a big reason why he is successful and why I enjoy watching him. Keeping it real.
@Kane01236 ай бұрын
Could hear it as soon as he started choking up - I would have bailed asap. Bro did some real man shit right here.
@raq10246 ай бұрын
Damn that ending hit hard and made a great point. Salute to Prime.
@joelperpetua39296 ай бұрын
man almost quoting the bible at the end "What will it benefit a man if he gains the whole world yet loses his life?"
@primbin_6 ай бұрын
1-based indexing is significantly worse for higher dimensional arrays. If I have a cubic 3-dimensional grid of width 16, its way more intuitive to index it like this (0-based): grid[x + y*16 + z*256] As opposed to this (1-based): grid[x + (y-1)*16 + (z-1)*256]
@Akronsus6 ай бұрын
oh nice. that is even better than the "it makes sense as an offset" argument, since yours shows that 0-indexing makes sense for every enumerated data
@georg98996 ай бұрын
I think for higher dimensions [x][y][z] would be a better way to index the array. In this case both 1-based and 0-based indexing would be more intuitive than doing the calculations for the offset manually.
@maidenlesstarnished88166 ай бұрын
@georg9899 I believe you misunderstood the comment. They're not referring to the indexing syntax. They're referring to the logic for computing the index.
@z278z6 ай бұрын
(grid - 16 - 256)[x + y * 16 + z * 256] Arrays should start at index -1, so 3d arrays should start at index (-1, -1, -1)
@xpusostomos6 ай бұрын
All you're telling me is that your language is brain dead and doesn't support multiple dimensional arrays natively
@aes0p8956 ай бұрын
The concept of 'nothing' or 'zero' definitely existed. They just didn't have agreement on how it worked in math (or a system to use it effectively).
@pokefreak21126 ай бұрын
1-based gets nasty the moment you need to do any index arithmetic. Like let's say you have a pixel array of WxH pixels and you need to generate an index given x and y. With 0-based thats just "x + W * y", while with 1-based it becomes "x + W * (y-1)" I can't think of any code where 1-based is better beyond it being slightly more intuitive for beginners.
@spacelem6 ай бұрын
True, but you do rarely need to do that with 1-based languages. X[x,y] is right there.
@porky11186 ай бұрын
And the intuitivity issue can be fixed by fixing natural language and teaching children to count from zero from birth :)
@spacelem6 ай бұрын
@@porky1118 we do count from zero. If there are no things, there are 0 of them. When the first thing comes along, there's 1 of them. In a race, once 1 person has finished, they are 1st. Nobody wears the "I came 0th" badge, unless it meant "there were zero people in between me and the finishing ribbon" which... is a pretty weird way to say you won.
@porky11186 ай бұрын
@@spacelem Yeah, indexing would be the proper term. But since the maximum index represents the count, it's just the same. But still, you'd still count the same way since you usually don't care about the indices. But calling myself the "zeroth" (I don't like the term) would make sense. If the rank is just the same as the number of people who are better than me, that's just more intuitive.
@spacelem6 ай бұрын
@@porky1118 I think "intuitive" is very much subjective, as describing where you came in a race by how many people came before you does not sound at all intuitive to me. If you're doing a test, and you answer no questions correctly and score "0", that's not an ordering, then it really is counting and 0 is intuitive. Saying "I got 37/50" is intuitive. Describing where you came on the test relative to everyone else is not counting, it's ordering.
@tinnguyen50556 ай бұрын
0 base array works great with modulo arithmetic.
@spacelem6 ай бұрын
In Julia, you have mod and mod1 functions. If you need n and not 0, just use mod1 instead.
@Daniel_WR_Hart6 ай бұрын
I never appreciated 0-indexing until I tried making a circular array
@MarcCastellsBallesta5 ай бұрын
I love your VLC-like profile picture!
@angeldude1015 ай бұрын
Minor problem, the vast majority of languages are broken by default for this, at least for negative indexes. Using unsigned values already takes an unrelated modulus unless the list itself has a length that's a power of two, and if the index is signed, then the remainder operator is broken by design and you need to manually add the length of the array anyways in order to simulate a working modulo operator. If you're instead referring to counting past the end of the array and then looping back to the front, then there's no problem and the positive indexes actually have work modulo operators. Python is one of the few languages whose signed remainder isn't broken by design and it just so happens to also be one of the few languages that allows negative indexes to index from the end, where said modulo is performed automatically. (I don't know if it works when idx/length is outside of [-1, 1).)
@Enjgine5 ай бұрын
I invited 1 people and they both showed up. I asked them to divide into 1 groups and there was 0 people in each group.
@chi_said_hi6 ай бұрын
The problem with 1-based is that when you do modulo and integer divide operations, there's a missmatch in indexing. Like if you have an array of 20 items and you want to associate them evenly for like 1000 elements, you'd do items[i % items.length()], this way, it'll always be contained within items. But with 1-indexing, item[40 % 20] = item[0], which would error out.
@DominikPlaylists6 ай бұрын
yes, there are very many good arguments for 0-based in math, but there are way more for 1-based. I vote we look at the top 1000 most useful formulas in computer science, math, physics and chemistry that have an index and then decide which one is easier.
@nikitatimaev52976 ай бұрын
@thetukars this will make unreadable code.
@hobe45766 ай бұрын
@@nikitatimaev5297true therefore a must-have feature for ... VBA!
@thomasmaughan47986 ай бұрын
@@DominikPlaylists "and then decide which one is easier." Done! Zero based is easier.
@dimitralex18926 ай бұрын
dude... you cannot tell people to analyse if its better for them to use 1 or 0 and then when someone says "ok, zero it is" tell them "no my friend you are wrong, both can be useful"...
@beest_6 ай бұрын
Tldr: instead of INDEX say OFFSET, because as human readable point of view we are mistaking index and our numeric counting. By this definition arrays must at ZERO based offset
@Deschutron6 ай бұрын
Offset is a great word for a zero-based index. Index is a great word for the number you say while counting and pointing at each item as you count it. "Subscript" is not a great word to distinguish from "index", or to specify that you're starting from zero, because the tradition of using subscripts comes from mathematics, where subscripts are used to write indices, and the indices usually start at 1.
@jnharton6 ай бұрын
Or just accept that your array has a Zeroth position. Try looking up the definition of index some time. Index and indicator have the same latin root. Also, the array is indexed by numbers which refer to a position/element in the array.
@Gregorius4216 ай бұрын
This is the way.
@johnathanrhoades77516 ай бұрын
I do a lot with SQL. It’s 1 indexed. I think it makes sense for the stuff you do with SQL. For anything that needs math, actual locations, modulus operator, etc., I am all for 0 index. Also, thanks for the closing thoughts! No one looking at you now would guess what you had to go through to get to where you are.
@andyc82576 ай бұрын
Such a crazy argument. Pascal sorted this years ago by letting you specify the upper and lower bounds, so you could have whatever made sense. Need indexes from 7 to 12, array[7..12]
@thomassynths6 ай бұрын
Edgar Dijkstra wrote a great short paper explaining why 0-based is intrinsically better. Source: EWD831 "Why numbering should start at zero"
@FighterHayabusa6 ай бұрын
I have to bring this one out from time to time to convince people. It's really well-written and reasoned.
@isodoubIet6 ай бұрын
Insane that people are still debating a point that was conclusively settled in the 80s
@victotronics6 ай бұрын
I drop that article in the class resources of almost everything I teach. He was so eloquent, thorough, and *right*.
@GabrielFury-mg8du6 ай бұрын
LOL, a 'short paper'? By today's standards it was a blog post on Medium: a long-winded trash take with petty stabs at contemporaries. The whole of the text embodies a thoroughly subjective opinion; If only 1982 had also held a medium with a 280 character limit he might yet have expressed his poorly formulated opinion that much quicker.
@jsonkody6 ай бұрын
I know it for years .. he's right when we talk about C He is wrong everywhere else.
@سیدمرتضیموسوی-ث2ل6 ай бұрын
In Persian, weekdays are zero-based. "shanbe", "yek shanbe" "do shanbe", .... yek means one. do means two, ...
@brainandforce2 ай бұрын
And Doshanbe is the capital of Tajikistan.
@Oler-yx7xj6 ай бұрын
Tom Scott in his "bodge" video was using lua, it went exactly the way one would expect
@kezzyhko6 ай бұрын
it went exactly the way zero would expect
@SkyyySi6 ай бұрын
You would indeed expect that considering he also said he likes JavaScript
@Alfred-Neuman6 ай бұрын
@@SkyyySi What's wrong with Javascript? Don't you agree that everything should be re-written in Javascript? Just imagine for a second, computers could be sold with Chrome a the main operating system and you could open Windows in the first tab, and then maybe Ubuntu in your second tab and why not have Fortnite in the third tab? Etc... Of course we might lose like 1 or 2 percent in performance but at the same time it would solve every single problems we currently have with all the other programming languages! Easy programming for everyone, no more security bugs, no more viruses!
@xybersurfer6 ай бұрын
@@Alfred-Neuman it sounds like you've only programmed in JavaScript, because you are asking what's wrong with JavaScript. while it's probably true that there would be less security vulnerabilities related to memory safety with everything written JavaScript, it won't eliminate all security vulnerabilities. do you remember that JavaScript was also vulnerable to Spectre and Meltdown? and it happens all the time that vulnerabilities are discovered and fixed in JavaScript engines. also i don't think JavaScript would be the best choice to write everything in, because of it's aggressive type coercion, which sometimes has resemblance to accidentally accessing the wrong memory in languages like C. not to mention all the other design mistakes in JavaScript that even TypeScript can't fix. vulnerabilities are not even always technical (like social engineering). so "no more security bugs" etc. is something you should be more careful with saying
@colefrankenhoff14286 ай бұрын
@@xybersurfer Way to mix the joke lmao
@MasterHigure6 ай бұрын
As a mathematician, some times it's more sensible to start a sequence at 0 (such as a geometric sequence, where the index tells you the power of the common quotient), some times it's more sensible to start a sequence at 1 (such as the harmonic sequence where the index tells you the denominator). It's the fact that programming languages can't be flexible about it that's the real issue here.
@username77636 ай бұрын
C++ can be flexible about that. It is perfectly possible to create an array class that uses 1-based indexing. This isn't commonly used because it is unexpected in the language.
@MasterHigure6 ай бұрын
@@username7763 I didn't mean it was physically impossible to do. I meant not a lot of languages do it, and it seems like a terrible idea.
@jongeduard6 ай бұрын
0 is the origin. Very simple. This is true in Math with the x, y, z axis, and used as a system in many areas of science like physics And this is true in computers with indexing in memory, in arrays. 1 based counting is for humans, practical when numbering things in real life. That's all. I prefer the 0.
@Forty8-Forty5-Fifty86 ай бұрын
I prefer languages with strict rules that make it annoying to do things the non-standard way. There are so many different plausible ways that this could theoretically be implemented and I don't want to have to think of all of them when all someone had to do was write i+1 when that is what they need.
@NickMak-m2c6 ай бұрын
@@jongeduard 0 is not the origin, zero actually represents nothing. "1 based counting is for humans" it's for computers too, it's actually multiplication that uses the zero, because you're multiplying addresses, and the first address has to equal the first address plus the number of bits until the next address * 0. 365 + 64*0 = 365 (first address) 365 + 64*1 = 429 (second address) and so on In representation, there is no reason to start it with zero, it confuses how math is done in the rest of programming, which is done the normal way where 1 = 1. 0 + 0 =/= 1 in computer math, it equals zero, computer math uses 0 as its normally used everywhere else, and this creates situations where you had to minus one from a calculation that equates to an index position. I see a lot of different reasons why people claim 0-start indexing is the way to go, and it all really is just justifying something people are used to, but if you wanted a more correct representation it'd start with 1. If we switched the norm now it'd cause a lot of chaos for something that a minus 1 or a plus 1 is all it takes to even out.
@Rikaisan6 ай бұрын
I don't know how I feel about live reactions, it's just... If I ever go to a Primeagen event, I would like him to talk about something himself, just like the course he made for Frontend Masters
@NoVIcE_Source6 ай бұрын
at the end he was fully himself
@scythazz6 ай бұрын
It is alittle bit weird isn’t it. Like people are saying that is what theu expected him to do but still… it feels just somewhat awkward.
@Forty8-Forty5-Fifty86 ай бұрын
Honestly, these live audience streams go much better than my actual college lectures from the very few I have seen so far.
@JeremyAndersonBoise6 ай бұрын
He does that too, later in the video, this is just a piece of the event.
@lifeisfakenews6 ай бұрын
"Lua is actually right" alr fine, ill hear you out but i doubt you will convince me
@jsonkody6 ай бұрын
I've spent a very VERY long time studying the historical reasoning about this topic, and TJ did not present the most significant points of why 0-based is not real indexing :/ He had some nice points, but he did not delve too deeply. Zero-based indexing can be understood as 'offset indexing', which is akin to measuring distances on a ruler starting from zero. It doesn't point directly to an element, but rather to the starting point of where the element is stored in memory. This method is efficient for data stored sequentially, as it doesn't require additional information about the size or location of each element. In contrast, one-based indexing, which I refer to as 'real indexing', naturally aligns with human understanding of order, where '1' points directly to the first element, making it more intuitive for directly referencing items, especially in mathematical and scientific contexts. So 0-based indexing is really necessary in low-level programming, but I consider it unnecessary in higher-level programming because there's absolutely no need for it-it's not real indexing, but rather offsetting in memory. Higher-level languages don't go so low in memory access; the language handles these things for you, so you could use normal indexing that points directly to elements (1-based). It’s too bad that almost everyone copied 0-based indexing from the C language, so now it's considered the 'normal' thing for programmers.
@isodoubIet6 ай бұрын
@@jsonkody You didn't present any arguments either, calling your wrong preference "real indexing" doesn't really count. "But it's intuitive" that's the same wrong argument TJ made.
@JohnSmith-qy1wm6 ай бұрын
The colloquial, lay understanding of the word "index" is (and always has been) a list of things. You don't normally number a list starting at 0. That is what they meant by "intuitive," and what "indexing" means in any other context. I agree with them on that. Their argument is that lua's 1-based indexing is correct for high-level languages, while 0-based indexing is necessary for low-level indexing. That's their argument. It's not particularly difficult to discern.
@isodoubIet6 ай бұрын
@@JohnSmith-qy1wm "The colloquial, lay understanding of the word "index" is" Irrelevant, since we're talking about a technical term with a precise definition. This has zero to do with high level versus low-level. It's about the fundamental logic of programming and 0-indexing is just inherently superior regardless of what "level" one is programming at. As long as you're indexing into a list, you have to think about how many elements are in a (sub)list and in how to combine two lists. 0-indexing with half-open intervals is the _only_ convention where end-begin is the number of elements and where, if you split a list into two, the "begin" for the second sublist coincides with the "end" for the first sublist. It's why multidimensional arrays are so much better when zero-indexing, for example. We're talking an objective advantage in writing actual code, not whatever a bronze age peasant counting sheep would've considered intuitive.
@parityviolation9686 ай бұрын
@@isodoubIet I wouldn't exactly describe the math and science based POV as bronze age peasantry, which was brought up by jsonkody and ignored by you when dismissing his comment. But I wouldn't agree with his point completely, either. In theoretical physics zero-based indexing is convention for tensors involving spacetime ... to this day, I still cant figure out the rationale behind that convention. I doubt it's as based as it's been for programming, though. Probably just some banal reason like spatial dimensions already had 1,2,3, so in order to treat time differently physicists opted for 0 instead of 4. I hope I'm wrong^^
@biggerdoofus6 ай бұрын
As soon as he mentioned the c specification I paused to look it up. C99, c-11, and c-17 all refer to square brackets as subscripting operators, but also refer to the elements of an initializer list as being "indexed". Further, c-2x (since at least August 2022) has all that plus the explicit mention of 0-indexing in relation to bits in the stdbit.h section. Also _Lua_ stores the array portion of tables in an actual c array. ..Counter-ackshually-d.
@isodoubIet6 ай бұрын
This fake distinction between indices and subscripts was the most mind-meltingly stupid part of the video.
@ionarevamp6 ай бұрын
This is because array subscripting is a *form* of indexing. It doesn't mean that it is the only logical form of indexing, that's the whole point.
@delta32446 ай бұрын
@@ionarevampSubscripting doesn't have the inherent meaning of x[y] ⇔ (*(x + y)) anywhere except in C (edit: and any other languages which _choose to_ ascribe that meaning), so it's a pointless distinction either way. It's also an incorrect distinction, so focusing on it does naught but obscure whatever point was being made.
@ionarevamp6 ай бұрын
@@delta3244 Precedent and tradition ascribe a meaning regardless. I think if you failed to see a point, you either have no opinion on it or you weren't paying attention. In fact, I think you just stated the point but don't seem to believe that's actually what it was: 0-based indexing because of the specified array subscripting pointer math due to the specification in C is the only real reason 0-based indexing exists. If 1-based indexing occurred first, *that* would probably be seen as normal, but the sheer influential power and age of the C (and C-based) language(s)--to quote the video--"tricks us" into thinking that 0-based indexing is the correct way. It is implied that we really should just think about what is the most intuitive and elegant solution that empowers us to do more with fewer mistakes.
@delta32446 ай бұрын
@@ionarevamp It could be that the point of the example was to restate the point of the video without adding anything, as you assume it is. That point is easy to figure out: simply watch the rest of the video and ignore the example. If the example was meant to illustrate any finer/more specific point, it was lost in the glaring flaws of the example. I cannot say which is true, because the example was clearly meant to be insightful, but it merely _sounds_ insightful. If it _were_ insightful, it could communicate something more specific than the point of the video. It isn't insightful, and it cannot do so. It is clearly meant to be insightful, so for all I know, the speaker could be trying and failing to communicate something specific. Hence "whatever point was being made." (edit - grammer)
@dany_fg2 ай бұрын
I like to think of this as the line of non negative numbers (0+) that you start at 0 and every entry added is 1 unit away from the 0 position, so it's a relative position.
@abauchu6 ай бұрын
Those feels at the end... Thank you Prime for thinking with us about technical stuff, having fun while doing so, AND being a great human being. At least that's what I can see from your videos. Thanks for sharing your life's journey from time to time with us, and thanks for your sincerity, we need more of that on the internets
@rikschaaf6 ай бұрын
Can we just agree on this: - in languages that start arrays with 0, let's call it an offset (or subscript if you're fancy) - in languages that start arrays with 1, let's call it an index That way, both can coexist. It even allows for languages with both.
@Valerius1236 ай бұрын
Hmm.. I like this idea. Worth thinking about.
@xpusostomos6 ай бұрын
A proper language lets the programmer choose his indexes
@stefanalecu95326 ай бұрын
@@xpusostomosso... Pascal? Which has been doing this for 54 years and counting?
@xpusostomos6 ай бұрын
@@stefanalecu9532 I guess, I forget... Of course the right libraries in Java and C++ could pull it off too
@Asto5086 ай бұрын
@@xpusostomos You can always create your own array object and define/override the [] operator, so virtually every modern language allows this by default
@TomMcGuire6 ай бұрын
I started my programming with Lua, starting at 1 made so much sense to me starting out UNTIL I dealt with time. Hours are 0 - 23 so I constantly had an off by 1 error which flew under the radar for about 3 weeks until I started running everything together. Threw me through a loop and I really see both sides of the argument from this.
@ElesharVermillion5 ай бұрын
Because a clock measures an *offset* from the midnight. You don't really have "hour 0", you always have "hour 0 something". It's like the ruler measuring distance. All these are offsets, not indexes. But if you were to iterate over each hour, you would start by 1, meaning the hour *running* from 00:00 to 01:00.
@PasiFourmyle6 ай бұрын
Thank you for sharing your wisdom and motivating words! 👏👏👏
@epiphaeny6 ай бұрын
I was coding many years in Matlab (1-based index) and now programming in C++ (0-based, you know...). 1-based index feels indeed more natural for counting, but 0-based index is MUCH more convenient when you do modulo operations. With 1-based indices, you basically always convert your index to a 0-based index, do the modulo operation and than convert it back to a 1-based index. So annoying.... The counting "issue" with 0-based can be fixed relatively easy with ranged-base loops (or STL algorithms).
@bgdgdgdf44883 ай бұрын
I mean I think when you spent 10 seconds programming, 0 based feels perfectly natural to you
@josefjelinek6 ай бұрын
In "How JavaScript works" book Douglas Crockford introduced "zeroth", "wunth", "twoth", "threeth" as a clear indication and disambiguation of the indexing (does not help with fourth and on, but at that time it should be clear what is going on). He also did a survey and analysis of all known arguments for 0 vs 1 start index and it came out inconclusive in the end...
@Oler-yx7xj6 ай бұрын
But have you seen a language in which it's possible to have an array indexed -69..69? How can you not love Pascal
@rupen426 ай бұрын
Fortran too!
@EngineerErik6 ай бұрын
done that in Ada
@adissentingopinion8486 ай бұрын
Damn, VHDL and Systemverilog inherited the Pascal goodness. It's strucutred as type var(7 downto 0). Yeah, you can choose your endinaness in these godforsaken HDLs.
@josefjelinek6 ай бұрын
Ada handled that much better than Pascal IIRC, since in Ada you could for example define a stack allocated array with dynamic length, while Pascal had the range part of its type and very static... almost impossible to do anything more complex with those arrays alone. Even Go needs dynamic "slice" construct and its stack allocated arrays still cannot be dynamic length...
@__christopher__6 ай бұрын
@@josefjelinek Extended Pascal had that too. It's just that this standard got rarely implemented (the only implementation I'm aware of is GNU Pascal).
@daschewie6 ай бұрын
C introduced the 0-based indexing. Most languages prior to C, and in the Algol lineage used 1 based indexing: Ada, Pascal, ALGOL 68, APL, AWK, CFML, COBOL, Fortran, FoxPro, Julia, Lingo, Lua, Mathematica, MATLAB, PL/I, RPG, R, Ring, Sass, Smalltalk, Wolfram Language, and XPath/XQuery
@isodoubIet6 ай бұрын
Yeah and then most languages after C copied the C convention instead of the earlier "intuitive" one. Almost like it was _actually better_ or something.
@roadgeek1236 ай бұрын
Also RPG
@MartialBoniou6 ай бұрын
Exactly!
@AM-yk5yd6 ай бұрын
@@isodoubIet What's funny it's even makes sense in purely functional languages(think something like agda): just consider how you would implement getting a value from a list using Peano numbers. Most natural is "get-nth for 0 is the head of the list. For a successor of X, it's get-nth(X, tail)". In Peano numbers "one" doesn't even exists on its own (successor of 0 exist). When such system and C agree on something... Well, human intuition probably has serious skill issues.
@jongeduard6 ай бұрын
Fact. I have learned myself a bit of Fortran recently, just for fun, out of fascination. And I have also written Delphi Pascal and VB in my life. It's all either 1 based indexing or you can choose your own array bounds when declaring the array. But I think the C family languages made a good choice here. I really prefer the technical and mathematical correctness of the 0. 1 based counting is just nice for humans in daily life. Lua is a much younger language by the way, a lot newer than C for example, but it clearly choose to follow the old programming languages.
@AlwaysSunny-qu5zp6 ай бұрын
First element is at the address you have, the index is just used as offset, so you get the first element with offset 0. This is the root of why the first element exists at index 0. If we'd have called it 'offset', and you would dereference your array providing an offset, would you accept that providing offset 0 yields the start of the array, which is the first element?
@hoppy64376 ай бұрын
Offset isn't the same thing except at 0. Offset 1 isn't the second element of the array, that's at offset 1 * sizeof(element). Offsets are more natural to a computer, and indexes are more natural to a human. Offsets are going to be awkward anyway, why not make indexes more intuitive for programmers?
@jsonkody6 ай бұрын
yep, finaly someone. Offsets are better for computer but indexes for people. Higher level langs should have 1-based indexes. Lower level langs like C make perfect sense for offsets because they work with memory. Also there may be the case of using offsets AND indexes in same language - Rust has also higher level concepts next to low level stuff. It's still compiled so indexing could be transformed to offsetting when elements have same size.
@AlwaysSunny-qu5zp6 ай бұрын
@@hoppy6437 Where did I say that the offset must be one byte to get to the next element? And if I have a typed pointer, and increase it by 1, the pointer moves to the next element, because the size of the element is taken into consideration. Are you imagining a byte pointer to region of contiguous memory of otherwise typed elements that you increase by one, and then tell me that's wrong?
@AlwaysSunny-qu5zp6 ай бұрын
@@jsonkody If the language truly creates an array (contiguous memory), it is very likely that the index involves yielding some offset internally (or otherwise it just pretends to provide an array - but an array is usually chosen because of their advantageous contiguous layout). I can agree a 1-based index could be a viable choice, though we've also had issues with the difference between 0-based and 1-based systems and so I also feel some advantage if it's just always the same.
@meowrbius6 ай бұрын
Those who didn't watch the whole video, please don't skip the last 5 mins. It's the greatest life lesson from Prime ever. Clip that part and save it on your device. Everyone needs to remember that advice forever.
@filipenicoli_6 ай бұрын
As comp.sci people would say: "There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors." Coming from a hardware background, it's always worth remembering that 0x0 is a valid address. Also, when doing ASM, some architectures access data by referencing a base pointer with an offset (again, 0 is a valid offset). As C was conceived as some sort of portable assembly, it makes sense for C arrays to be 0-indexed. I believe there's no objectively good or bad approach as long as it has a consistent behaviour and doesn't suffer from performance penalties.
@henry_tsai6 ай бұрын
Except 1indexing suffers inconsistency as soon as you go out of bound. Like if you want to assess the last n item, or if you want to address things prior to first entry.
@Asto5086 ай бұрын
@@henry_tsaiWith 1 indexing, the last item on an n array, is literally array[n] and accessing elements outside the array is something that's pointless to begin with. If you're relying on hacks using this, you're doing it wrong.
@henry_tsai6 ай бұрын
@@Asto508 See, the last (1) item is array[n] in 1 indexing, instead of array[n-(1)] in 0 indexing. Or if you want to access the last third item, it would be array[n-(3-1)] instead of array[n-3], 0 indexing is more straigh forward. (python outright allow you to access the last nth item with array[-n].) Also, if you're describing something in real life with an array, like date, and later on you need to expand the span of interest, you would find the ability to address out of bound elements really valuable.
@mek101whatif76 ай бұрын
How does one end up working in hardware?
@filipenicoli_6 ай бұрын
@@mek101whatif7 You can try getting into FPGA or Electronics Engineering. What I meant was, based on my knowledge about hardware, 0-indexing makes sense, and it's not even because of memory availability.
@Ekitchi06 ай бұрын
As a French where the ground floor is floor 0 and the first floor up floor 1 and the first floor down is -1 it makes me smirk to hear Americans defend indexing starting at 0 ;p
@dwigtschrude3 ай бұрын
North America starts with a ground floor too
@unknownunknown57302 ай бұрын
@@dwigtschrude In the US the "ground floor" is typically called the "first floor"
@dwigtschrude2 ай бұрын
@@unknownunknown5730 weird because almost every elevator that floor has a G with a star next to it, instead of a 1
@nilsosinga4952 ай бұрын
This isn't entirely the same because in French, German, Dutch, we count "etages" (which are per definition NOT the ground floor). The 1st etage, is the first floor AFTER ground floor. In English, we count "floors" (which per definition DOES include the ground floor). So the 1st floor, is ground floor.
@parad0xheartАй бұрын
In the UK, the ground floor is the zeroth floor, and the first floor is the one above the ground floor. Unless there is a mezzanine, which I guess you could describe as real life off by one error.
@dami-i6 ай бұрын
function myArray(i) { return myArray[i-1]; } BOOM!
@pqnet846 ай бұрын
in C the third element of an array is not at a+2, it is between a+2 and a+3. The address point at the start of the object. x[n] refers to the object that is in the memory range between addresses x+n and x+n+1. Once you start giving addresses to the gaps between bytes and not to the bytes themselves everything makes a lot of sense.
@treidex6 ай бұрын
this ^
@dire_prism6 ай бұрын
In mathematics, even before computing, 0 based indexing for sequences has had a lot of use.
@ZombieLincoln6662 ай бұрын
and in physics and engineering. subscript 0 is always used for initial variables
@juliencortes26663 ай бұрын
Base 0 : I can speak your language machine, don't worry. Base 1 : Machine, speak my language please. Hypothesis : the smarter one is the one that succeeds to speak both languages.
@Hobbitstomper6 ай бұрын
In the late 90s, my teacher explained like this: "Don't think of indexing as regular counting. Think of the numbers used in indexing as symbols. Instead of numbers we could have used letters starting with A to Z and then AA to ZZ etc. just like in columns in spreadsheets. However since offset calculations need to be done under the hood to access specific parts of the array, the symbols A-Z would eventually need to be turned into numbers anyway. That is why it's more efficient to just use numbers in the first place. The reason we start with zero as a starting point is, because we want to use as many different symbols as possible using non-negative numbers, so we don't want to waste the symbol zero. Hence we start with the symbol zero. Historically this has its roots in memory addresses, where the lowest memory address also starts with zero, for the same reason, to use the lowest possible non-negative symbol. Because memory addresses already use zero-based indexing, it makes calculation of memory addresses and offsets more efficient if the array also starts with zero indexing. Additionally it aligns with mathematical concepts and simplifies certain algorithms and calculations." I always liked this way of thinking about it. It helps get over the confusion of thinking of indexes as regular counting.
@psyience32136 ай бұрын
i dk i mean it's not a symbol anymore than 1 represents the abstract idea of a singular thing. It seems like a way of thinking about it that is wrong, but i guess could still help you use it correctly? The symbol is the variable for the array you're using which represents to beginning of the block of memory, and the subscript/index represents how many of, the type that array holds, you're adding to the beginning of the block. Like if you have a ruler with 10 inches on it, if you wanted to access the first inch of the ruler you would start at 0 and go up to 1, you wouldn't start at 1, 1 is the start of the second inch.
@RandomGeometryDashStuff6 ай бұрын
I just think index as how many elements to skip
@gezenews6 ай бұрын
Yeah the problem with this discussion is you could make them different fruit loop flavors and I wouldn't give a shit. These things are iterated over and if you screw up I can't think of a more obvious place than in an array index.
@javierRC828576 ай бұрын
It was a Performance convention, ok. Any other reason it's wrong
@NickMak-m2c6 ай бұрын
It seems really dumb to me, whether I'm used to it or not. The fact that I always have to minus everything by one when I want it to equal the number of list items there are is unintuitive. I understand that the address in memory iterates over bytes or whatever (address 123 + 8 * 0 = 123, address 123 + 8 * 1 = 131, and so on...) and so the first address has to equal the actual number where the list starts if it's not a linked list (123 in this case), you don't need the interface to show that. Nothing else in the representation of the machine code is that close to the actual machine code, why should positions in an index? It should work like everything else does, first item, second item, third item, fourth item... And then in memory 123 + 32*0, 123 + 32*1, 123+32*2, 123+32*3
@skaruts6 ай бұрын
Two crucial mistakes in his reasoning: first, he confused indexing with counting, and second, he completely neglected to consider that indexing math only works with 0-indexing. People often make these two mistakes. Let me explain: An array of 10 elements will still have a *count* of 10 elements (10 loop iterations) regardless of whether it's indexed from 0 or 1. Indexing and counting are very different things. The "first element" is a count, not an index. Index 0 points at the first element. The only thing that guy got right was the statement _"that's what "indexes" do: they point at things"._ But then he failed to realize that "counts" don't point at things, and are not the same thing as "indices" (the plural is "indices", not "indexes"). This mistake nullifies almost every argument he makes, because they're based on this premise that he got wrong. And what programmer doesn't think about indexing math? Indexing math (converting an index to X and Y coordinates and vice-versa) is what you use to access an element in a 1D array that represents for example a tile in a 2D grid of tiles for an RPG, or a voxel in a 3D chunk, or a cell in a 2D text buffer, or a quad slot in a data structure for sprite batching, etc, etc. Indexing math dictates that, even if your language is 1-indexed, many of your arrays *have to* be indexed from 0, or else the math won't work. In practice, you can have every array indexed from 0, but you can't possibly have every array indexed from 1 (which causes some problems in 1-indexed languages). And man... that "index finger" argument is just absolute nonsense. It sounds like a desperate attempt at having one more flimsy argument. Speaking from experience, though: I love Lua like no other language. But it's because I've been using it for some 5 years that I can say that 1-indexing is a perpetual rock in the shoe. It's not a deal breaker because Lua is otherwise an excellent language, but it only brings problems, error proneness and traps: - it expects loops to go from 1 to limit (inclusive), and so whenever you need 0 to limit-1, you have to not forget the explicit -1. This requires some extra attention to what you're doing, lest you forget it. - you need to be extra careful about using certain language tools, like *_ipairs, #_* or *_table.insert()_*, because they won't work with 0-indexing. - the language creates 1-indexed arrays by default, and you can't run away from it. This makes your code inconsistent, such that you have to pay extra attention to not get your index variables off by 1, or if you're using them across multiple arrays with different indexing, etc. - utility functions that deal with arrays are harder to make/debug, because you never know what users will throw in them, so you have to account for 0 and 1 base. Or if you don't account for that, then your functions won't work for every use case where they'd be needed. - you'll perpetually have to be considering when to let the language have it's way with arrays and when not to. And sometimes you'll get it wrong and have to waste time re-writing some code. - it's harder to port code to and from 1-indexed languages because you'll have to be extra careful to not break the algorithm you're porting by allowing 1-indexed arrays in it. And then if the algorithm doesn't work, you'll have extra stuff to double-check with extra attention. There's just no world where 1-indexing is the sane option.
@Yupppi6 ай бұрын
You know what's crazy? When talking about physics, we have so many things starting at x=0 when we make graphs out of data or phenomenon. So our first point is always at 0.
@xennial74085 ай бұрын
Yes. 0 is where we are, so it's actually wrong to call an array index an index. The first block in memory is 0 steps away from the array start. Yes, that's programmer thinking and yes, you should have that thinking when programming. However, high level programming languages, that do not require memory / pointer operations, it's more non-tech human readable.
@M_10246 ай бұрын
Hours start at 0. We have 0:00, not 1:01. We can interpret 0:30 as "since midnight, 0 hours and 30 minutes have passed", but what would 1:31 mean? But centries start at 1. And it only brings problems. Year 00XX is ceuntry 1, year 01XX is ceuntry 2 and year 20XX is ceuntry 21. Years also start at 1, and it also brings problems. Year 1 b.c. is year 0, year 2 b.c. is year -1, year 3 b.c. is year -2. Starting at zero also makes it easy to do unit conversion. 1 inch = 2.54 cm therefore 10 inches = 25.4 cm. This only works because 0 inches = 0 cm. But degrees start at -273 C or -459 F. And this again brings problems: if 0 C = 32 F then multiplying both sides by 2 gives 0 C = 64 F. Binary numbers in computers also start at 0. uint8 covers integers 0-255. So if we started indexing arrays from 1, we would get a smaller range 1-255 and 0 would be wasted.
@beepbop66976 ай бұрын
All true, but the range would be [1-256] instead of the original [0-255], not your [1-255]. You still have 256 positions regardless of where you start your index counting.
@M_10246 ай бұрын
@@beepbop6697 True, but you would need a different format (that's why I said "uint8" instead of "8 bit number")
@cheerpoasting2 ай бұрын
no, we actually start at 12. 12:30 is 30 minutes since midnight.
@M_10242 ай бұрын
@@cheerpoasting I am counting the 24 hour format, because 12 hour format has inconsistencies
@James_D_Bartlett_III6 ай бұрын
Man, that took a hard left turn from a purely technical talk to passionate advocacy for self-care and spending quality time with your loved ones... And I am 100% here for it. Zero notes.
@upsidedownChad6 ай бұрын
Yooooooooo that Brazilian shirt is fire 🔥🇧🇷
@nyahhbinghi6 ай бұрын
it is :)
@bjbboy716976 ай бұрын
Prime: "For those that don't use neovim..." Also Prime: "That's odd, because the people who said they use neovim didn't raise their hand".
@DarkerStarSword6 ай бұрын
Easy solution, just declare a map like this and use it to convert English to indices: {"first": 0, "second": 1, "third": 2, "fourth": 3, ...}
@therainman77775 ай бұрын
And ~double the syntax needed every time you need to index into a collection for any purpose?
@DarkerStarSword5 ай бұрын
@@therainman7777 Did the sarcasm really escape you?
@jordanhildebrandt37052 ай бұрын
This is nightmare fuel 🤣
@TheSoulCrisis6 ай бұрын
Damn Prime damn near brought me to tears with the ending segment.....powerful and touching to every human on the planet real talk! Great job Prime......THANK YOU for being so genuine, cool, funny, and authentic in keeping in touch with the important things!! ❣
@OhMyShad4 ай бұрын
Man! The final quick speech was something else, it went beyond work, skills, salary and bring us to the essence of why we push ourselves into this complex field! Being excellent but losing yourself in the long run is actually loss. Always keep in mind the people around you ❤
@mgmchenry6 ай бұрын
I simply love lua. I've got decades with C# and Java. Before that, C and C++, but my first love was Pascal. I've spent time interfacing with lua from x64 ASM and being able to be comfortable in an interpreted language while in a debugger is amazing. Lua integrates with c so well. I have wasted so much time working around the 1 based index standard. Almost every algorithm just works with a zero base, but I have to slow down constantly and make sure I haven't messed it up. I still love lua but i don't know why this choice was made
@robmorgan12146 ай бұрын
Count and index are different integer types... however, I'm a physicist. we invented the concept of potential... when you are forced to do calculus for a semester on your pointers before you even get to take the math classes that cover the prerequisite concepts I'll sympathize with this perspective. I wake up every day of my life off by one and bump into everything until the coffee and training kicks in.😂 Oh...and BTW iterators are the devil. Historical note: for several algorithms in memory limited numerical computations, it is sometimes significantly more efficient and faster to do computations in the address space rather than on the data itself hence we retain the choice of zero based indexing for these purposes. Symmetry about a zero index becomes an important mathematical property here.
@dasdos0026 ай бұрын
In physics, the “initial value” is indexed with 0 not 1. We say, “x naught” (x_0 or x[0]) because that’s where we START. It’s an indexing convention NOT a counting convention. TJ’s points about indexing and counting are moot point.
@Exilum6 ай бұрын
That end speech should've been an entire video. Got me real emotional. Those people that skipped the end really missed something.
@ebmpinyuri6 ай бұрын
It's actually the best part arguably
@Exilum6 ай бұрын
@@ebmpinyuri I think it's definitely worth having its own video. The thing is a lot of people skipped without knowing that, because when it reached the end of the react and he started talking about something else they just clicked on the next video, unaware of what was to come.
@abenezerteshome5206 ай бұрын
@@Exilum @Exilum I even recorded that portion from the live stream , it's very impotant life lesson for a programmer
@tedlava6 ай бұрын
When a baby is newly born, we don't start counting their age as being 1 year old immediately when they come out of the womb. All the age counters for every unit of time start at ZERO intuitively!! A recently born baby would be something like 0 years, 0 months, 0 weeks, and maybe 3 days old... However, it's common in human languages to omit saying the units that are currently zero, but they are still there and we all know mathematically that they are there.
@lucassatie6 ай бұрын
Except some cultures do start counting age at 1 from the moment of birth. Which I think is the problem: it's all about subjective perception. When I reference an element in an array, I prefer to reference it by its cardinal position so I prefer indexing at 1(e.g. "the first element"). But if you prefer thinking about it as an offset, then it makes more sense to start at 0 (e.g. "count of elements beyond the starting point").
@sillymesilly6 ай бұрын
@@lucassatiedont care. Most countries start from 0. Because before you move the distance you start with is 0. It is not subjective, the baby did live for one year outside of the womb. A man standing did not travel 1 of any distance by standing.
@TPF00T6 ай бұрын
@@lucassatie The countries that start counting at 1 do so because they are counting the baby's age from conception. Presumably, they didn't know that it was exactly 9 months or they decided to simplify it. Keep in mind these countries also have their entire population get 1 year older every New Year, so they aren't exactly counting it mathematically anyway. It's just formality.
@lucassatie5 ай бұрын
@@sillymesilly dont care. You're explaining what an offset is which I already said makes sense to start at zero. A man standing did not travel 1 of any distance, but a man at the head of a queue is not 0th in line. Offset != position.
@cheerpoasting2 ай бұрын
Most of Asia starts as 1 and you turn 2 on new years
@gregdawe27864 ай бұрын
We need to protect you at all cost. Like Prime , you just seem like such a good dude. I know you've made mistakes but as you point out in this video, thats what makes you better. Youve taught me so much and made me better AND provided lots of entertainment. Thank you for being THE PRIMEAGEN ♥️
@atomicman0076 ай бұрын
I had a class on this in college 2 semesters ago. This addition-asterisk-address magic actually makes sense (it's not magic, I get it) and it blew my mind that a[i] is same as a + i. One more thing was blown away recently, my eardrums while watching this video. Cheers
@Saiphes6 ай бұрын
If you start counting seconds, and you go "1, 2, 3" and stop, you'll have counted 2 seconds. My son counts from 0 (where it is) for knight chess moves too.
@brandongregori9956 ай бұрын
That's why people count Mississippis. It makes no sense to stop at just 3 without the Mississippi part
@brandongregori9956 ай бұрын
Also cadence as well. But it's a benefit when using a cadence to counting the current number of seconds
@Thurrak6 ай бұрын
That's only assuming that 0 has to be said to be considered. You could easily assume that you were counting from 0 but didn't say it because it's irrelevant to the purpose of what you are trying to do. When you say 5 you don't say 5.00 or 005 because the 0's are irrelevant.
@brentlio55786 ай бұрын
Depends on where people think every number system starts. The starting of a timing system is 0. The starting of a counting system is also 0. The start of referencing system is going to be 1. Because if the size of a referencing system is zero, then there is nothing to reference to, whereas timing and counting can have a size of 0 if it hasn't started or progressed enough for their first cycle.
@ValentineOficial6 ай бұрын
If you're counting seconds, it's easier to count downwards (3, 2, 1, 0) because you'll intuitively include zero as the stopping point
@kjdavid6 ай бұрын
How old were you when you were just born? 1 year old? No. 1 month old? No. 1 day old? No. But you are in your first year, first month, first day. That is how I interpret this 0 indexing vs the first element.
@milanstevic84246 ай бұрын
This is the correct analysis. Yes you can say that you're in your first day, decade, heck even your first life, this is because your index is below the limit. Counting actually works like this: 9 belongs to a first grouping of ten, while 10 belongs to a second grouping of ten, which by extension means that 0 belongs to a first grouping of ten. This indicates that 0 should be the natural start for counting, it's just skipped because we humans are sloppy. Here's another argument for our sloppiness, let's say we count all the numbers that belong to a second grouping of hundred. There are a hundred of them going from 100 .. 199, so there are exactly one hundred natural numbers in this set. However in the first grouping of hundred, there are only 99 natural numbers, because 0 is excluded. Makes very little sense. We also do this for the millennium counting which is sad, because years stubbornly begin at 1 AD, year 2000 is included in the 2nd millennium. But check this out: the "80's decade" is officially set to be the interval between January 1, 1980, and December 31, 1989. That means that the 90's began at Jan 1, 1990 and ended in Dec 31, 1999, HOWEVER the 21st century began on Jan 1 2001. This makes VERY little sense. We are sloppy to the bone.
@spacelem6 ай бұрын
@@milanstevic8424 "This indicates that 0 should be the natural start for counting." It is though. If there are 0 things, we say there are 0. If there's 1, we say there's 1. When we have 1 thing, that is the 1st thing. If all the things line up in a row, the first thing in in position 1. There is no position 0, because says there are 0 things (e.g. a race is yet to be completed). There's nothing sloppy about it. In other words, you can absolutely count 0 things, but you can't give the position of a 0th thing, because there isn't a thing to assign a position to. As for dates... the interesting thing about 2000 was all the digits changing. 2000->2001 was a regular single digit change, which was boring. 80s are any date matching xx8x, this millennium is any date starting with a 2. We didn't call year 1 year 1 until years later anyway. Plus if you switch to the Holocene calendar, we account for an additional 10 millennia of human history, and this is the year 12,024, and before the year 10,001 (1 CE) was 10,000 (1 BCE). It's all approximate and arbitrary, so just enjoy the digits.
@porky11186 ай бұрын
@@milanstevic8424 I think it comes down to the distinction of ordinal and cardinal numbers. Ordinal numbers (first, second, basically indices) should start with zero. The offset from the start. Cardinal numbers (1, 2, 3, basically counts/quantities) should also start with zero. But zero in this case means no elements. An array of length 0 doesn't have an element 0. And ranges should be inclusive at the start and exclusive at the end. And these should probably be different types, too.
@milanstevic84246 ай бұрын
@@porky1118 Here's a trick question: if we know that the year 2000 belongs to the 20th century, to which decade of which century it belongs? It can't belong to the first decade of the 21st century (2000-2009), because it doesn't belong to the 21st century by definition. It can't belong to the last decade of the 20th century, because the 90s run from Jan 1st 1990 to Dec 31st 1999. Such a conundrum.
@porky11186 ай бұрын
@@milanstevic8424 What's tricky about that? It obviously belongs to the 21st century (1-based). If there is a definition which doesn't put the year 2000 into the 21th century, it's just not such a good definition.
@ytdlgandalf6 ай бұрын
My daughter knew very well at age 2 that when were doing a count down, shit happens at 0, not 1, so debunked.
@cleptos9726 ай бұрын
You are such an inspirational person! Especially the end. Thank you!
@loian72 ай бұрын
1 second in and I already love this video, BRASIIIIIIIL KARALHO!!!
@asaad10226 ай бұрын
When you enter a building and go up, do you start from the ground floor or the first floor?
@SandraWantsCoke6 ай бұрын
I live in a basement
@kirkanos7716 ай бұрын
the ground floor, because in Europe we dont count floors, but stages. It's a NA perception i guess. But like imperial units, everything from NA is dubious.
@iraniansuperhacker43826 ай бұрын
@@kirkanos771 its Europes fault really. All the retards you guys kicked out had no where else to go so they came to America. Compound that over 300 years or so and you got stuff like the imperial system
@kirkanos7716 ай бұрын
@thetukars The second one. 0 is the engine. xD
@shaggygoat6 ай бұрын
Americans count floors starting at 1 at ground-level but British count floors starting at 1 one storey above ground, which used to be just dirt and indoor farm animals. (The British system would fit nicely with −1 being the first floor underground.)
@Ninakoru6 ай бұрын
If you think of it in a continued way (a simple ruler), makes sense, you start at 0, and at 1 you start with the next. The zero-based index always made sense for me, the only time I feel lightly challenged mentally is accessing a position of a string.
@Pyrosublime6 ай бұрын
true but when using a rule to mark lines for saw cuts for example 0 is at the edge of the time not the first marking point, in your case you would need a rule that starts at -1 so you can mark 0 as the first measure. Essentially its about how each person sees it and wants to use the scale and what makes sense to them. Looking at a 48 port network switch that starts at port 0 is trippy and having to explain to a trainee or management the documentation of why its port 0 and not port 1 is very challenging.
@mskiptr6 ай бұрын
@@Pyrosublime I have the exact opposite experience. It's so confusing whenever stuff is numbered from 1 and swaps to the next column | row | page at 11, 21, 31 and so on
@DF-wl8nj6 ай бұрын
@@Pyrosublime It shouldn't be challenging at all. "Why does it start at 0?" "Because that's how the company made it". Conversation over.
@thomasslone19646 ай бұрын
i think the concept is that the first item of the array should be the most often access item and with 0 in many script languages you can just not pass a value so it becomes nil which is treated as zero, also 0 is a number why not use it and have one more value for the maximum possible array size
@xpusostomos6 ай бұрын
0 index is easy to think about the first position, but hard to think about the last character (n-1)
@spectrecular97216 ай бұрын
RAM traditionally works in 0's and 1's to indicate whether or not voltage exists. I always just figured the concept of 0-based indexing originally stemmed from this, because 0 would indicate the first of two existing options and is the default when there is no power
@-Kal-6 ай бұрын
Exactly! I got into programming with electronics and microcontrollers. 0 is the obvious number to count from in hardware. I do mostly high level stuff now. Maybe if I got started with high level I would think differently, but when I try to 'think like a computer' I start counting from 0 and 1 based indexing is annoying af. Thinking of the 0 as an offset is probably the best way to go about it.
@danielbrockman12216 ай бұрын
The end made me cry ❤
@ThePrimeTimeagen6 ай бұрын
:) thank you. i felt every word myself :)
@grimfang46 ай бұрын
In math and physics, we often use a subscript of 0 (naught/nought) to denote the starting value of a property. You'll find lots of summations and integrals written starting at 0. There's no problem with this, as we don't throw around weird arguments about the concept of 0 being unintuitive thousands of years ago when it is very intuitive now. When you start a timer, it starts at 0 seconds, not 1 second. Concepts of time weren't intuitive in all cultures in the past, but we're past that now, right?
@joseoncrack6 ай бұрын
Absolutely. As a corollary of your remark, having a problem with 0-based indexing usually comes from a lack of math education, which IMHO is a big problem for any decent developer. Math is, and should remain the basis of programming. Developers who do not master enough of math can't be good developers. Programming language-wise, though, this holds true, except that I consider that a good programming language *should* allow flexible indexing from a defined range, not necessarily beginning at 0 or 1. Ada allows that, of course.
@awesomedavid20126 ай бұрын
The problem is, he criticizes us for not liking 1-based indexing because it isn't familiar to us. Then he argues that 0 based indexing is bad because it isn't familiar to how we talk about ordinal numbers.
@FlyingOctopus06 ай бұрын
By writing "-1" when you index, you can use 0 based indexing lika a 1 based indexing. Like this arr[3-1].
@therainman77775 ай бұрын
lol did you really just share this as an insight? 😂 Sorry, not trying to be a jerk but it’s just kind of funny
@nolanfaught69746 ай бұрын
In mathematics, it's possible use any partially ordered set as an index. With this in mind, it's clear that the superior option is to index arrays using the space of Lesbesgue-measurable functions. Anyone espousing the value of integer-based indexing is clearly unable to appreciate the beauty of being able to index uncountably many things and is categorically wrong in every conceivable way
@drdca82636 ай бұрын
What’s the poset you are defining on measurable functions?
@nolanfaught69746 ай бұрын
@@drdca8263 ordered using the L2 norm over a subset of R^n
@РайанКупер-э4о2 ай бұрын
Zero-start counting makes sense when we talking about shifting from some starting position. But in most cases when we use arrays 1-start indexing just makes more sense. I think it should not be a choice of language creator. It should be a choice of programmer. I remember when I had just started learning to code in my first language, Basic, I could use any integer as starting index. I think it makes far more sense. It's question of interface, not question of implementation, and interface should me chosen by someone who gonna use it, not by someone who provides it. I think it's something from SOLID principles, am I wrong?
@Blaisem4 ай бұрын
The main checkmate here is that Teej comes up with a bunch of reasons for 1-based indexing, and the only argument to remain with 0-based indexing is "just because we always did it that way."
@pweddy16 ай бұрын
The notion that he is advocating for data not being stored contiguously means he wants to get cache misses as he reads enumerated data.
@aoeu2566 ай бұрын
Will computers in the future have the same kind of caches and centralized memory like von-neumann's 1945 model? I think we are going to go for a more "networked" model where cpus and memory are joined together in a network like in a cellular automata...
@Forty8-Forty5-Fifty86 ай бұрын
@@aoeu256 I was under the impression that von Neumann architecture has been the status quo since forever? What problem would this hypothetical networked model solve that cloud computing doesn't already do? It sounds like it would be an expensive to develop model that would not financially benefit the companies who are supposed to design it.
@NickMak-m2c6 ай бұрын
No he is arguing for the representation of it, how much of what you program input into the machine level is what you entered? Unless your IDE is full of "001001110010100011101000110100" I'm going to guess very little. It's a matter of translating human-sense to machine-sense, and it is not really at all helpful for the human, in a high-level programming language, to remember the bytes are incrementing via multiplication with the index number.
@GoddamnAxl6 ай бұрын
The man is turning reaction videos into live performance art… what an innovation 🤯
@lookingforluck6 ай бұрын
live reactions is wicked work
@aeronwolfe70726 ай бұрын
23:00 brother. THANK YOU for saying this stuff. Man, I freaking LOVE this guy. Thank you for everything you do man..... :)
@themetadaemon5 ай бұрын
He's right. 1-based indexing is not only more natural, but it opens up the opportunity to store the count of items in the array at position 0. The perfect implementation.
@xpusostomos6 ай бұрын
A good programming language will never make you think about indexes, but when you insist on it, you choose the indexing, bottom and top value.
@IdeaToGame6 ай бұрын
yo Brazil mentioned!!! suddenly caralho
@dabbopabblo6 ай бұрын
The moment I realized he was doing a live reaction to a video during a talk I died laughing, this is way too meta😂😂☠
@JasonDoege6 ай бұрын
@17:07 0 is the right way because significant parts of CS require it. Assembly and other low level languages can not escape 0-based indexing because they refer to memory directly. It is only with significant abstraction that 1-based indexing is possible. So now we are going to have a field where one of the most fundamental concepts has two incompatible definitions? I'm sure this guy Teej is certifiably smart but he is either intentionally eliding vast swaths of his knowledge and this is just meant to be ironically entertaining or he has developed a huge blind spot in his thinking while constructing this argument.
@berekyLog6 ай бұрын
Man this is such a great video. TBH I got so emotional on the last minutes. Such a great advice I heard in a long time. Thanks!
@RenderingUser6 ай бұрын
TJ the type of guy to say he's 6ft when hes actually 5 cause he like to start from 1
@jongeduard6 ай бұрын
Or just take the elevator, which is like an iterator. It brings you to the right floor without having to walk every step yourself.
@billeterk6 ай бұрын
But you need to know which number to press
@jongeduard6 ай бұрын
@@billeterk Yeah, iterator analogy kind of stops there indeed. :P
@Becoming-Human6 ай бұрын
In my opinion, one of the strongest arguments for 1 based indexing, at least in Python, would be the following logic, "In Python, if negative indexing starts at -1, then why _wouldn't_ positive indexing start at 1?"
@shaggygoat6 ай бұрын
But Python negative indices aren’t able to address the end of the array so the last three single-element slices of array A would ideally by A[-3:-1], A[-2:-1], A[-1:0] but as zero is interpreted to mean the beginning of the array (so that the first single-element slice is A[0:1]), A[-1:0] has to be replaced with A[-1, len(A)] or A[len(A)-1, len(A)]. (Just as graphics coordinates typically address pixel edges instead of pixel centres, Python and C address element and slice boundaries.)
@Starwort6 ай бұрын
Negative indexing actually starts at ~0 Also, adding one to a negative index gives you the next number in the sequence (wrapping around the end if necessary) - why should there be a hole in the valid indices at 0
@porky11186 ай бұрын
I could answer the question: The simplest way to implement negative indexing would be this: value = array[mod(index, array.length)] If you implement it like this, the first element wold still be 0, and the last element (using negative indices) would be -1, just like it usually is now. So that's why negative indexing starting with -1 is rather an argument for positive indexing starting with 0.
@titfortat44056 ай бұрын
This is actually a reason to start non-negative indexing at 0 if you think about how modular arithmetic works and how arr[-1] gives you the value arr[length-1]. But that's not just my opinion, that's the reasoning behind the python syntax/semantics.
@wojciechbojewski94426 ай бұрын
0-indexing is right for C, and optional for other languages (base of the legend of C - php, python and others). You don't teach kids counting from 0, as well as you don't teach a kid's poinmter's arithmetic in C.
@thomasmaughan47986 ай бұрын
"You don't teach kids counting from 0" This becomes a challenge when you introduce the zero as the fulcrum of a number line. Now suddenly "1" is not the first number; in fact, on a number line there is no first number.
@bgdgdgdf44883 ай бұрын
Maybe we should teach counting from zero. I mean when you start counting with one, you actually count 1 second too much. Because when you start saying "one", zero seconds have passed.
@sercan97916 ай бұрын
As someone who has fucked up in life and now is trying his hardest, I really appreciate you man. Knowing that you also made a bunch of mistakes before getting where you are gives me hope for my own future.
@RogerValor6 ай бұрын
My first language after basic was pascal, and it had 1-based string indexes, so most of the time you would define arrays as 1-based as well array[1..100] of integer it took me a long time to learn 0-based indexes, or the fact range() returns length-1 as maximum. for the for loop the only difference is, whether you use < or
@orthoplex646 ай бұрын
Subscript vs index is a distinction without a difference. EVERY realistic time that you need to do some amount of arithmetic to compute an index, 0-based requires no additional math, and 1-based requires subtracting 1 at the beginning and/or adding 1 at the end of the formula. The preference is not baseless dogma. Lay intuition and ease of accessing last element are the only benefits of 1-based indexing, and they're not much. In real world code, the times you need to specifically access the last element are few and far between, and programmers usually quickly develop a separate 0-based intuition.
@user-cx5jj2yv3p6 ай бұрын
Gigachad ending
@sk-sm9sh6 ай бұрын
No because sometimes you just don't want to iterate the array in sequential order you want to build your own order of iteration. For instance maybe you have 2d matrix and you are iterating in a spiral that starts at center.
@softwaretechnologyengineering6 ай бұрын
No Hood. Unsubscribed.
@TheAgentAPM6 ай бұрын
Music intervals are 1-indexed and it's infuriating how the 3rd of 3rd is the 5th.
@kanyangokariuki37922 сағат бұрын
That last bit, turned from robot to human. Thank you Prime
@thunder____6 ай бұрын
The way I've always conceptualized it (even before learning C, but learning C has only reinforced this) is that the index doesn't point to the data itself, it points to the space before the data. As anyone who knows C knows, the index is the number of elements to be skipped over to get to the memory address of the one you want. This also explains why things like string slices are non-inclusive; when I was first learning PHP, I was confused about why something like $string[0:5] wouldn't include the 6th character in $string when that character exists at index 5, but when I started thinking of it existing AFTER index 5, it immediately made total sense. It was a little bit of a learning curve, but with the thought process of looking at an index as the space between elements, I find it very easy and I don't even want to consider using a language like Lua, even if it has the endorsement of John Romero, someone I greatly admire.
@defenestrated236 ай бұрын
A great argument for 0-offset notation is languages that allow indexing from the end, like Python. What's the obvious index of the very last element? -1. If you 0-index, the absolute offset is just (length + index). If you have ten things, the last thing is at -1, 10-1=9, array[9]. How do you make this intuitive for 1-indexing? You can't use 0 for the last element, that's insanity, and -2 is the wrong direction, so it's still -1. Now the math is 10-1+1 = 10, 10-2+1 = 9, etc. You are adding 1 just to make up for the implicit -1 from starting at 1.
@jordsRSAint6 ай бұрын
I like Prime more and more each video. Solid vibes from his authenticity ❤
@phillipjoyce88256 ай бұрын
A good practical example is age, 0 is your first year. Age points at the end of your year not the start A technical example is rendering textured polygons. The top left corner of your map is 0,0. If you're saying "get me that first texel" then you need to sample from texel (0.5,0.5) or else your sample is filtered with its neighbours. 0 points to the start of each item. 1 points to the end. If you want unambiguously the first item that's 0.5
@wtrflsh6 ай бұрын
We start at 1 in our uni's pseudocode. Had multiple calculation issues because the range was always offset the first time. The advantage of 0 is it has no effect in algebra. You can do checks that - if the pointer is not moved(i.e. pointer value has no effect), it should still be at the start.
@bryonnoel42546 ай бұрын
In 95% of the situations I've faced programming the indexing scheme is irrelevant. Many programming languages allow the programmer to be are agnostic to this. In times where I cared about it I never used or wanted zero as an index but my indexes could be 100-500 or a-z. Which is more like a dictionary. The major point being that the programming language is an interface between what the programmer wants to do and how the code is compiled. In extremely rare cases that the memory needs to be accessed manually, the programming language still interfaces for the programmer. Forcing a zero index is a major limitation, and this may be how it works under the hood, but it's not an effective interface to human language.
@JoeJoeTater6 ай бұрын
So, I learned a lot of math before I got into coding. In math, you just explicitly say what your starting index is each time, because sometimes it's more convenient to start at -1, 0, 1, 2, whatever. (In more advanced notations, like Einstein index notation, you don't even say what your starting/ending indices are. You work with placeholder indicies that each imply a loop over the entire range.) So, I think there's a lot of merit to the variable-first-index thing. I've written a lot of R, which is 1-based. Honestly, I ran into fewer off-by-one errors in R. Though, I think a lot of that is due to how R allows you to avoid using loops and explicit indices through vectorization. I think that's the real takeaway. Whether it's through vectorization, iterators, or whatever else, avoiding explicit loops is a good idea.
@NerdBotatous2 ай бұрын
10:09 actually, it depends on culture
@stevenpike78575 ай бұрын
Zero index is because of the binary nature of the computer. If it's 8 bits, for example, you start the position with all switches off: 0000 0000, and then increment by one: 0000 0001, 0000 0010, 0000 0011.... and so on. Moresoe, if you are accessing an array in memory, and it's starts at memory address 1001 0110, you simply add the index number to get your location of the data. First position is at 0000 0000. Want the second one? -- add the index 0000 0001 to the address to get it.
@randyriegel85536 ай бұрын
As a developer 0 based indexes are awesome. "foreach" helps with this. I can't remember last time I made an actual Array. Instead of an array in C# I use "List" or "List", "List", etc. And can manipulate them more than array.