Rust’s Big Differences

All developers will find substantial differences with Rust. In one aspect, Ownership, Rust is different that just about every language before it. The following outline gives a brief overview of Rust’s most significant (most difficult?) differences.

  • Variables – immutable by default, structs + methods (no classes), None > null, no implicit casting
  • Ownership – only one pointer at a time
  • Borrowing – sole pointer can be loaned / borrowed
  • Traits – not quite .NET’s interface

Ownership

Rust’s concept of memory ownership is its most substantial difference from other languages. Almost all languages employ an accessor model for memory. Accessors (aka, pointers, references, etc.) can be copied, passed to other code, etc., which results in multiple accessors to the same bit of memory.

Ownership explicitly replaces an accessor model with the ownership model. Ownership, and its companion Borrowing, underlie Rust’s focus on memory safe code.

For developers who have worked with pointers in languages like C, C++, etc., the easiest way to think about ownership is that only one pointer may point to (own) a memory location. Copying a pointer transfers ownership to the new pointer, and the previous pointer becomes invalid.

More recent OOP languages like Java and C# hide much of the complexity of dealing with pointers directly, but developers still deal with concepts value types (stack) vs object types (heap), passing by value (a copy) vs by reference (a pointer).

Regardless, the ownership model really twists your noodle!

See Ownership for more explanation and examples of ownership.

Leave a Reply