O'Reilly logo

Mastering Rust by Vesa Kaihlavirta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Memory safety

In many modern languages the usages of stack and heap are abstracted away from the programmer: you declare and use the variables in your code and they are allocated based on the usage patterns. Usually the allocation happens in the heap, and some form of runtime garbage collection takes care of the deallocations. The end result is easy memory safety, but with a runtime cost: the allocation decisions happen automatically and may not always be optimal for your program.

In contrast, a low-level systems programming language such as C does nothing to hide these details from the programmer, and provides nearly no safety. A programmer can easily create hard-to-debug errors by allocating and deallocating things in the wrong order, or ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required