News for hackers. Stuff that matters.
Re:Rust and Go by gorhill on Friday November 07, 2014 @08:54PM (#8575715)
> functional style is so much clearer

There is something that makes me uncomfortable in there:

> let descending_squares = range(0u, 5u).rev().map(|x| x * x).collect();

The overhead. I wonder about it. I am unable to get a sense of what it is. With a simple for-loop, it's rather easy to see it, but with the version above I have no idea. So "much clearer" is not what I see with the piece of code above. I see what it does, but what is not so clear is what code will be generated, something which matters when trying to write efficient code.

Re:Rust and Go by dbaupp on Friday November 07, 2014 @10:51PM (#8575932)
There is not much overhead with Rust iterators at all. They are essentially concrete versions of the deforestation that Haskell can do to avoid constructing intermediate lists, and compile to code that is close to the equivalent C (the functionality is all statically dispatched, so the compiler can inline and optimise the calls). This is a case of having experience with and trusting one's tools.

I wrote a blog post a while ago that used iterators heavily http://huonw.github.io/blog/2014/06/comparing-knn-in-rust/ , as you can see the performance is good.

Re:Rust and Go by gorhill on Saturday November 08, 2014 @10:40AM (#8577151)
I am definitely going to have to look more into Rust.
Re:Rust and Go by kinghajj on Friday November 07, 2014 @10:54PM (#8575935)
Well then, good news! Such usages of iterators in Rust are almost always result in the same code that would be generated by old-fashioned, hand-written loops. The 'trick' is that the methods (and the closure!) are inlined, and generics are specialized at compile time.