13

Personally i think all arrays should start at -1

Comments
  • 8
    -1 should index the last element
  • 5
  • 11
    Let’s have them index mod the length and then they need never start nor end.
  • 5
    Arrays should implement complex numbers so we can have 1d 2d arrays and we can use arr[3 + 4i] instead of arr[3][4]

    Readability ftw
  • 7
    Can we put them on a Möbius strip?
  • 10
    Why do we need array anyway? If you need to store more than three values your code is way too complex.

    There should only be three variables—-x, y and z. And they should be strings. If you want to store anything else you have to serialise to a string.

    In fact, let’s get rid of y and z. I’m deprecating then. If you need them just use “y: <data>, z: <data>”.
  • 6
    Personally I think you are wrong
  • 3
    @platypus just store everything as json

    kappa
  • 2
    Let’s introduce a function that sets the starting position when an array is constructed
  • 3
    You can have your arrays start at whatever number you want... just keep it rational.
  • 2
    What is the problem with 0?
  • 1
    I agree with arrays beginning at -1 and avoiding else, getters, setters and nested if statements bc it’s good design and helps maintainability. Anyone who disagrees shouldn’t be a software engineer bc they have the wrong brain and should find another profession. If I’m a manager and I see any of these in the code base (even when it’s objectively ok to use them) I’ll fire that developer immediately and throw his ass on the street. This field shall be cleansed of such heathens and leave everything to us gods
  • 1
    I don't get why an array should start -1...

    Many comments here seem really dubious.

    An (numeric) array is an numeric indexed data structure. Nothing more, nothing less. The sequence can start at 0 or 1, depending on language.

    -1 was reserved as a special value in many languages as an indicator for end of array, though it would be more correct to use the usually available constants for it instead of using the number.

    It's the archetype for (m)any other data structures.

    Iterators, Generators, Lists, Array as Object, and so on.

    In my opinion, use the starting index of the language.

    Anything else is non standard and your stubbornness to choose non standard will make the life for any other developer hell.
  • 2
    Personally, I think.
Add Comment