← Back to context

Comment by Ygg2

4 months ago

I don't think so. One based numbering is barring few particular (spoken) languages the default. You have to had to change your counting strategies when going from regular world to 0 based indices.

Maybe you had the luck of learning 0 based language first. Then most of them were a smooth ride.

My point is you forgot how hard it is because it's now muscle memory (if you need a recap of the difficulty learn a program with arbitrary array indexing and set you first array index to something exciting like 5 or -6). It also means if you are "fighting the borrow checker" you are still at pre-"muscle memory" stage of learning Rust.

> Maybe you had the luck of learning 0 based language first. Then most of them were a smooth ride.

Given most languages since at least C have 0-based indexing... I would think most engineers picked it up early? I recall reading The C Programming Language 20 years ago, reading the reason and just following what it says. I don't think it's as complex as the descriptions people put forward of "fighting the borrow checker." One is "mentally add/subtract 1" and another is "gain a deep understanding of how memory management works in Rust." I know which one I'm going to find more challenging when I get round to trying to learn Rust...

  • > Given most languages since at least C have 0-based indexing.

    As I mentioned I started Basic on C64, and schools curriculum was in Pascal. I didn't learn about C until I got to college.

    > One is "mentally add/subtract 1" and another is "gain a deep understanding of how memory management works in Rust."

    In practice they are, you start writing code. At first you trip on your feet, read stuff carefully, then try again until you succeed.

    Then one day, you wake up and realize I know 0 indices and/or borrow checker. You don't know how you know, you just know you don't make those mistakes anymore.

    • I was Basic (on C64) -> assembly -> Pascal -> C, more or less. 0-based indexing wasn't too bad for me, except when it came to for loops.

          for (i=0; i<length; i++)
      

      I eventually just memorized that pattern, but stumbled every time any part of it changed. I had to rethink the whole logic every time to figure out < vs <= and length vs length-1, and usually ended up getting an answer that was both confident and wrong.

      The borrow checks feels similar but different. It feels like it has more "levels" to it. Initially, it came naturally to me and I wondered what all the fuss was about. I was fighting iterators and into, not the borrow checker. I just had to mentally keep track of what owned my data and it all felt pretty obvious.

      Then I started working on things that didn't fit into my naive mental model, and it became a constant fight.

      So overall, a similar experience to 0-based indexing, yes. (Except I still don't "just know" the trickier bits of the borrow checker yet, so I don't know what comes next.)

    • I literally just described my process, so I don’t get how you got to “you don’t know how you know” because… well… I just told you.

      Also, there’s a huge difference between beginners not understanding 0-based indexing and experienced C++ engineers describing the challenges understanding Rust’s unique features. I mean, Jesus Christ, we’re commenting on a thread here of experienced engineers commenting on how challenging it can be! I really don’t know what else to say.

      6 replies →