DEV Community

loading...

Discussion on: Explain Rust like I'm five

Collapse
kayis profile image
K

When you programm a computer you have to tell it when you need memory to store your data in and when you done using it.

There are two ways to do it.

1 Say what memory you want and when you done. Yo write "free" every time your done.

2 Just pretend you can use all the meomory and let someone else figure out how much you really use and when you done with it.

Now "someone else" is usually some part of your software, called a garbage collector. While your software runs, it checks what memory you don't use anymore and "frees" it for other programs to use.

But with Rust "someone else" is your compiler, the program that translates the Rust language into computer language.

The Rust compiler writes your "manual" frees into the right places while it translates your Rust code into computer language. So you don't need a extra part in your software that looks for unused memory while it runs.