News for hackers. Stuff that matters.
Re:Rust is more than safety by tatterdemalion on Wednesday December 28, 2016 @02:53PM (#13273133)
Close. :-) Closures are anonymous types which implement one of the Fn traits (which are not anonymous). Traits are usually not implemented with vtables; they are usually monomorphized and statically dispatched (this includes most higher order functions). If you need dynamic dispatch, they can be cast into "trait objects" with vtables. This is a pretty big deal - static dispatch is why functionalish abstractions like map and filter can compile to a very tight loop.
Re:Rust is more than safety by ucarion on Wednesday December 28, 2016 @08:06PM (#13275007)
Ah, thanks for catching that subtle-but-important mistake. :)
Re:Rust is more than safety by Animats on Wednesday December 28, 2016 @03:54PM (#13273554)
And you wonder why C programmers have trouble with Rust.
Re:Rust is more than safety by akiselev on Wednesday December 28, 2016 @04:21PM (#13273769)
No one in their right mind is wondering that. Going from "go ahead, do whatever you want" memory management to Rust's ownerhsip system or object oriented programming to trait based programming isn't something anyone excepts to happen without some perseverance.
Re:Rust is more than safety by Animats on Wednesday December 28, 2016 @04:33PM (#13273864)
"Expects", I think.

Ask who really needs Rust. People who write code that has to work and causes real trouble when it doesn't. That includes embedded system programmers. They're typically into C and can use an oscilloscope. They seldom know C++ and have never heard of Haskell. But they can lay out a circuit board and get it to work.

Rust needs to be accessible to those people.

Re:Rust is more than safety by Manishearth on Wednesday December 28, 2016 @07:55PM (#13274958)
Almost none of the above is something you actually need to know when programming in Rust.

You just need to know how closures work at a high level, which is pretty straightforward. Rust closures are basically the same as C++ closures.

If you're really worried about the generated code generally iterator code with closures compiles down to the same thing as the imperative code. This isn't a hidden complexity unique to Rust; C code these days is pretty far removed from the generated asm too.

Re:Rust is more than safety by Veedrac on Thursday December 29, 2016 @04:26PM (#13280268)
I strongly disagree. Though it is possible to fudge through working Rust code without understanding the principles that govern Rust, which is probably more than you can say for C++, not understanding these things is going to make life a lot harder when you do run up against them.

An example: https://www.reddit.com/r/rust/comments/5iwyt9/how_to_accompl...

You might not need to know what "vtable" means, but the differences between, for example, `T: Fn()` and `T = Fn()` are pretty important.

Re:Rust is more than safety by kibwen on Wednesday December 28, 2016 @04:47PM (#13273969)
Rust's closure model is literally just C++'s with an extra dose of memory safety on top.