what good is philosophy if you choose arrays based on 1? https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...
Fun fact: arrays in Fortran are also based on 1 by default, but they can be defined to start at 0, or even arbitrary negative numbers. The following are all valid: integer :: array1(5) integer :: array2(0:4) integer :: array3(5:10) integer :: array4(-4:4)
Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
111–120 of 249 posts
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#112Earlier quoted context omitted.
There's pretty big differences in usage between multimethods in Clojure and Julia. I've used both a decent amount. All functions in Julia are multimethods by default. If you don't use type annotations, a new method will be generated whenever you call the function with new argument types. This explicit type specialization is a very important part of why Julia can have such a consistently fast JIT despite its dynamicit…
> If you don't use type annotations, a new method will be generated whenever you call the function with new argument types. Damn. That's a pretty clever trade off between dynamic and static types.
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#113Earlier quoted context omitted.
I thought Tim Holy's Trait Tick was considered the de facto way to use traits in Julia? https://github.com/mauro3/SimpleTraits.jl
Maybe it works great, but the syntax doesn't feel native to me, and I don't see it used in the standard library, which means that it's not embraced by the language developers.
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#114Want to drive adoption? Introduce it in schools.
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#115Earlier quoted context omitted.
Suppose I have to compute sum for array of length N. In python it is something like s = 0 for k in range(0, N): s += a[k] Ok, I have more cores/CPUs, could I do it in parallel? Sure v1 = Sum(0, N/2) v2 = Sum(N/2, N) s = v1 + v2 I even could do it on asymmetric cores (like most phone CPUs today) v1 = Sum(0, K) v2 = Sum(K, N) s = v1 + v2 I could do a bit more complicated things, like calculating means. For that, I have…
But why should you have to care, why not just sum(range)? Or @threads for i in eachindex(object) and let the details about how many cores be written once, correctly, elsewhere?
Sure, if you have single infinitely fast CPU. In real life, we have to decompose problem, run it in parallel and compose it back.
> Or @threads for i in eachindex(object) & let the details about how many cores be written once, correctly, elsewhere?
Here I'm explicitly talking about details, how it should be done, importance of composition, monoids etc. I understand, that if someone did it for you, you might not care - well, more power to you then. But some basics rules about Pyton ranges are pretty good:
1. [0...K) + [K...N) = [0...N)
2. Given range [K...N), number of elements in the range is N-K, in case of [0...N) number of elements is N-0=N.
Simple, elegant, composable. I can't say the same about Julia
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#116If anyone is interested, I was snooping around and found one of the co-creator's PHD thesis that explains in detailed terms some of the ideology behind Julia: https://dspace.mit.edu/handle/1721.1/99811#files-area
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#117Earlier quoted context omitted.
Can't reply anymore to flagged-to-death sibling, but wrt "1-based array indexing": I've actually found behaviour of "zero-avoidance" a good battle-tested heuristics to coding. A lot of numeric spaces can be mapped as to be >0 or >0 Arithmetic is much safer without 0.
offset 1 is logical if you look at the machine code / data in memory. if you have array [a,b,c,d] array[0] is a which in computer is logical. why? because it stored in memory 'abcd' (forgetting endianness for sake of argument...) and the offset from the base pointer to a is 0. so it makes perfect sense for arrays to start at 0, as there is no offset from the base... there is not 1 item offset from the base :s if you…
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#118Earlier quoted context omitted.
as someone who's written a lot of Fortran and Python for the same project I fail to see the problem. I find something like row- vs. column order differences harder to deal with. 1 vs. 0 based is just a matter of choice, a developer should be able to adapt, just like tabs vs. spaces etc.
I think the exact amount of spaces that should make up a tab is an even more controversial point. I'd love to see what happens to the tabs vs spaces debate once someone makes tabs that aren't an integer multiple of spaces wide.
So, that world was and is a long time ago. We just don't typically give a way for people to set tabstops in most environments, therefore it was chosen that tabs would advance a certain number of spaces.
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#119what good is philosophy if you choose arrays based on 1? https://groups.google.com/forum/?hl=en#!topic/julia-dev/tNN7...
I don't recall the details, as this was a long time ago, but there were definitely times I was glad C++ used 0-based arrays, and there were definitely times when 1-based would have made for cleaner code.
So I overloaded the () operator to make a(n), where a is an array, equivalent to a[n-1].
It looked a little odd at first if I mixed a[] and a() form in the same program, but it wasn't hard to get used to.
I doubt I would recommend this in general, but it worked well for this particular application.
Re: Julia Language Co-Creators Win James H. Wilkinson Prize for Numerical Software
#120Earlier quoted context omitted.
offset 1 is logical if you look at the machine code / data in memory. if you have array [a,b,c,d] array[0] is a which in computer is logical. why? because it stored in memory 'abcd' (forgetting endianness for sake of argument...) and the offset from the base pointer to a is 0. so it makes perfect sense for arrays to start at 0, as there is no offset from the base... there is not 1 item offset from the base :s if you…
Ok, but why should that influence a managed language with no pointers?