Get the latest tech news

How does Ada's memory safety compare against Rust?


A comparison of how well Rust and Ada prevent the most common memory-related software errors.

While Ada's controlled types do support implementing RAII-like functionality, under normal circumstances forgetting to manually deallocate heap memory will cause it to leak. If we wrap the Get call in a loop, and poll the user continuously until we have a value within the array bounds, SPARK can actually prove that a buffer overflow can't occur. Unlike in C, freeing an access type in Ada automatically sets its value to null, and any subsequent attempt to dereference it will raise a Constraint_Error exception, which can be caught and handled.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Compare

Compare

Photo of Ada

Ada

Photo of Rust

Rust

Related news:

News photo

Ada crate of the year 2024 announced

News photo

What Do Linux Kernel Developers Think of Rust?

News photo

Writing a simple windows driver in Rust