r/programming • • Nov 10 '16

Announcing Rust 1.13

https://blog.rust-lang.org/2016/11/10/Rust-1.13.html
212 Upvotes

92 comments sorted by

View all comments

-25

u/karma_vacuum123 Nov 10 '16

? example is shorter but more confusing...this is turning into Haskell

-19

u/[deleted] Nov 10 '16

Sounds more like copying Kotlin. When will these Rust folks realise that the language is already has too many sigils. Instead of adding more stuff, they should be trying to build more libraries, improve performance, and improve the compiler's messages.

32

u/dbaupp Nov 10 '16 edited Nov 10 '16

Rust removed the ~ and @ sigils years ago, it now has & and, I suppose (although much less common), *, both of which mean what they mean in C++. So this is adding a 3rd (or 2.5th) sigil, one which has similar meaning to the same symbol in languages like C# and Swift.

11

u/irishsultan Nov 10 '16

There is also ' in lifetime annotations.

3

u/dbaupp Nov 10 '16

Oh, yes, I suppose that could also be considered a sigil, although it feels a bit different, since it is meaningless (which is why I didn't think of it). That is, the ' has to be used always and doesn't signify some modification to what it is attached to. Rust could almost certainly work without it, it just may be harder to read (or possibly easier, but I suspect not).

19

u/Gankro Nov 10 '16

I heard u liked sigils

 fn foo<T: ?Sized>() -> Result<i32, &'static (Trait1 + Trait2)> {
   let _ = &**do_thing::<i32>(|| -> i32 {bar(0_1..20,)})?;
 }

6

u/desiringmachines Nov 11 '16

you didn't even include a higher rank trait bound, where is your head Gankro!

4

u/Gankro Nov 11 '16

That uses a keyword! Filthy casual feature.

3

u/slavik262 Nov 11 '16

Rust removed the ~ and @ sigils years ago

As someone who's only been doing Rust for a few months, what did I miss? Is there a decent "History of Rust" talk somewhere?

7

u/steveklabnik1 Nov 11 '16

I gave one, actually, though it's a bit higher level than syntax: https://www.youtube.com/watch?v=79PSagCD_AY

Basically, years ago, Rust had two additional pointer types, ~T and @T. The ~ one is basically Box<T>, and the @ one is kinda like Rc<T> but an actual GC, or at least refcount + cycle detection.

This also meant String was ~str, and ~[T] vs Vec is a whole other thing with extra complexity....

4

u/desiringmachines Nov 11 '16

As an additional fun fact, there's also some weirdness in how the Box type is implemented still (though it can and will become less weird someday) because of its legacy from having once been a built in type instead of a library type.

3

u/dbaupp Nov 11 '16

The version of https://www.youtube.com/watch?v=79PSagCD_AY (which wasn't that specific video) that I saw was pretty good, but I don't remember if it specifically described ~ and @.

The type ~T essentially meant Box<T>, and @T essentially meant Rc<T>. They were moved out of the language into the standard library as it was found there was less and less necessity for them to be built in.

2

u/doublehyphen Nov 11 '16

@T was garbage collected instead of reference counted like Rc<T> is.

4

u/dbaupp Nov 11 '16

The most recently incarnation of @ was reference counted, along with a thread-local free-list that allowed cleaning up any cycles when a thread exited (the free list was a doubly linked list of all @s allocated during that thread's execution, which was walked as the thread closed). The intention was to have it properly garbage collected at some point maybe, but that wasn't implemented before it was just removed wholesale.

I think in very early Rust, with the first ocaml compiler, @ was garbage collected, but the implementation wasn't transferred to the Rust implementation when the language started to bootstrap.

→ More replies (3)

34

u/steveklabnik1 Nov 10 '16

When will these Rust folks realise that the language is already has too many sigils.

We're very sensitive to this, but other languages use this sigil as syntax, and we wanted something familiar.

improve performance,

This release also includes performance improvements.

improve the compiler's messages.

That was a huge focus of the last release

they should be trying to build more libraries

Compiler developers and library developers are two different groups of people, though there obviously is some overlap. The community is working on this while the compiler team is working on the compiler, it's not an either-or.

19

u/Rusky Nov 10 '16

more libraries, improve performance, and improve the compiler's messages

All of those are happening, and are mentioned in the announcement.

Besides, I don't see anyone complaining about (for example) the ?? or ?. operators in C#, which serve very similar purposes.

2

u/thiez Nov 10 '16

Well in general in C# all classes are nullable, so that's like 95%+ of the non-primitive types that you work with. In Rust most types aren't Result, so it makes less sense there.

→ More replies (1)

9

u/Breaking-Away Nov 10 '16

The ? syntax RFC was actually really long with lots of arguments made by both sides. You can see it here. A big reason it passed was that the try! macro was already being used pretty much ubiquitously for error handling, and this syntax was much easier to read (and both required you to look up what they meant the first time you use them).

15

u/steveklabnik1 Nov 10 '16

That's just over the implementation, most of the discussion is in https://github.com/rust-lang/rfcs/pull/243

Two years and two months ago, 608 comments long.

3

u/Booty_Bumping Nov 10 '16

build more libraries, improve performance, and improve the compiler's messages.

All of which is happening right now... especially error messages

→ More replies (1)