Since I was recently talking about FORTRAN and its one-based arrays, and how I used it for scientific (Chemistry / Physics) use way back when, I thought you may be interested in this link I just got today :-
I used FORTRAN77 lastly when I did my diploma work 1984. Then I learned C and dBase and thought that FORTRAN is very outdated. I believe one reason why it is still there: people don't want to learn new things once they are familiar with a tool. And of course the non existing interoperability of those other languages. From my point of view there is nothing we cannot do in C and it's successors too but there are many things we cannot do in FORTRAN.
Maybe I'm wrong. There are so many languages out there ...
I started my programmer career with Fortran 77. I am glad that I can use other programming languages now. But it depends on the task someone has to resolve. If it is more important to run long duration simulation programs on super computers it can still be convenient to do it in Fortran. I remember having worked with programs of few thousands of lines spending very much main frame time to do what I should do. And now? Now we have programs of some milions lines of code, but most of the code is used only for user I/O and not for heavy calculations.
What is regarding the zero based arrays:
I believe that it was the pointer approach in the 70s that fitted so nice to highly optimized C programs that introduced thinking zero based: The data pointer to an array is immediately the pointer to the first element using a 0 offset. And this will remain, it's the same why programmers still are using Fortran...
Arne Ortlinghaus wrote: The data pointer to an array is immediately the pointer to the first element using a 0 offset.
Yep. But the fundamental error was, the "thing" it points to is Thing #1, not #0 - counting starts with 1... So the problem was not a possible offset, but the way the index was semantically interpreted... Yes, you have to add a cycle for access to the first element, but, OTOH, if you use arrays there are more than one element - and for all other you have to calculate anyway...
But, as you wrote, it will stay, like so many cemented things of the past, sadly.
but we have many similarities in our normal live:
If you are 0 years old, you are in your first live of year.
If you go to the first floor of a building, in reality you are in a building that has at least two floors. So the first upper floor should be the second "total" floor, especially if you think in one-based arrays...
As an exercise in learning X# syntax etc., I have made a Generic class which is really just a wrapper which goes around a .NET System.Array object. Tested with Int and String so far.
So all I do really is to convert the start and end "one dimensional" index array values. I am adding more nice little features now that things seem to be working ;-0) Can't resist it !
A two dimensional version will come later when I have solved all the problems. Try this for an example of use :-
Plans are in progress to be able to 'Add' an element, as well as Filling a range from an input array. You know, the stuff we have in ArrayList and List<T>. I think I may also handle resizing in some nice and "easy to use" way.
PLEASE all note that this is done as a good way of learning X#, Generics, and feeling familiar with more complex syntax than just the usual 'bread and butter' stuff.