-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why do Julia arrays use 1-based indexing? #558
Comments
Depends. Mathematica uses 1-indexing, and it makes perfect sense mathematically and code-style-wise. I haven't been able to compile / run |
There is a huge discussion about this on the mailing list; please see that. If 0 is mathematically "better", then why does the field of mathematics itself start indexes at 1? We have chosen 1 to be more similar to existing math software. |
Can you give me the URL of the discussion? |
http://groups.google.com/group/julia-dev/browse_thread/thread/b4d37bd859d86d84?hl=en You might have to join the list to be able to view it. It really isn't that interesting a topic though. We all work with both 0-based and 1-based languages and I don't think it matters that much. |
Sorry about bringing up a painful memory? What about sidestep the issue of 1-ness with a 'begin' just like 'end': a[begin] = 1 # first item
a[begin+1] = 2 # second You could leave the integral (non-begin-or-end) as is 1-based, but allow those who want to think in 0-ness to use begin in that style? |
I don't really see how pretending that Julia isn't 1-indexed will help people learn to use Julia, given that Julia is unambiguously 1-indexed and will stay that way. Unlike |
From a programmer's perspective, I find 1-based indexing harder to wrap around compared to python (mod operations on indexes, -1), etc. I also thought julia's goal was to unite the mathematical and general purpose languages. In this regard, 0 based indexing is much more popular. Indexing may seem like a small thing, but you deal with it daily, more often than anything else. |
I don't really think this topic is open for discussion anymore. |
See also |
Julia recommends pyplot for plotting. Pyplot uses 0-based indexing by default, so plotting |
I'm locking this issue as there's no real possibility of this being changed. |
See also: JuliaPy/PyPlot.jl#117 (comment) |
For most language they are start with 0. Why Julia choose zero.
And from mathematical point of view, start with 0 is better.
1 1 Java 17.050% -1.43% A
2 2 C 16.523% +1.54% A
3 6 C# 8.653% +1.84% A
4 3 C++ 7.853% -0.33% A
5 8 Objective-C 7.062% +4.49% A
6 5 PHP 5.641% -1.33% A
7 7 (Visual) Basic 4.315% -0.61% A
8 4 Python 3.148% -3.89% A
9 10 Perl 2.931% +1.02% A
10 9 JavaScript 2.465% -0.09% A
The text was updated successfully, but these errors were encountered: