News for hackers. Stuff that matters.
Re:Giving up on Julia by bluecalm on Friday May 13, 2016 @05:44PM (#11693403)
The thing about 1 based indexing is that it's a kind of in your face "this is different" decision from the point of view of a programmers of most popular languages. To be honest I wouldn't want to start investing my time into a language where people who proposed 1 based indexing are making design decisions. It's not that I think they are incompetent but it's clear they care way more about some different world than about my programming world and are ready to make my life miserable stating the point.

Now, I don't know if people from that different world (Fortran, Matlab, some other languages used in academia maybe) would feel the same way about 0 based indexing but it certainly sends the message to programmers outside those domains.

Re:Giving up on Julia by chappi42 on Friday May 13, 2016 @06:09PM (#11693519)
R and Mathematica are also 1 based. And R really is popular (http://www.tiobe.com/tiobe_index?page=index - ok, popularity is droping right now, likely b/c of Julia ;-))
Re:Giving up on Julia by c3534l on Friday May 13, 2016 @06:46PM (#11693680)
Julia seems like it's meant to be friendly to people who know MATLAB, Python, and R (even Fortran). R and Python are really comfortable with working with data science and that's what Julia is geared toward. I have no experience with MATLAB, though. Julia's programming "world" may indeed be a different programming world than C programmers.

I'm not defending Julia per se. I've been patiently observing from the sidelines to see how the language shapes up.

Re:Giving up on Julia by banku_brougham on Friday May 13, 2016 @07:22PM (#11693843)
R is ranked lower year-on-year, but if you click into the actual rating time series you can see that R is on a tear into new highs of popularity. For that matter so is MATLAB. Julia is still buried in the next 50 list.

BTW i'm a julia proponent, I'm just starting into it but I like a lot about it.

Re:Giving up on Julia by nonbel on Friday May 13, 2016 @08:30PM (#11694027)
>"popularity is droping right now, likely b/c of Julia"

I don't see how you concluded that? http://www.tiobe.com/tiobe_index?page=R

Re:Giving up on Julia by eternalban on Friday May 13, 2016 @07:29PM (#11693859)
So is Lua.
Re:Giving up on Julia by bdowling on Friday May 13, 2016 @08:11PM (#11693980)
Lua tables are more interesting than that. You can have an table that is indexed by any supported type. That means tables indexed by positive or negative integers, floating point values, references to other objects or other tables, true, false, strings, coroutines, and external memory references can all be indexes. You can also have a single table indexed by any combination of these.
Re:Giving up on Julia by eternalban on Friday May 13, 2016 @08:25PM (#11694016)
Isn't that technically a hashtable and not an array?
Re:Giving up on Julia by bdowling on Friday May 13, 2016 @09:24PM (#11694180)
In Lua the same data structure is used for both. The implementation optimizes the data structure like an array when you use a range of non-negative integers as indexes.
Re:Giving up on Julia by mindcrime on Friday May 13, 2016 @09:47PM (#11694228)
To be honest I wouldn't want to start investing my time into a language where people who proposed 1 based indexing are making design decisions.

Possibly because you're used to working with languages like C, C++, Java, Pascal, Javascript, Python, etc. But in the world of languages tied closely to scientific / mathematical programming (Matlab/Octave, R, etc.) 1-based indexing is the norm. If you'd "grown up" so to speak, in that world, you'd probably find 0-based indexing distasteful.

Re:Giving up on Julia by xxs on Saturday May 14, 2016 @06:37AM (#11695484)
Around 3 decades ago when started with BASIC, Pascal/Delphi 1-based index was pretty much the norm and off-by-1 mistakes were significantly more dominant.

Switching to zero based index Java/Javascript/C felt a lot more natural (no need for upper bound, always include->exclusive when it comes to bounds). Many algorithms benefit greatly from as well (hashtables + bitwise AND, for instance)

Virtually I do not recall making off-by-one errors while working with Java. Whilst it could be attributed to personal experience, the loops construct "for (int i=0; i<length; i++)" or "for(int i=length; i-->0;)" appear quite intuitive. Strict bounds (i.e. < or >) feel more elegant as well.

Seeing, using both type of indexing, 0-based one would a winner by large margin in my book.

Re:Giving up on Julia by Avshalom on Friday May 13, 2016 @10:01PM (#11694263)
Pascal (and Ada) actually expects you to specify the both the first and last index foo[1..10] or foo[0..9] are both valid arrays (though I believe 1 is the traditional first index) which is handy when you do run into situations where one or the other is a poor fit for an algorithm.
Re:Giving up on Julia by bluecalm on Friday May 13, 2016 @10:50PM (#11694366)
Yes, my argument is purely about habits. 1-based indexing is a potent trap for programmers who are used to implementing stuff in 0-based indexing world.
Re:Giving up on Julia by dnautics on Friday May 13, 2016 @06:32PM (#11693625)
You shouldn't be so biased. Having one based indexing makes translating numerical recipes from pure math textbooks (where vectors and matrices are generally one-based) simpler and less error prone. I say this as someone who chafes at Julia's one based indexing as a matter of professional practice.
Re:Giving up on Julia by bluecalm on Friday May 13, 2016 @10:47PM (#11694353)
It's very error prone if you implemented algorithms using 0 based indexing your whole programming life. You are just bound to make mistakes if suddenly it's 1 based indexing.

I am not saying 0 based indexing is technically superior (I really have no opinion on that). I could compare it to switching positions of brake and accelerator in a car - you can talk about brake on the right design being superior all you want but the fatal crashes will happen if you implement it.

Re:Giving up on Julia by rrock on Friday May 13, 2016 @11:10PM (#11694397)
This is exactly why all of my off by one errors happen in zero-based indexing languages. I need 1-based languages for data analysis, and 0-based languages for working on instrumentation.
Re:Giving up on Julia by dragonwriter on Friday May 13, 2016 @10:56PM (#11694376)
Of course, zero-based indexing is prone to error if you've grown up using natural language ordinals your whole life, and get business requirements based in them both of which are stunningly common of real developers and real development tasks.
Re:Giving up on Julia by dnautics on Saturday May 14, 2016 @02:27AM (#11694771)
0-based indexing is technically superior, because it makes offsets for memory addressing simpler.
Re:Giving up on Julia by Avshalom on Saturday May 14, 2016 @05:22AM (#11695268)
Well unless your array is more than just x-many addresses in a row, like if the array carries metadata related to length (like every language but C) or if it's a sparse array (hint sparse arrays are super common in numerical work).
Re:Giving up on Julia by tcpekin on Friday May 13, 2016 @11:22PM (#11694430)
I don't really get the difference. I'm in academia i guess (grad school) and use MATLAB a bunch, as well as Python (not a CS major). I don't think it's that much work to switch between the two, and I don't understand why there's such a division. Why is this such a huge deal?
Re:Giving up on Julia by nl on Saturday May 14, 2016 @01:30AM (#11694668)
It's not. It's nothing more than bike-shedding language design.

It's an easy thing to discuss, and everyone is an expert. Meanwhile, the real problems get ignored.

Re:Giving up on Julia by jules on Friday May 13, 2016 @06:44PM (#11693672)
Does 1 based indexing actually matter? It does if you are doing index arithmetic for rolling your own multidimensional arrays for example, but one shouldn't do those kind of things anyway.
Re:Giving up on Julia by Fomite on Friday May 13, 2016 @07:53PM (#11693920)
One thing to keep in mind is that scientific computing languages often have people using them who are not programmers, and who will not be "rolling their own multidimensional arrays."

If they're used to R, MATLAB, or basically any statistics programming/scripting language ever, not only will they be expecting 1-based indexing, they might not even know that that's a thing they have to think about.

Re:Giving up on Julia by developer2 on Friday May 13, 2016 @11:15PM (#11694411)
>> they be expecting 1-based indexing, they might not even know that that's a thing they have to think about

The truth of the matter is that this is not a point that anyone should ever mention as either a pro or con of any language. It's simply a fact that you're going to see one or the other, and it's useless to complain about which one is present in any given language. It's a one-time discovery as to which you're working with. People try to make it out to be a debilitating factor, when in reality it's a non-issue.

Re:Giving up on Julia by bluecalm on Friday May 13, 2016 @10:55PM (#11694371)
There are tons of things which you need an index for when iterating over an array. Do something different for every 4th element but then something else if it's 16th. Keep doing something for triplets of elements unless you run into specific index which is divisible by 7, then start taking them one by one. Iterate but go 5 elements back if you encounter something in some state. There are a lot of algorithms which take advantage of array being an indexed data structure with an order and not just plain container without structure.

The problem doesn't just go away with for each style loops. Python added enumerate for this reason but it really is quite clumsy for anything more complicated (and you have to choose if it's indexing from 0 or 1 anyway).