Hacker News new | past | comments | ask | show | jobs | submit login

Composable? Julia and composable?!?

They decided on sequence range [1...N], instead of [0...N) like Python.

Try to compose that.




Depends on what you work on. When doing more computer science like stuff, such as computing memory offsets etc, then 0-based indexing is practical. But for numerical work 1-based indexing is usually easier to work with. Mathematical texts are already using 1-based indexing and hence that is what people are used to when thinking about math.

I work with both and I never found this a big problem. This is on par with complaining about whitespace in Python. I prefer languages to not be whitespace sensitive but it is not a big problem.

Although I pretty sure you will accidentally get more problem from Python whitespace usage than from Julia 1-based indexing.

And frankly since Julia can use any indexing, you can use A[begin:end] to refer to the whole range of an object. If you want the second item in any array you can just write A[begin+1].


Whatever I'm doing this is wrong. Simple example - I have Python sequence [0...N) to process. If members are independent, I could split it with easy in Python and do it in parallel: [0...N) -> [0...M) + [M...N) for any M between 0 and N. Basically, Python sequences/ranges/etc are monoids in many cases. Simplest composition rule - monoid, with unit element and associative composition. In Julia it really looks ugly, you have to make some effort to do it right.

For me, Julia people don't get range/sequence composition right, so ...


You're inventing problems that don't exist. Every thing you said is applicable exactly with 1, 2 or whatever based indexing. It literally doesn't matter.

Julia's sequences/arrays are monoids too, I don't see what it has to do with anything.


> Every thing you said is applicable exactly with 1, 2 or whatever based indexing.

read my statement again, it is about open vs closed interval. Python ranges/sequences are composable, Julia ones are not.

> Julia's sequences/arrays are monoids too

really?

suppose you compute sum, and got two results: S(1, M) and S(M, N)

Could you compose them in Julia?


You compute S(1, M-1) and S(M, N) instead and compose them. That's it. This is not complicated stuff.


> Mathematical texts are already using 1-based indexing

For matrices and vectors, usually. For series and sequences 0-based comes up quite often too.


> But for numerical work 1-based indexing is usually easier to work with.

That's not really true in my experience, since all the nice properties of zero-based indexing transfer perfectly over to mathematics.

But you're right, this isn't anything to abandon an otherwise wonderful language over.



If subtracting 1 when needed is too much work then you have more serious problems that the choice of programming language.


What does that have to do with anything?


Simple example - I have Python sequence [0...N) to process. If members are independent, I could split it with easy in Python and do it in parallel: [0...N) -> [0...M) + [M...N) for any M between 0 and N. Basically, Python sequences/ranges/etc are monoids in many cases. Simplest composition rule - monoid, with unit element and associative composition. In Julia it really looks ugly, you have to make some effort to do it right. For me, Julia people don't get range/sequence composition right, so ...



It's pretty easy, you use an OffsetArray.

Because Julia is composable the shape of the array and the values in it are orthogonal while reaming performant (as discussed by the article). As demonstrated by OffsetArray how one access an array is also orthogonal to those other factors, while remaining performant (it's a zero runtime cost abstraction).


Why I have to make special efforts to make simple things? Simple example - I have Python sequence [0...N) to process. If members are independent, I could split it with easy in Python and do it in parallel: [0...N) -> [0...M) + [M...N) for any M between 0 and N. Basically, Python sequences/ranges/etc are monoids in many cases. Simplest composition rule - monoid, with unit element and associative composition. In Julia it really looks ugly, you have to make some effort to do it right. For me, Julia people don't get range/sequence composition right, simple thing, basic thing, thus ...


0-based indexing makes some things harder. Why should i have to make special effort to make those things simple?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: