3 ms·
as a javascript developer, I want to know what is the main difference between Rust and JavaScript regarding memory safety. - javascript utilizes a form of autom
by yzemmour 3y ago
as a javascript developer, I want to know what is the main difference between Rust and JavaScript regarding memory safety.
- javascript utilizes a form of automatic memory management known as garbage collection (GC). The purpose of a garbage collector is to monitor memory allocation and determine when a block of allocated memory is no longer needed and reclaim it.
what about Rust?
- bigfishrunning 3y agoRust is fairly unique in that it uses a "Borrow Checker" to verify memory safety at compile time. Garbage collection has a definite performance cost, which Rust avoids.
- yzemmour 3y agothank you
- seanmcdirmid 3y agoRust relies on static memory safety. In general you want both static and dynamic, but you can take a static type safe language and run it in processes with isolated address spaces. GC is largely orthogonal to memory safety, although it is really hard to implement GC in languages that don't have static type safety (although not impossible).
- yzemmour 3y agothank you