Discussion on "Why I no longer recommend Julia" by Yuri Vishnevsky

The problem is it assumes the valid indices are 1:length(a). This cannot be assumed for an arbitrary AbstractArray:

julia> using OffsetArrays

julia> A = OffsetArray(1:10, -2)
1:10 with indices -1:8

julia> A[length(A)]
ERROR: BoundsError: attempt to access 10-element OffsetArray(::UnitRange{Int64}, -1:8) with eltype Int64 with indices -1:8 at index [10]
Stacktrace:
 [1] throw_boundserror(A::OffsetVector{Int64, UnitRange{Int64}}, I::Tuple{Int64})
   @ Base .\abstractarray.jl:691
 [2] checkbounds
   @ .\abstractarray.jl:656 [inlined]
 [3] getindex(A::OffsetVector{Int64, UnitRange{Int64}}, i::Int64)
   @ OffsetArrays C:\Users\kittisopikulm\.julia\packages\OffsetArrays\N7ji6\src\OffsetArrays.jl:428
 [4] top-level scope
   @ REPL[100]:1
7 Likes