News for hackers. Stuff that matters.
Re:Rust, Lifetimes, and Collections by Animats on Wednesday November 19, 2014 @02:25PM (#8632056)
(Replying to message below, indent limit reached).

The panic check is inside the loop, not hoisted out of the loop?

OK, that means it's only optimizing bounds tests out when it can, not hoisting them out of loops. That's not bad for a compiler in the early stages. Is a matrix multiply free of checks in the inner loops? That's a good test, because most numerical code has a lot of matrix multiplies underneath. A useful goal is to have most of the inner loops from algorithms in Numerical Recipes free of unnecessary subscript checks.

If that can be done, is the "unsafe" stuff necessary at all?

Re:Rust, Lifetimes, and Collections by kibwen on Wednesday November 19, 2014 @03:29PM (#8632412)
At the limit, `unsafe` blocks would still be necessary for any FFI used to call into C code, which is trivially proven unsafe.

It's mistaken to think of `unsafe` as a novel language feature. All other languages merely defer their unsafe shenanigans to native C calls. I can just as easily write a memory-unsafe program in Python. In Rust, we use `unsafe` to hoist logic out of C wherever possible, to make our code even more safe; even the unsafe dialect of Rust is safer than C.