I've started to work mostly with Julia 0.4 recently since has a lot of useful tools for me. I noticed the following error message:"indexing with non Integer Reals is deprecated"I guess this is due to Issue https://github.com/JuliaLang/julia/issues/10154. I may well be missing a crucial point here, but I think it is a huge mistake to take this step and it is taking Julia in the wrong direction. It feels to be something along the lines of "premature optimisation". For casual scripting, or just quick testing, teaching numerical computing to beginners, converting from Matlab, and probably for many other reasons, not having to worry about types is really important.
The problem is that its fairly easy to be casually wrong when using reals as indexes. What does 10. index? (Hint: floating point numbers can't represent 10 exactly, its 9.999999...)
That's one place off at the end of a 10 petabyte array. We're really planning for the future. But as I think about it, we've grown 10 MB to 10 GB arrays in 20 years, so who knows what the future will bring.
Personally I think learning the difference between Float and Int is a pretty basic programming skill, that is better thought at entry level, than in a "post mortem" when something really bad happened. This distinction also makes programs easier to read, because it forces one style of programming.
I agree it is easy to learn, but numerical analysts are *not* computer scientists, nor should they be expected to be.
My question was "does Julia always use float64 even if its a 32 bit build?" so that a real can be assumed to at least be that size.
Although non-integer indexing is deprecated, am I still allowed to do it if I build my own getindex? Or, put another way, will Grid.jl still work?
Following the principle of 'minimum surprise': If I have an integer just that happens to be represented via a floating point type I would still like to be able to use it as an integer.
Julia tries, and I think succeeds, in solving the two language problem.
The two language problem being that one uses one language for most
things but drops down to a fast language for bottlenecks and/or one
language to prototype one for production.
This means that Julia has to cater to a wide range of programming style
and tastes: ranging from a throw-away script to big application code.
To pick up the not-integer-indexing example: this is probably in the
"throw-away-script" category. It seems it has been deemed too much so,
thus support was removed. In my big-application-code, I'd certainly
want not-integer-indexing to error.
Note that this goes the other way too: people hoping for a more strict
approach, presumably to make big-application-code more maintainable (see
e.g. this thread discussing private-functions of modules:
https://groups.google.com/d/msg/julia-users/by3y9JEMra8/9xqvoy_xd6YJ)
I think, the devs have found good middle ground in their design of Julia
so far. As Julia is evolving, discussions on these topics are important
(although not at infinitum...).
julia> module MatlabCompat
linspace(a,b,c)=collect(Base.linspace(a,b,c))
end
julia> using MatlabCompat
julia> linspace=MatlabCompat.linspace
julia> linspace(1,2,3)
3-element Array{Float64,1}:
1.0
1.5
2.0
julia> Base.linspace(1,2,3)
linspace(1.0,2.0,3)
As long as no package depends on MatlabCompat, then the issue of non-standard code will be localized.
D[i+1-div(d,2):j-3+q*5]
D[i+1-d÷2:j-3+q*5]
D[i+1-d>>1:j-3+q*5]
I feel like 99% of the problems that people have with deprecating floating-point indices arise because they used / rather than ÷ for an integer division. I wonder if there is some way to give a helpful warning in such cases?