Python handles globals badly.
steve at pearwood.info
Tue Sep 8 17:56:04 CEST 2015
On Wed, 9 Sep 2015 12:31 am, Ian Kelly wrote:
> On Tue, Sep 8, 2015 at 5:55 AM, Vladimir Ignatov <kmisoft at gmail.com>
>>>> I had some experience programming in Lua and I'd say - that language
>>>> is bad example to follow.
>>>> Indexes start with 1 (I am not kidding)
>>> What is so bad about that?
>> It's different from the rest 99.9% of languages for no particular reason.
> It's not "different from the rest 99.9% of languages". There are many
> languages that use 1-based indexing, e.g. Matlab, Pascal, Fortran.
Correct. Nearly all natural languages start counting at 1, not 0, as do
quite a few programming languages, such as PL/I, Algol60 and others. You'll
note that languages that are designed for mathematics (Matlab, Mathematica,
Julia) tend to use 1-based indexes. This is not an accident.
Guido discusses why he choose 0-based indexing like in C, instead of 1-based
indexing like in ABC:
He links to this fantastic discussion of why C ended up with 0-based
It's a wonderful read.
Anyone who thinks that there is one right answer here simply isn't paying
> None of those are even the worst offender here, IMO. That honor goes
> to Visual Basic 6, where the default lower bound is 0, but the
> programmer has the option of declaring an array to use any lower bound
> they want, or even globally change the default.
I'll just point out that some algorithms are best written with 0-based
arrays, and some are best with 1-based arrays. I shouldn't have to change
languages to change from one to the other!
More information about the Python-list