Compile time checks those avoids runtime crashes(segfault)
1. Ownership
2. Borrowing
3. No Manual Memory management
- Rust does not provide `new, delete` operators as in C++ for
dynamically allocate memory.
- Though C++ provides smart pointers, still someone can leak
using C++98 new() and delete()
- Rust's ownership and borrowing rules ensure memory safety
without the need for manual memory management.
C++
|
Rust
|
Faster wrt C++
4. Aggressive Complier Optimizations
- Rust's Compiler(LLVM) optimizes code more aggressivly wrt C++ compiler
& this is because of ownership rules, LLVM can make assumptions.
- LLVM is more aggressive about inlining functions, especially for small
functions. Inlining avoids function call overhead and makes it fast.
5. Lower Runtime overheads
- C++
Exception Handling
has Run time overhead
Smaller binary wrt C++
RTTI in C++
increases size of binary
Rust does dynamic dispatch using
trait Printable avoiding need of
RTTI