News for hackers. Stuff that matters.
Re:Moving from Ruby to Rust by Certhas on Thursday February 14, 2019 @06:51PM (#19167226)
When I started Julia I was annoyed by it.

Then I realized that 90% of my mental gymnastics with indices got simplified. Explaining indexing to newbies is now immediate where before it took a slide, several examples, and a clever picture. Slicing is also more natural:

"1:3 picks out index 1, 2 and 3, which are the first, second and third element of the array."

Instead of the python version of

"0:4 picks out index 0, 1 and 2, which are the first, second and third element of the array."

Re:Moving from Ruby to Rust by saghm on Thursday February 14, 2019 @07:11PM (#19167352)
> "0:4 picks out index 0, 1 and 2, which are the first, second and third element of the array."

I don't think that's right? It should pick out four things, not three.

Of course, you could argue that getting that wrong proves your point! I personally still prefer 0-indexing, but I definitely agree with you that having an exclusive upper bound is confusing.

Re:Moving from Ruby to Rust by Certhas on Thursday February 14, 2019 @07:29PM (#19167486)
You're right of course. Not intentional.

0:3 picks out index 0, 1, 2.

So 1:3 picks out the second and third element, which are indexed by 1 and 2 respectively.

My guess is that what one prefers probably depends entirely on the data structures one works with most....

Re:Moving from Ruby to Rust by shele on Friday February 15, 2019 @02:49AM (#19169211)
I like how you got it wrong, proving your point.
Re:Moving from Ruby to Rust by petre on Thursday February 14, 2019 @11:59PM (#19168558)
Less off by one errors for one.