Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code
by steveklabnik on Friday October 30, 2015 @10:50AM
(#10478132)
Rust's safety features are similar to those, but even stronger in a number of ways. There's two aspects to this: 1. more guarantees. You can write code with uniq_ptr that segfaults, but you cannot with Box<T>. 2. safety allows for patterns that would be dangerous in C++. For example, shared_ptr uses atomics for thread safety. Rust has two variants, Arc<T> with similar atomics, and Rc<T> without. If you're not using multiple threads, you can use Rc<T>, safe in knowing that Rust will give you a compile-time error if you introduce multithreading. In other words, there are ways that you need to be defensive in C++ that you do not in Rust.
Rust does not really have OOP, exactly, we have structs and traits (concepts). One major difference is that we don't currently have inheritance, though proposals are being worked on. But since we already have the concept equivalent, we have extra power there. Tradeoffs.
Rust lets you overload certain pre-defined operators, but not create new ones.
AST based, hygenic macros, instead.
[ Parent
| on HN ]
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code
by cristicbz on Friday October 30, 2015 @11:00AM
(#10478205)
> AST based, hygenic macros, instead.
Well and generics & traits. 99% of the places where C++ programmers use templates, they would use generics in Rust. `template std::vector<T>` <-> `Vec<T>` etc.
It's only the niche metaprogramming ability of C++'s templates that would be replaced with macros.
Re:Rust-Doom: A Doom renderer in Rust, with no unsafe code
by steveklabnik on Friday October 30, 2015 @11:02AM
(#10478219)
Yes, thanks, that's a more complete answer.