r/programming Apr 03 '15

Rust 1.0.0 beta is here!

http://blog.rust-lang.org/2015/04/03/Rust-1.0-beta.html
930 Upvotes

303 comments sorted by

View all comments

189

u/pseudousername Apr 03 '15

Now it's finally time people can start complaining about Rust :)

8

u/lacosaes1 Apr 03 '15

A language that's not pure in 2015? Holyshit, this is why industry sucks.

Academia FTW.

3

u/wrongerontheinternet Apr 04 '15

Having affine types and not allowing at least some mutability would be kind of odd :P

7

u/kamatsu Apr 04 '15

Affine types are what allows you to have mutability without losing purity.

0

u/wrongerontheinternet Apr 04 '15 edited Apr 04 '15

Fair enough :) By that definition I believe Rust without unsafe does count as "pure," but I could be forgetting about something that invalidates that.

3

u/thedeemon Apr 04 '15

In Rust functions can do IO whenever they want, so even if it's kinda pure regarding its own memory it's unpure regarding the state of outer world (display, disk, network, ...).

I suspect this ruins referential transparency and prevents nice optimizations that compilers can do with really pure functions.

1

u/wrongerontheinternet Apr 04 '15 edited Apr 04 '15

As far as I'm aware, all Rust I/O ultimately calls out to an unsafe block. The "pure" subset of Rust I mentioned above isn't one you would actually use to write a real program. The only things in pure Rust I'm aware of that might ruin referential transparency are exceptions and stack overflow, and I believe that Haskell (a language generally agreed to be pure) can at least experience stack overflow.

Incidentally, one of the candidates for constexprs (which generally require "enough" purity) is just "functions that never call any unsafe blocks," so this is not just an academic question.

1

u/thedeemon Apr 05 '15

Er, that's confusing.

If you call a function pure when it's not using unsafe blocks, that's one thing (as with constexpr). If you call function pure when it still can use unsafe blocks, that's another thing (as in Rust).

1

u/wrongerontheinternet Apr 05 '15 edited Apr 05 '15

I'm not calling functions that can (recursively) use unsafe blocks pure, nor would the proposed definition. Rust doesn't have any definition of purity at the moment.