Re:Julia's Arraypocalypse Release
by gct on Sunday September 27, 2015 @09:48PM
(#10288584)
One-based is just wrong. I've never been in a zero-based language and wanted one-based, but I go the other way all the time. Arrays beginning with zero are isomorphic to the ring formed by Z modulo N, and you can use a bit mask for modulo with a power-of-two array size. It's not an "implementation detail" that arrays start with zero it's a "zero is important to mathematics" thing.
If I want to build a hash table, a power of two size for the underlying array is a nice performance optimization since you can use a bitmask instead of a modulo operation, and it makes a big performance difference, what does one-based give you other than some nebulous "it just _seems_ simpler to think about" kind of nonsense? I love how we expect people to grok the type system but we're afraid zero-based arrays will scare mathematicians off.
If I want to build a hash table, a power of two size for the underlying array is a nice performance optimization since you can use a bitmask instead of a modulo operation, and it makes a big performance difference, what does one-based give you other than some nebulous "it just _seems_ simpler to think about" kind of nonsense? I love how we expect people to grok the type system but we're afraid zero-based arrays will scare mathematicians off.
See: https://en.wikipedia.org/wiki/Modular_arithmetic#Integers_mo...