|
Hans Dietrich wrote: Humans start counting at one, but start measuring at zero.
Heh. I really appreciate you bringing to light that distinction.
Hans Dietrich wrote: This leads to a lot of confusion in interpreting ancient texts
Interesting! I didn't know that!
Marc
|
|
|
|
|
Marc Clifton wrote: Interesting! I didn't know that! Yes, there's an obvious religious text I could quote, that illustrates exactly this problem.
|
|
|
|
|
Hans Dietrich wrote: Yes, there's an obvious religious text I could quote, that illustrates exactly this problem
Genesis?
Marc
|
|
|
|
|
Heh. I'll just say it has something to do with something happening on the third day.
|
|
|
|
|
The third day is only 2 days away from the first day. Today is 0 days away from Today.
The concepts surrounding the difference between absolutes and relativity are vaguely understood and even harder to describe but not for mathmatics.
Lets not forget that numbers are expressions. For the most part, they are logical expressions, but 0 and 1 are also states. False and True. None existance and the Existence of.
|
|
|
|
|
How many elephants are in the room?
|
|
|
|
|
|
no no no, has to be one - in the corner..
|
|
|
|
|
Well, it may be true for you, but when you are in the embedded world, you usually don't use objects, sometimes you are even forbiden to use it.
In other languages, such as ADA, you start counting whenever you want, you just need to tell the compiler what are your limits. Sometimes you don't even count numbers.
Maybe it is just me, but I think this question does not make sense and serves to just start another language war just by its text saying C is ancient history when it is still widely used.
|
|
|
|
|
Agree. Starting from 0 could be a mistake or convenience due to system restrictions in the early development of computing technology.
TOMZ_KV
|
|
|
|
|
What do You do when You have to set numer of loops? Usually we do sample like this: variableName= variableName - 1. So we DO one operation more when we starting counting at 0.
I can Youse counting at 0 or 1 but i think that starting counting at 1 is closer for people and decreases implementation bugs.
|
|
|
|
|
No - most loops are from start to end, so
int count = GetNumberOfElements();
for (int i=0; i < Count; i++) {} --> 0-based is ok
If you have to loop backwards:
int i = GetNumberOfElements();
while (i--) {} --> 0-based is ok, too
|
|
|
|
|
Ok, You're right but if You don't have built in function in some languages....
Ok Klaus, We can decrease count of loops but still we have to remember that some lang. have 0, others 1 index at start. And WEe can write code like yours but if You want to generate grid for customer and each row must be numerated, so You must write row 1, row 2 , not row 0 row 1 etc. So we must read cell from array and ADD +1 (rowNumber+1). If We could write in language where each indexing array would be starting at 1 it could decrease number of bugs and maybe number of operations.
|
|
|
|
|
Yes, but try to to revesely:
for(unsigned i=0; i<N; ++i)
a[i]=...;
becomes
for(unsigned i=N-1; i!=0u-1; --i)
a[i]=...
abusing of -1 == MAX_UNSIGNED_INT
or
for(unsigned i=N; i>0; --i)
a[i-1]=...;
for(unsigned i=0, j=N-1; i<N; ++i,--j)
a[j]= ...
asymmetrical, or using cont and indexes as separate concepts.
But if everything start at 1...
for(unsigned i=1; i<=N; ++i) ...;
for(unsigned i=N; i>0; --i) ...;
perfectly symmetrical.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Maybe it is true about the humans. Homo programmicus is a separate species.
Nick Polyak
|
|
|
|
|
I agree. If we were "resetting" the programming industry we should start from 1. But most of us have just gotten used to zero-based indexes so it seems odd now to do anything different.
Kevin
|
|
|
|
|
Jacques Bourgeois wrote: For humans, zero is the absence of something. One means that there is at least one element.
100% agree. Zero-based arrays and such need to go. Years in the past, a lot of the old BASIC languages gave you a choice. Something on the order of Option1 or Option0 if I remember correctly.
Everybody SHUT UP until I finish my coffee...
|
|
|
|
|
Not so "old BASIC". In Visual Basic classic, that is up to VB6, you could specify Option Base 1 at the top of a file for arrays to start at an index of 1.
Even better (or worse, depending on your position), you could define arrays any way you wanted:
Dim x(3 to 10).
Dim y(-20 to 20) that one being very useful to plot coordinates on a graph.
Although they were useful in some applications, those things tended to confuse the non initiated, and forced the initiated to often check the declaration in order to use an array properly.
So I am quite glad that in VB.NET they fixed the basic index of an array.
But since most collections start at 1, why did they not do the same for arrays?
Jacques Bourgeois
|
|
|
|
|
Everything in Computer science and engineering is zeros and ones. The premise of a clock cycle says zero is the start, then one is voltage high, then zero, and so on. I strongly feel they should be zero based.
Bikeatlanta
|
|
|
|
|
|
C and C++ use 0 and I'm fine with that.
Lua uses 1 , and that was at first disappointing, now I'm used to and don't bother anymore.
Supporting both (the way VB6 did) still looks a bit weird (but possibly save many 'coders wannabe' from application crashes...).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I'm for '0 or any'. Being fixed at 1 seems arbitrary, being fixed at 0 is completely plausible.
|
|
|
|
|
I don't agree, but it is just matter of personal taste.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you had asked me 25 years ago when I was new to programming I would have said 1. But today I wonder what idiot would want it to start with 0?
Nevertheless, After some deep thought and setting aside my nerdiness, which is compelling me to say 0 (like 90% of other developers) I still believe deep inside that it should be 1. Starting with 0 is still the root of many "off by one" looping errors. Then there are real worldly representations that just do not accept 0 as start and so you are tweaking your index references with in-code "+1" modifications. This happens so much in programming. After decades of programming we are used to it such that starting with 0 seems more natural. But it is not.
Starting with 0 was a first historical step in mankind bowing to the needs of the machines. This will no doubt continue. We are all doomed. Skynet SHALL win. All of you who voted 0 should be aware of the implications of this altered belief of yours.
Yes. You have become slaves to your machines.
|
|
|
|
|
You have opened my eyes.
Now how can I change my vote?
Regards
Shajeel
|
|
|
|