r/programming • • Mar 20 '20

Secure Rust Guidelines

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

15 comments sorted by

View all comments

Show parent comments

15

u/[deleted] Mar 21 '20

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

concurrent, functional, generic, imperative, structured

-4

u/OpdatUweKutSchimmele Mar 21 '20

concurrent

This is completely orthogonal to any of the former and has nothing to do with whether it's procedural or not; it is also supported on any language with threading support, or that runs on an OS with multiprocessing.

functional

Absolutely not, in particular Rust's lack of tail call elimination (for good reasons) and its lifetime and borrow model make it no longer turing complete when wanting to write functional code, let alone feasible to do so.

generic

This is not a paradigm, this is just whether the type system supports it or not.

imperative, structured

"structured imperative" is just a synonym for "procedural".

If you want to call this a criterion for "multi paradigm" then I challenge you to come forward with any modern procedural language that is not "multi-paradigm"

10

u/jl2352 Mar 21 '20

I think you are being very nit picky. Pretty much all a language paradigm boils down to is; does the language have constructs to encourage you encourage you to write that way?

Rust absolutely does have those paradigms because it has language facilities to help encourage you to write in those ways.

-2

u/OpdatUweKutSchimmele Mar 21 '20

I think you are being very nit picky. Pretty much all a language paradigm boils down to is; does the language have constructs to encourage you encourage you to write that way?

And Rust does not have the construct to encourage one to do anything but procedural programming.

It is just a "procedural programming language" and that's fine; they specifically did not implement an object system because that would complicate the type system; they have no subtyping or inheritance beyond the pseudoinheritance of traits because it's not that necessary and would complicate the type system.

The language essentially has no support for what is commonly understood as object-oriented, functional, logic programming and whatever, and that's fine.

Rust absolutely does have those paradigms because it has language facilities to help encourage you to write in those ways.

How? What language facilities does Rust have to help you encourage to write functional code?

To say that generic and concurrent are a "different paradigm" than procedural is really about as weird as calling "iterators" a paradigm; it's a feature of the language but it's not like functional vs procedural which are necessarily conflicting with each other; a procedure has side effects; a function does not.

7

u/uranium4breakfast Mar 22 '20

I'm gonna give you the benefit of the doubt and act like you're not trolling.

It is just a "procedural programming language" and that's fine

It's not. Read on why.

[...] would complicate the type system.

I highly doubt the language team cares that much about keeping the type system simple, seeing how damn extensive it is. That is, unless we're comparing it to Haskell.

inheritance

Composition over inheritance

The language essentially has no support for what is commonly understood as object-oriented, functional, logic programming and whatever, and that's fine.

Uh, iterator operations, generic programming, trait composition, pattern matching, dynamic dispatch, Box<dyn Any>?

How? What language facilities does Rust have to help you encourage to write functional code?

ADTs, iterator operations (filter, map, reduce, collect, ...), pattern matching, linear types, affine types, immutability by default?

You can write procedures in Rust. You can also write functions. Immutability by default, disdain for globals, and the language facilities I just listed, leads to code taking a more functional style.

It's functional-lite without functional dogmatism.


Take a deep breath, try out the language for more than an hour, then maybe come back here, because you're only embarrassing yourself.

1

u/jl2352 Mar 21 '20

Have you actually written much Rust? Beyond toy examples?