6 ms·
A selection of some of my favorite aspects of this release: 1. The (yet-ongoing) removal of managed pointers, leaving us with one fewer pointer type. Final tal
by kibwen 13y ago
A selection of some of my favorite aspects of this release:
1. The (yet-ongoing) removal of managed pointers, leaving us with one fewer pointer type. Final tally of built-in pointer types: unique pointers, mutable references, and immutable references.
2. The dead code detection pass (https://github.com/mozilla/rust/pull/10477 https://github.com/mozilla/rust/pull/10477), contributed by a student of the University of Virginia's Rust-based systems programming class (http://rust-class.org/pages/using-rust-for-an-undergraduate-os-course.html http://rust-class.org/pages/using-rust-for-an-undergraduate-...).
3. The `Any` trait, giving us on-demand dynamic typing (https://github.com/mozilla/rust/pull/9967 https://github.com/mozilla/rust/pull/9967).
4. The clean abstraction of green threads and native threads out into their own libraries (https://mail.mozilla.org/pipermail/rust-dev/2013-December/007565.html https://mail.mozilla.org/pipermail/rust-dev/2013-December/00...) such that any library that makes use of the stdlib will work regardless of which strategy the user selects.
We're not quite in the home stretch yet, but there are very few hard blockers left on 1.0. Here's the list that I can think of:
1. Dynamically-sized types (http://smallcultfollowing.com/babysteps/blog/2014/01/05/dst-take-5/ http://smallcultfollowing.com/babysteps/blog/2014/01/05/dst-...)
2. The extension of rvalue lifetimes (http://smallcultfollowing.com/babysteps/blog/2014/01/09/rvalue-lifetimes-in-rust/ http://smallcultfollowing.com/babysteps/blog/2014/01/09/rval...)
3. Struct single (note that's single) inheritance (http://smallcultfollowing.com/babysteps/blog/2013/10/24/single-inheritance/ http://smallcultfollowing.com/babysteps/blog/2013/10/24/sing...)
4. Niceties and sugar to support custom smart pointer types to complete the excision of managed pointers
As far as I know, the devs are still aiming for a 1.0 release in 2014. The 1.0 release will not necessarily mean that the language is done evolving or ready for production use, but it will mean that the developers will begin honoring language-level and library-level backwards compatibility. I would expect at least two more unstable point releases (i.e. 0.10 and 0.11) before a 1.0 release occurs.
- Ygg2 13y agoAren't unique pointer also scheduled for decommission?
- kibwen 13y agoNo, not at all. Unique pointers are awesome and are the foundation for lots of other features. Now, some of the syntax for using them might still change. That's yet to be decided. But it wouldn't be Rust without unique pointers.
- pcwalton 13y agoUndecided. They will always be somewhat magical in that the "box" operator creates them by default. But the syntax for them may change, or be moved into the library.
- dded 13y agoYou can put a pointer type into a library?
- lucian1900 13y agoRc and Gc are now libraries you can import. A nice advantage is that Arc, MutexArc and any other reference types look and work the same way.
- dbaupp 13y ago
- Touche 13y agoDocumenting Rust must be a major pain.
- steveklabnik 13y agoDisclaimer: I've written a bunch of it. It's actually not too bad. The biggest problem with the docs currently is that it's a patched-together set of things people have written at random over the last few years. Mozilla has taken some concrete steps to address this, it'll be much better overall soon.
- Touche 13y agoSorry, I was making a joke about how Rust changes a lot. You guys do great work considering.
- steveklabnik 13y agoHa, no worries. Thanks!
- dbaupp 13y agoThis release also heralds the ability for the built-in documentation generator to run any code examples, which has helped us keep the documentation up-to-date a lot.
- weavie 13y agoExcellent. It was the multitude of different pointer types that confused me the most, so it's great to hear that they are simplifying this.
- steveklabnik 13y agoMy guide got merged in for this release: http://static.rust-lang.org/doc/0.9/guide-pointers.html http://static.rust-lang.org/doc/0.9/guide-pointers.html TL;DR: you don't need them as much as you may think, so don't let that scare you away!
- pcwalton 13y agoInheritance may not make 1.0.
- kibwen 13y agoAh, news to me. I guess it can be introduced without breaking backwards-compatibility.
- Ycros 13y agoI'm finding that my OO code style these days is very composition heavy with pretty much no inheritance use. I think given Rust's type system, I'm not going to miss inheritance much.
- zanny 13y agoAs someone who writes a lot of C++ and has played with Rust (ie, hello world) how does the language work when you remove shared pointers? Say I have an early-generated state tracker for a whole bunch of events propagating in an event loop somewhere, that I want discarded when all the events finish. They are all separate tasks in different threads, so I either need to have some job that just checks if they all finish to clean up, or pass around shared data structures. How would you do that in Rust?
- banachtarski 13y agoI actually make it a point to do most of my code without shared_ptr, opting instead for unique_ptr. There was a talk somewhere about the "best written library you should never use" and shared_ptr was the focus. For the example you mentioned, you could have the parent object of those tasks responsible for cleanup of the shared object (e.g. each thread's destructor calls a finish function on the parent object). This is just one possible implementation. I don't encounter this as much because I prefer a shared-nothing approach where possible. edit:typo
- jmgrosen 13y agoIf the structure is immutable after you've produced it, you can use extra::arc::Arc<T> [0], and once all the references are dropped the memory will be deallocated. I haven't used C++, so this might be very similar to std::shared_ptr or not, but this is usually what one would use in Rust. (There's also extra::arc::RWArc<T> [1] when you need mutability, but that isn't used much in my experience.) [0] http://static.rust-lang.org/doc/master/extra/arc/struct.Arc.html http://static.rust-lang.org/doc/master/extra/arc/struct.Arc.... [1] http://static.rust-lang.org/doc/master/extra/arc/struct.RWArc.html http://static.rust-lang.org/doc/master/extra/arc/struct.RWAr...