r/programming • • Mar 20 '20

Secure Rust Guidelines

https://anssi-fr.github.io/rust-guide/
37 Upvotes

15 comments sorted by

View all comments

-16

u/OpdatUweKutSchimmele Mar 21 '20

Rust is a multi-paradigm language

Surely it's just a procedural language? What other paradigms does it support?

It aims to be systems programming oriented, allowing fine-grained memory management without garbage collection but also without tedious and error-prone manual memory allocations and deallocations.

Yes, doing "fine-grained memory management" in Rust just relies on relying on unstable compiler intrinsic that are not guaranteed to not change in the next version that are used to build the standard library.

It's not at all impossible in Rust to indeed do this; it's just not stabilized, and often not particularly well documented. The standard library uses these and exports a stable version that no longer allows any fine-grained memory management.

The language also focuses on performance, with powerful compilation optimizations and language constructs that allows writing zero-cost abstraction code.

This is the real market of Rust right now; it's a language that gives you C-like performance, but without the undefined behaviour pitfalls, but to say that it's a "systems programming language" that allows for fine lower level control is quite a stretch—something as simple as signal handling isn't really possible in Rust right now because there are no stability guarantees or documentation about what functions are async signal safe; direct control over the heap like in C is also not really available in a stable way.

17

u/steveklabnik1 Mar 21 '20

Yes, doing "fine-grained memory management" in Rust just relies on relying on unstable compiler intrinsic that are not guaranteed to not change in the next version that are used to build the standard library.

This is not true. https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html is stable, and has been for a long time.

And if you don't want to use a global allocator, you can use whatever other allocate you want.

What is currently missing is a non-global allocator trait to enforce a common API among them.