|
Well you can't realy expect after all this years using arrays starting in 0 everybody suddently thought "Oh wait, let's start by 1 instead beacuse we're kinda bored with the 0"
|
|
|
|
|
I've a devoted VB programmer... from VB3... zero based was always my preference. I don't really care personally, I just want uniformity and most major big boy languages (including VB) are default to or allow with a lot of use to zero based. In low level systems, it's a requirement. In high level systems it's trivial debate. We all use numbers for arrays (I hope, I've never seen a language that uses letters or counts pipe symbols) so lets just keep one rule.
When I actually thought about this argument I realized I've almost stopped using single dimensional arrays, which I feel like is the only type where this debate has real meaning. More complex collections objects are easier to use unless you really need the performance and multi dimensional arrays so often represent a physical plane which naturally starts at (0,0) or (0,0,0) I feel it's not worth the occasional loop help to have a 1-based system ever... come to think of it, I don't use For much either, always For Each and Do... Loop w/cursor (when deleting from collections).
|
|
|
|
|
I'm just glad they made their minds up and hope they stick with it. What pisses me off is when you run up against some antiquated tool that uses a different (1) base.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Why not both? If you want your arrays to start at 1 then simply do not use the first (0) element. Sure it is a waste of memory, but nobody seems to care about memory any more as it is so cheap.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Just to check, what's your choice:
Bacon
- or -
Tee Oh Eff Oh
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|
|
CListCtrl
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
You've already stepped in it. It's too late to invoke that control...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
The problem with this is that most people are professionals and develop code professionally. This means code must be shared and co-maintained. Unless everybody is a VB developer this causes great confusion.
I used VB many years ago before C/C++ and now C#. It was for people that had no programming skills or training (as few did in those days) to be so verbose they could actually understand what was going on. It was been kept back then because of a legacy base that existed when real programming languages started emerging. Beginners thought it was the way to go because C and C++ were so complex relative to VB. So they stayed with it. VB has become close to as powerful a language as C++/C#. There are elegant things you can do with C#/C++ that you cannot do with VB. Dot Net has evened the power out.
But, there is no question that VB is a very ugly and busy language. The bounding of every declaration with an End statement and the Pascal Casing of keywords make it somewhat unreadable and cluttered so that it is harder to see what is really going on. VBers are used to it. C#/C++ers are not and it looks overly verbose. Even in the beginning where people used assembler because there were no real high level languages, the indexes always started with zero. VB adds a statement to subtract 1 from the index to use it. It has to because in memory arrays they have to use pointers and the index starts at the starting address without offsetting. No starting at zero would mean they would have decrement it for the loop in order to calculate the offset by multiply the entry size by the index. So it is more than just a waste of memory. It is also a waste of processing. Having to add the word DIM in order to declare a statement is pointless and even more cluttering. Instead of "typeof(x) you have to type TypeOf(x). That is too much usage of the shift key which slows typing. Especially if you turn the annoying syntax checker that won't let you leave the line until you fix any error in the syntax. I am still forced to use it for macros so I still get the pain. Having to know two different syntaxes is also a royal pain.
There is much bigotry against VB. I think I have listed what the main gripes are the over verbosity, silly syntax to "explain" the obvious, and the fact you don't know whether it is indexed by 0 or 1. These are unfortunate but they are legacy. They are not likely to change.
I am glad to see there is a rapid move away from VB. Having two primary languages litters the google search landscape. I don't think people use VB because they are simple minded. I just believe it is what they learned and they have experience on it and they don't want to change anymore than C# people would want to change to Java or some other language that they are not used to.
It is unfortunate that VB has this legacy. IF not for this gross mistake, this indexing issue would not exist because mid level languages ever attempted it because they saw redundant processing as a waste. As far as FORTRAN goes, it may be why VB got that tradition. But, it died on the vine long ago. VB hasn't. It is not as elegant and powerful at debugging syntax than C#. It is bad that Microsoft has to waste money with different compilers and editor support, when that time could be used to develop new tools or technologies which would benefit the entire programming world. But, it is what it is. Maybe in the future, the usage of VB would drop to a point that they could drop support for it.
|
|
|
|
|
Of course, the old VB, before .NET allowed you the ability to declare it either 0 or 1. Certainly, the atrocity of declaring an array with 10 elements and getting 11, 0 thru 10, is not the way to go.
Delphi allows you to declare an array starting with the positive integer of your choice, e.g.:
var Appointments : array[3 .. 9] of Integer; which would give you seven (7) elements.
Or you could do the usual:
var Appointments : array[0 .. 6] of Integer; for seven (7) elements.
Norman E. Fisher
|
|
|
|
|
To me that makes sense. It doesn't matter what you call it as long as it has the number of elements you require?
A rose by any other name...
|
|
|
|
|
Why use anything other than 0? It always works when the iterating a range and can just use the count. I see no benefit to using arbitrary offsets. If I saw them I would assume the code was a hack job, rather than a well designed or elegant piece of code, and that the code is confusing to anyone that doesn't know the reason (which would be everyone but the author, then maybe even the author if he picked it up later).
Even if you say something like from 3..9, you still have the problem of knowing whether you are starting with the 3rd or 4th element, and ending on the 9th or 10th element. It did not solve a thing. If you don't use zero as the index, there is always some a priori knowledge of the special case that you HAVE to know or document so it is easy to see and understand, which just increases the probability of a bug.
There is nothing gained except the ability to hack and it should not be encouraged as a principle of software development. That is like encouraging people us Goto or return in the middle of a function, to me.
I think this is why there is a lack of respect for VB coders. Their language of choice encourages bad technique. I prefer the codes look and the compiler tell me if I appear to be doing something stupid with warnings, rather than just hide it in the muck of verbosity and irregularity.
Just my opinion.
|
|
|
|
|
*pArray essentially means pArray[0] . Using pArray[1] and *pArray for same thing would be inconsistent and error prone.
A loop that starts from 0 would always end up counting the elements, no +1 or -1 would be required.
When building lifts starts with 0, and almost everyone can understand it, what the problem with 0-based indexing?
|
|
|
|
|
Unfortunately there's a continent full of people who don't understand that lifts start at zero. They don't even understand that they are called lifts.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
My experience also says something else too. People would ask for the lift to "come-down", or to "go-up". Instead of asking it to take you "where" you want to go.
For example, you are on 4th floor, want to goto ground floor, and lift is on 1st floor - they would press "UP" asking it to come up, take you. Instead of pressing "down", where you want to go!
|
|
|
|
|
Oh yeah.... I see that almost everyday and I think: "Hummm... it's gotta be the first time they are using the elevator".
If the above is true, then man, I think I'm the person who has seen the most people using the lift for the first time.
|
|
|
|
|
They left out being able to choose any positive integer for the starting index.
Still I vote for array indexes starting at zero.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
I was *that* close to adding a "other" option on the poll.
But I knew that would just confuse the issue
cheers,
Chris Maunder
The Code Project | Co-founder
Microsoft C++ MVP
|
|
|
|
|
Only the true comedians here would have selected it.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Well the universe is homogeneous, why shouldn't be the arrays?
Yes, I'm one of the true...
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]
|
|
|
|
|
|
|
You can in Ada, if I remember rightly, or with a negative number, but though it seems clever when you do it, the code is unmaintainable. But that goes for Ada most of the time anyway.
------------------<;,><-------------------
|
|
|
|
|
CIDev wrote: Still I vote for array indexes starting at zero.
Surely zero is neither positive or negative.
|
|
|
|
|
Why stop with positive. Pascal let you do something like this:
Example = Array[-5..5] of Integer;
3x12=36
2x12=24
1x12=12
0x12=18
|
|
|
|
|
Ahhhhhh. I still remember my love affair with (Turbo) Pascal. What a beauty.
|
|
|
|