The world if every programming language indexed starting at 1.

The world if every programming language indexed starting at 1.

POSIWID: The Purpose Of A System Is What It Does Shirt $21.68

The Kind of Tired That Sleep Won’t Fix Shirt $21.68

POSIWID: The Purpose Of A System Is What It Does Shirt $21.68

  1. 1 month ago
    Anonymous

    Nope. 0 needs to be accounted for. This proposal you're suggesting is like saying the binary equivalent of 0000 0000 0000 0000 should equal 1.

    • 1 month ago
      Anonymous

      2^0 = 1

  2. 1 month ago
    Anonymous

    Tell me you don't know assembly without telling me you don't know assembly

    • 1 month ago
      Anonymous

      This would include assembly

      • 1 month ago
        Anonymous

        see

        the index is the offset of an element from the starting address of the array

        • 1 month ago
          Anonymous

          The assembler can subtract 1

          • 1 month ago
            Anonymous

            the assembler can subtract 1 from a runtime expression at compile time?
            you are an idiot. shut your b***h ass mouth up when discussing things you do not understand. a fricking React dev works with more complicated constructs than you.

          • 1 month ago
            Anonymous

            what are you even talking about
            if something happens at runtime, you can program it to happen differently at runtime.

    • 1 month ago
      Anonymous

      you can add / subtract immediate values from addresses stored in registers
      this has been a feature of x86 processors since x86 was a thing and even Intel 8086 supported this style of addressing
      all 1-based indices would mean on an assembly level is additional "- 1" appearing in memory operands

      • 1 month ago
        Anonymous

        Yes. That adds another cycle to all memory operations.

        • 1 month ago
          Anonymous

          Do you know this for sure? I've read an AMD manual where certain idioms (such as xor r64,r64) were described to be 0-cycle operations under some circumstances so it wouldn't surprise me if subtracting 1 from an address didn't even matter to a modern CPU.
          FWIW, according to https://uops.info/table.html all forms of Zen 3 mov are pretty much the same.

          >If your indices start with 1, none of this matters because both the length of the array and the index of its last element are the same number.
          If your indicies start with 0 none of this matters, either.

          Computing the index of left and right binary heap is objectively easier when your indices start at 1. On the other hand, counting sort gets fricking stupid unless you start at 0. If you don't see the value of having the last index and array length be the same thing, that's fine. I'm just pointing out this property since it's the only major difference from 0-based indexing that I could think of.

  3. 1 month ago
    Anonymous

    the index is the offset of an element from the starting address of the array

  4. 1 month ago
    Anonymous

    Sorry, wrong pic.

  5. 1 month ago
    Anonymous

    i still see a black

  6. 1 month ago
    Anonymous

    >moronic idea
    >I'm brown
    >I'm a w*man
    Makes sense

  7. 1 month ago
    Anonymous

    but that ruins string arrays.

  8. 1 month ago
    Anonymous

    R does it like that. i think matlab also.

  9. 1 month ago
    Anonymous

    Imagine looking at that image and thinking it is how utopia looks like. Lmao like what are you 8 haha.

  10. 1 month ago
    Anonymous

    0 is the first number

    • 1 month ago
      Anonymous

      Then how come when you initialize array[5] you get 5 elements, instead of 6?

      • 1 month ago
        Anonymous

        because 5 is the number of elements?

        • 1 month ago
          Anonymous

          And that's why array[5] should be the fifth element.

  11. 1 month ago
    Anonymous

    you have down syndrome plus you will never be a woman

  12. 1 month ago
    Anonymous

    Dijkstra wrote about this. The [m..n) interval notation is objectively the best

  13. 1 month ago
    Anonymous

    FPBP

  14. 1 month ago
    Anonymous

    When you make an array you're basically getting a memory address and a counter away from that memory address for the number of values in that array.
    So if I initialize an array of int8 Bob and the memory address of that array starts at 0x7700 the first value of that array is at 0x7700 and the second value is at 0x7701, the third at 0x7702, and so on.
    So it is easy to just use the address + index to address the values in the array. It is, quite literally, the most efficient way to do it.

    • 1 month ago
      Anonymous

      We're not in the 1970s. We have billions of memory addresses, we can afford to throw one away.

      • 1 month ago
        Anonymous

        It's thinking like that which leads to needing 16GB minimum today.

      • 1 month ago
        Anonymous

        the reason to start indecies at one is not to save memory but to make index/offset arithmetic easier.
        https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

        • 1 month ago
          Anonymous

          how often do you do those kinds of arithmetics, versus how often do you write a for loop and forget to write i < n - 1?

          • 1 month ago
            Anonymous

            <=

        • 1 month ago
          Anonymous

          >the reason to start indecies at one is not to save memory but to make index/offset arithmetic easier.
          But does it really?
          Currently for all loops to get a list of values based on index you just use < target, that just changes to <= target

          • 1 month ago
            Anonymous

            just iterating an array via a for loop is the most basic stuff you do with index/offset arithmetic.

            how often do you do those kinds of arithmetics, versus how often do you write a for loop and forget to write i < n - 1?

            I'd rather make the trivial stuff slightly harder and error prone stuff significantly easier
            than having the trivial stuff even easier and the error prone stuff even harder

          • 1 month ago
            Anonymous

            An array indexed by integers from range [a .. b] has b - a + 1 elements.
            If your indices start with 1, none of this matters because both the length of the array and the index of its last element are the same number.
            Ada goes full moron by allowing you to specify any range but when you stick to 1-based indexing, some calculations become simpler (or at least it felt that way when writing heapsort)

          • 1 month ago
            Anonymous

            >If your indices start with 1, none of this matters because both the length of the array and the index of its last element are the same number.
            If your indicies start with 0 none of this matters, either.

    • 1 month ago
      Anonymous

      We're not in the 1970s. We have billions of memory addresses, we can afford to throw one away.

      >We're not in the 1970s.
      Most languages in the 1970s started arrays at 1.

      We're not in the 1970s. We have billions of memory addresses, we can afford to throw one away.

      >We have billions of memory addresses, we can afford to throw one away.
      It doesn't throw away any memory addresses.

  15. 1 month ago
    Anonymous

    why are you brown and smelly?

  16. 1 month ago
    Anonymous

    with 0-indexation you can still pretend an array is 1-indexed if you want. but you can't do it the other way.

    • 1 month ago
      Anonymous

      You can just change it in Fortran. Defaults to 1 but you can set it to 0 or whatever you want

Your email address will not be published. Required fields are marked *