News for hackers. Stuff that matters.
Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by phkahler on Wednesday January 23, 2019 @10:34AM (#18979017)
>> I really do with the 1 indexing had stayed around, since I feel like it's more natural to say the 1st element, instead of the 0th.

It's not the 0th element. It is the 1st element and has an offset of 0 from the beginning of the array.

Not saying it's better or worse, but that if you change the words you use to describe it, you may find it easier to use.

To my surprise, I just learned that ranges in Rust don't include the end number which felt incredibly stupid from a conceptual point of view (python too). But is syntactically useful when doing:

for x in 0..len(my_array) {

My preference would be that a range include the end number and the language provide more python-like iterators and list comprehensions. I am aware that there is a library that provides more python-like syntax, but that doesn't change the oddness of ranges in either language. I guess I just need to remember that the interval is open on one end. Which brings to mind the notion of using [0..n] or [0..n) in a language...

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by wwweston on Wednesday January 23, 2019 @11:58AM (#18979981)
> It's not the 0th element. It is the 1st element and has an offset of 0 from the beginning of the array.

This is why I think the terminology should be "indexed arrays" and "offset arrays" (and variables perhaps even called index/idx/i or offset/ofst/o as appropriate) instead of using the terms "0-indexed" or "1-indexed."

But I have a hard enough time getting out of the habit myself, and some people are going to hate using o as a variable, so....

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by umvi on Wednesday January 23, 2019 @10:43AM (#18979117)
Python almost always does what I want.

If I say `for x in range(10)` it iterates exactly 10 times, starting at zero (which is convenient for 0-index lists in python). It would be extremely counter-intuitive if it did [0,10] as it would iterate 11 times. I agree though that it would be much less ambiguous if you could just do `for x in [0..10)`, for example.

Current implementation requires the least amount of "off-by-one" corrections for most tasks, IMO.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by phkahler on Wednesday January 23, 2019 @01:00PM (#18980692)
>> If I say `for x in range(10)` it iterates exactly 10 times

Right and I expect that. The issue I have is that the values do not include 10. It turns out great in Python and Rust where things are 0-indexed, but that does not change the fact that the range construct itself is strange in not including 10.

I'm sure the notion of using mathematical notation where [1..10], (0..10], [1..11), and (0..11) all mean the same thing would drive the language parsing people nuts. Mostly because some of those involve unmatched [) or (]. But that's why we have a computer right?

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by nicoburns on Wednesday January 23, 2019 @11:25AM (#18979625)
Rust actually has both [0..=n] is inclusive

https://doc.rust-lang.org/std/ops/struct.RangeToInclusive.ht...

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by coldtea on Wednesday January 23, 2019 @10:40AM (#18979093)
>It's not the 0th element. It is the 1st element and has an offset of 0 from the beginning of the array.

It should be indexed with its position then a[1], as we do in all other aspects of life (and in math), and not with it's offset.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by umvi on Wednesday January 23, 2019 @10:47AM (#18979165)
> as we do in all other aspects of life

You mean like elevators? You may be surprised to learn that elevators in America are 1-indexed (ground floor == floor 1), but in Europe they are 0-indexed (ground floor == floor 0).

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by coldtea on Wednesday January 23, 2019 @11:12AM (#18979477)
As a European I'm not really surprised, but it's not exactly the same thing. It's not like the ground level is considered "the 0th floor" and thus we use 0-based indexing.

In most European countries the ground floor is not considered the same thing as the others. As Wikipedia puts it: "In most of Europe, the "first floor" is the first level above ground level".

We consider and count as floors the "layers" above the ground level. In french for example, the ground level is called "rez-de-chaussée" and the floors above it "XX étage". The ground level is not an "étage" (in American terms, the "ground level" is not considered a floor, and is not counted among the floors).

For this reason, apart from elevator labels nobody calls the ground level "the 0th floor" when speaking/writing.

And even in elevators, O is just used as a convenient way to convey the ground level (since the buttons don't fit much) -- and not everywhere. In many elevators it gets it own designation (e.g. G or GRD or some other national variety).

It's "the ground level" (with different names per country) + "N floors".

A multi-floor building with ground floor + 3 floors can even named "3rd-storey building" in some countries (and the ground level is just taken as granted) -- e.g. une maison à deux étages in the UK --> 3 story building in the US.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by phkahler on Wednesday January 23, 2019 @01:08PM (#18980770)
>> A multi-floor building with ground floor + 3 floors can even named "3rd-storey building" in some countries

I think you just refuted your own previous assertion that 1-indexing is universal in all other aspects of life.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by coldtea on Wednesday January 23, 2019 @01:48PM (#18981283)
Not sure what you mean. There are 3 floors (as europeans define a floor, ie. anything ABOVE what americans call ground floor) and are named floor 1, floor 2 and floor 3.

So, no 0-based indexing here.

We call the house a "3-storey house" not because we zero index, but because the cardinality of it's floors (as europeans define a floor) is 3. In "3-storey building" for Europeans, 3 is the "length", not the last index.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by threatofrain on Wednesday January 23, 2019 @02:11PM (#18981547)
Ground floor, 1st floor, 2nd floor still sounds very much like 0-based indexing. Is the objection just that people don't literally say the word "zero", but instead say ground?
Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by dragonwriter on Wednesday January 23, 2019 @02:20PM (#18981650)
“Ground floor” is not the European name; the names are things like “Ground of the roadway” (literal word-by-word translation of the French name), “first floor”, “second floor”, etc.

It's no more zero-based indexing than naming relations as “sibling”,“first cousin”,“second cousin” is, just because some hypothetical culture that also uses 1-based indexing but counts siblings as first cousins might rationalize our system as starting with “zeroth cousins” where they have “first cousins”.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by mcabbott on Wednesday January 23, 2019 @02:30PM (#18981794)
There are also differences of building styles, maybe this is part of how we ended up with different terminology. The prototypical Parisian building has a paved driveway to the courtyard which is on the ground level. The prototypical New England house has a first floor which is a wooden thing with floorboards, 3 feet or so above ground.
Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by threatofrain on Wednesday January 23, 2019 @02:37PM (#18981884)
If I heard that in other countries their use of 1st floor was 1 off from me, and they had a name for whatever was before 1, then what they have is like a zero, especially if some elevators use the literal 0 to mean the ground floor.
Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by coldtea on Wednesday January 23, 2019 @03:18PM (#18982382)
>and they had a name for whatever was before 1

What they have merely names what Americans name as zero.

But it's not a stand-in for zero, for us, it's a different entity (a different thing).

A floor (etage, piano, orofos, etc) is a "layer of building where people live above the ground level layer".

So there's no zero-based indexing of floors, because the first item in the set of what are considered as floors is called "first" (e.g. primo in italian).

So, the thing one must understand before they say "same difference", is the other cultural difference: that most European countries don't consider the ground level "floor" to be a floor/story.

I.e, we don't consider the upper floors and the "ground floor" to be in the same set. Which is also why we don't count them when we say a "2 story house" (and we mean a house with 3 such layers, ground story + 2 stories).

Is there a zero-based indexing of the whole "heterogenous" set of ground level + floors?

Well, it's common to have the ground level designated with G or national specific names: BG, BV, E, IS, PB, PT, RC, S, P, PK, etc.

It's just that in some elevators 0 is a substitute for this -- which is probably due to the few common brands and parts being international and nobody bothering to change them (e.g. Otis). That's more a red herring than how Europeans think about floors or index them.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by phkahler on Wednesday January 23, 2019 @04:28PM (#18983183)
>> So there's no zero-based indexing of floors, because the first item in the set of what are considered as floors is called "first" (e.g. primo in italian).

So the floors are numbered according to their distance above the ground level (whatever that's called). This matches my suggestion of treating zero-based indexing as a distance from the first element.

>> Is there a zero-based indexing of the whole "heterogenous" set of ground level + floors?

Yes there is! It's how the elevator buttons are labeled with the possible variation of using a label instead of "0".

The European elevator numbering scheme according to your own comments matches more closely with a zero-based indexing scheme than a 1-based. Or more precisely it matches my proposal to consider the numbers used to reference array elements as distances rather than indexes.

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by goto11 on Thursday January 24, 2019 @11:53AM (#18990372)
I think you misunderstand how the European numbering works. Think of it like Europeans count the separations between levels. There is no 0th separation, the first separation is the ceiling above the ground level. Saying that the ground level is the "first element" is begging the question - this is just not what Europeans count. (Well some do, but then they count similar to Americans, there is still no 0th floor ether way).

It is true that some elevators label the ground level 0, but this is usually when there are also negative levels (cellars).

Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by phkahler on Wednesday January 23, 2019 @04:21PM (#18983098)
It's not zero-based indexing, it's measuring the distance from a reference level. That matches my suggested change in terminology for indexing quite nicely (for zero-based indexing).
Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by oblio on Wednesday January 23, 2019 @11:48AM (#18979870)
Yup, for Europe I'd actually be curious which countries don't consider the first floor the one above the ground floor, since they're probably the minority.
Re:Julia Language Co-Creators Win James H. Wilkinson Prize f... by goto11 on Wednesday January 23, 2019 @04:52PM (#18983467)
It is not 0-indexed, it is just that "floor" means something different than in American English. It means a level above the ground. So the first level above ground is the first floor.

The German word Stockwerk is even clearer. It describes the wooden planks which separates two levels. So if you live on the first Stockwerk you live one level above ground.