C++ - Native Code |
Source code |
Compiles to native code executed by its process |
Objects
|
stored in function's stack frame unless explicity placed in heap or static memory
|
Object management |
provided by program code, e.g., creation, deallocation, exception handling |
Types |
Language enables user-defined objects to behave like primitive types, e.g., value behavior,
through use of constructors and assignment operators.
|
Moves |
C++ provides move constructors but does not enforce single ownership, allowing use of source
after move, possibly resulting in undefined behavior.
|
Pros and Cons |
excellent performance, requires care to avoid paths to undefined behavior
|
Rust - Native Code |
Source code |
Compiles to native code executed by its process |
Objects |
stored in function's stack frame unless explicity placed in heap with Box |
Object management |
provided by program code and library, e.g., creation, deallocation, error handling |
Types |
Rust has two categories of types: Copy types and Move types. Copy types have value behavior.
Move types transfer ownership when assigned or passed by value.
|
Moves |
Rust treats all types that are not copy (satisfy the Copy trait) as moves. It enforces single ownership
so source becomes invalid after move.
|
Pros and Cons |
excellent performance and safety. Initially hard to build due to safety
constraints, but once built is very likely to have correct implementation.
|
C# - Managed Code |
|
Source code |
Compiles to byte-code, jitted and executed by its process's virtual machine |
Object storage |
object handles stored in function's stack, pointing to instances stored in heap |
Object management |
provided by virtual machine using garbage collector and VM events |
Types |
Types are either value or reference types, with quite different behavior |
Moves |
C# does not provide move operations.
|
Pros and Cons |
promotes safety at the expense of performance and initial latency
|