Convince me that Lua's 1 based array indexing isn't retarded and wrong.

Convince me that Lua's 1 based array indexing isn't moronic and wrong.

It's All Fucked Shirt $22.14

Tip Your Landlord Shirt $21.68

It's All Fucked Shirt $22.14

  1. 2 weeks ago
    Anonymous

    Humans count starting from 1. Also your name is moronic.

    • 2 weeks ago
      Anonymous

      >addressing and counting are the same thing
      Why are nocoders so fricking moronic?

      • 2 weeks ago
        Anonymous

        >want to access the 1st (first) element on an array
        >"i-it's 0, o-okay? it j-just is, don't ask w-why."

        • 2 weeks ago
          Anonymous

          you can't get to 1 apple unless you first start with 0 apples

          • 2 weeks ago
            Anonymous

            that's not true

            You start at the first element. For every further element, you skip one element. To get the first element, you skip no elements, which why it's index 0.

            You can use based 0 indexing in Lua, though. It's just that everyone will hate you for it. Also you can't use the array constructor syntax.

            then it's not an index, it's an offset. the mental gymnastics cniles will perform to justify their errors...

  2. 2 weeks ago
    Anonymous

    if it was moronic why do they call it 1 based instead of 1 cringe?

  3. 2 weeks ago
    Anonymous

    0-indexed is just because of how pointer arithmetic works in arrays. Lua is explicitly a high-level programming language often used for scripting. there is no reason why its indexing needs to reflect array arithmetic. 1-indexed is far more traditional in mathematics

    • 2 weeks ago
      Anonymous

      I find that in practice doing arithmetic with indices is more ergonomic and relies on fewer edge-cases when using 0-based indexing.

  4. 2 weeks ago
    Anonymous

    it's a really high level language, so it's reasonable to start counting from a more natural number

  5. 2 weeks ago
    Anonymous

    i never had an issue mentally accounting for it when i would write garry’s mod shit. always seemed like a non-issue. the lack of a robust standard library and any modules written for it being out of date / unmaintained is a very real problem though. still a great language regardless.

  6. 2 weeks ago
    Anonymous

    It's not worth $20/m

    • 2 weeks ago
      Anonymous

      20 dollars per meter? of what?

      • 2 weeks ago
        Anonymous

        the moon. buying land on the moon isn't worth it. it's a white elephant. you'll lose everything in transportation costs

  7. 2 weeks ago
    Anonymous

    When you draw a 2-axis graph do you label the origin 1,1?

    • 2 weeks ago
      Anonymous

      Yes.

  8. 2 weeks ago
    Anonymous

    Don't lump Lua-tan with your stupid spam threads.

  9. 2 weeks ago
    Anonymous

    0 does not exist. its a psyop. not a natural number, does not occur anywhere in the real world.

    • 2 weeks ago
      Anonymous

      glass has 20 water
      sun evaporates water
      glass has 0 water

      • 2 weeks ago
        Anonymous

        glass has 1/infinity water actually (Newton, not zero)

      • 2 weeks ago
        Anonymous

        anon is right, 0 and negative numbers were invented by the oven people to fool you into getting in debt

      • 2 weeks ago
        Anonymous

        anon is right, 0 and negative numbers were invented by the oven people to fool you into getting in debt

        Cero is definitely a natural number. You can lack resources, materials, objects in general in nature that your brain is aware that exist. Negative numbers are a israeli psyop 100% though.

      • 2 weeks ago
        Anonymous

        glass has no (false) water

  10. 2 weeks ago
    Anonymous

    1 is more intuitive and would have saved devs from "of by one" confusion problems that sometimes happen when working in arrays but in practical terms all the languages under the sun use 0 so just make it 0 for consistency at this point

  11. 2 weeks ago
    Anonymous

    It's too late now[0]

    We won't be able to do

    if index:

    because index can be an index and falsey

    We will be forced to subtract 1 from every index in our head

    Forever

  12. 2 weeks ago
    Anonymous

    You start at the first element. For every further element, you skip one element. To get the first element, you skip no elements, which why it's index 0.

    You can use based 0 indexing in Lua, though. It's just that everyone will hate you for it. Also you can't use the array constructor syntax.

  13. 2 weeks ago
    Anonymous

    lua was made by brazillians
    they've apologized with elixir, which atones for their sins, but never forget

  14. 2 weeks ago
    Anonymous

    The choice of 1 or 0 indexing is arbitrary, 1-indexing is more natural for non-programmers, and this "debate" is peak bikeshedding.

    • 2 weeks ago
      Anonymous

      No it isn't. 1 based indexes break a lot of indexing arithmetic. As a very simple example lets say you want to find the nth slice of a 3 slices with 30 values array. If you index with 0 you can have

      >X * 30
      or maybe
      >(X-1) * 30
      and this will give you the start of the row, but if you have 1 based indexes strides just become kinda confusing, and you always have to add a 1. There is a fundamental difference between offsets (which is what arrays are), and counting things. There is literally no reason to use 1 as the first index, especially because everyone is used to doing arithmetic with offset based logic.

  15. 2 weeks ago
    Anonymous

    intervals start from zero
    items (labels of those intervals) start from 1

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