17

I'm fed up with those memes about programmers that starts counting from 0.
index != count

Just go check in any programming languages.
For example, in Java:

string[] array = new string[1];
array.length doesn't give 0, it gives 1, even if 0 is actually the index of the item.
If you do array[0] you get the position of the item but you don't actually count from zero like that without looking retarded.

Fuck it.

Comments
  • 9
    Empty array has a length of zero
  • 1
    @electrineer But there is no item index.
  • 1
  • 0
    @netikras There is no item nor indexes if the length is zero.
  • 0
  • 0
  • 0
  • 1
    Counting down UNTIL 0 is faster anyway.
  • 1
    @Fast-Nop I wonder if there's an optimization method to transform loops that count up into loops that count down.
    You'd need to check data dependencies inside the loop body before transforming, hmm
    Maybe via TMP, or by hacking at libclang
    Hmm, gotta try this out
  • 1
    0 is the smallest positive integer and combinations of the digits 0-9 make up all other numbers. The first 10 digits are therefore 0-9 and not 1-10, memes or not.
  • 0
    It's a grey area, finding length of array is for developers, where as languages are create for interaction with machine,in this case counting from zero is more practical (might i say needed) when you take into account how memory allocations are done or machine code works. You've to consider binary implementation and memory offsets. For machines counting start from one, we can do nothing to change that even if you hate those memes, counting start from zero
  • 0
    I really hope you start counting from zero....otherwise....at least I couldn't say "Zero Fucks Given!"
  • 0
    @irene yes it is. In math it's included with the positive numbers.
  • 0
    @irene there is no such thing as a neutral number in math. There are positive, negative and imaginary ones. Zero is included with the positives. A count of zero is nothing but it's still included among the positive numbers.
  • 0
    @netnut @irene
    ”All non-negative numbers” includes all positive numbers including zero. That shouldn’t be cunfused with ”zero is a positive number” though.

    However, a quick google did yield that, in some advance cases, there seem to exist a need to restrict the property of zero to be either negative or positive.
Add Comment