10 ms·
Rust 0.12.0 released
- kibwen 12y agoI'm very excited at the progress in this release. In particular I'm thrilled at the ongoing focus on ergonomics and overall developer experience, what with the push for quality documentation (brand-new tutorials, code examples for all library functions, and API stability markers) and the rapid maturation of Cargo. Also, lifetime elision and `where` clauses have done wonders in reducing the horror that has historically plagued Rust function signatures. There's also been tons of progress toward the last features that are blocking the 1.0 release (http://blog.rust-lang.org/2014/09/15/Rust-1.0.html http://blog.rust-lang.org/2014/09/15/Rust-1.0.html). The long-awaited work on dynamically-sized types is now partially complete, and the only two remaining big hurdles that I can think of are closure reform and trait coherence reform. Onward to stability!
- untothebreach 12y agoexcuse my ignorance, but what exactly does 'lifetime elision' mean?
- mbrubeck 12y agoIn cases where a function's input and output have the same lifetime, the lifetime is now inferred. So instead of this: fn f<'a>(x: &'a SomeType) -> &'a OtherType you can now write this: fn f(x: &SomeType) -> &OtherType Same meaning, just more concise syntax.
- untothebreach 12y agoah, got it. thanks!
- thomasahle 12y agoUhm, what if I didn't want `&OtherType` to have the same lifetime? Would I then write: fn f<'a>(x: &'a SomeType) -> &'b OtherType ?
- kimundi 12y agoYes, though this particular code would not compile because one of the lifetimes is not declared.
- kibwen 12y agoThat would be illegal, because it only makes sense to return a reference when that reference is somehow linked to the lifetime of an input parameter. (Or when it has a lifetime of `static`, which means the referent is stored in static memory and thus is alive for the whole program.)
- thristian 12y agoWhat if you're looking up the input in a temporary cache of some kind, and returning a reference to the cached value? The lifetime of the input and output would not be related in that scenario, but the output would not necessarily be 'static (maybe you build a cache, run some functions, tear it all down, then build a new cache with different values and do it all again).
- steveklabnik 12y agoThe lifetime would be matched to the lifetime of the cache, which has to be referred to somehow.
- thomasahle 12y agoAh cool, I still have a lot to learn about rust :)
- TD-Linux 12y agoYou wouldn't use a reference generally, if you're thinking of creating a new independent object you'd just return that. This is for cases when your return object is a reference into your argument, for example
- steveklabnik 12y agoPart of Rust's ownership system are 'lifetimes.' Without getting into the details, they're an annotation you occasionally add to code in certain situations. Like these two: fn get_mut<'a>(&'a mut self) -> &'a mut T; fn print<'a>(s: &'a str); The 'a parts are the lifetime annotations. We used to have a single inference rule for when you didn't need to write the annotation. With RFC 39[1], we added two more. These two extra inference rules removed 87% of the existing annotations, giving you this instead: fn get_mut(&mut self) -> &mut T; fn print(s: &str); This is a pretty huge readability win. 1: https://github.com/rust-lang/rfcs/blob/master/active/0039-lifetime-elision.md https://github.com/rust-lang/rfcs/blob/master/active/0039-li...
- untothebreach 12y agooh ok, thanks. i knew what lifetimes were, but was confused by the 'elision.' Apparently I didn't connect 'elision' with 'elide.' So, new vocab word for today :)
- haberman 12y agoWhat kind of cases do you still need to write explicit lifetimes?
- steveklabnik 12y agoI actually haven't had to since elision was implemented, so I can't give you a good rule of thumb from experience. Here's an overview of how the rules applied to the standard library at the time they were implemented, which is where the percentage came from: https://gist.github.com/aturon/da49a6d00099fdb0e861 https://gist.github.com/aturon/da49a6d00099fdb0e861
- xKingfisher 12y agoThe most common case I have run into is storing a reference inside another data structure.
- kibwen 12y agoBasically, after working with lifetimes for so long we realized that a great many functions that take lifetime parameters follow a similar and straightforward pattern. As of this release, we now allow you to omit lifetime parameters entirely for functions that follow this pattern, which is likely the vast majority of functions in your code that previously required such annotations. The detailed release notes have a more, er, detailed explanation: https://github.com/rust-lang/rust/wiki/Doc-detailed-release-notes https://github.com/rust-lang/rust/wiki/Doc-detailed-release-...
- yen223 12y agoThis is a great change. But to clarify, functions which take 2 or more reference inputs won't benefit from this, since the compiler can't determine which lifetime parameter to use, right? Edit: Never mind, I RTFM. Turns out it can't benefit.
- saosebastiao 12y agoIt has come a long way since I first started using it (0.6 era). Congratulations on the release! I look forward to a future world where I can use it (via Servo) in Firefox, as well as in my Constraint Solver engine, which I hope to reveal for the 2015 Minizinc Challenge.
- nnethercote 12y agoMiniZinc! There's a blast from the past... I wrote most of the first few versions of the specification and much of the initial implementation. Good to hear it's still being useful.
- Ygg2 12y agoIs there like a what's new in Firefox but for Rust?
- frewsxcv 12y agoYes. Click on the link and scroll down.
- blinkingled 12y agoDoes the RFC230 (https://github.com/rust-lang/rfcs/pull/230 https://github.com/rust-lang/rfcs/pull/230) removal of green threads give me out of box 1:1 threading or just that std::io uses native threads and the rest has to use green threads only now as an additional outside dependency? Kinda confused given I don't follow Rust all that much. Really odd that they went with M:N model - if the OS is fast at creating/destroying threads 1:1 is the best model for vast majority of apps.
- wycats 12y agoThe default is 1:1 threads. If you use `spawn` in Rust, you get a native thread.
- blinkingled 12y agoOh, it is? I must be reading some old docs and mailing list discussions. That's great to hear. Thanks for the clarification!
- steveklabnik 12y agoIt's changed a number of times. First it was M:N, then 1:1 was added, then 1:1 was made the default, now M:N is getting removed.
- sitkack 12y agoDoes anything preclude M:N threading in a library? It is really useful in quite a number of scenarios.
- kibwen 12y agoI believe the goal is for there to be an officially-supported green threading library, yes.
- steveklabnik 12y agoThe existing libgreen will be moved out to a Cargo library. You just won't be able to seamlessly switch between the two like you did before, you'll have to explicitly use the green threading API instead.
- pkulak 12y agoNoticeably absent is a really good HTTP library.
- jmgrosen 12y ago...and as usual no one will actually use it ;) (Because of the nightlies, I mean -- the language itself even I use!) But really, is there any reason to have these "releases" that almost no ones uses, or is it just to have a concrete changelog every once in a while?
- kibwen 12y agoActually, I've heard from at least one person that the code that they wrote for 0.11 didn't break when upgrading to 0.12! A milestone in Rust history!! As we approach 1.0, these last few snapshot releases will become more and more valuable since the reduced frequency of breakage means that they will be more representative of the final language. The fact that people feel compelled to develop against nightlies is a bug, not a feature! :)
- sanderjd 12y agoI recently received a pull request on a library that I hadn't updated in about 6 months, and was astonished how few changes it needed! Very exciting times.
- doe88 12y agoVery good idea these release notes [1]. In a perfect world it should be even more detailed a bit like What's new in Python x.x notes. Maybe by giving the gist of an RFC through an example or an high-level description before linking to it, because there are some RFCs a bit overwhelming I think, more theoritical than illustrated with examples. [1] https://github.com/rust-lang/rust/wiki/Doc-detailed-release-notes https://github.com/rust-lang/rust/wiki/Doc-detailed-release-...
- kibwen 12y agoBecause it's easy to miss, note that there is a longer list of summarized changes below the links in the OP, also reproduced in this file: https://github.com/rust-lang/rust/blob/master/RELEASES.md https://github.com/rust-lang/rust/blob/master/RELEASES.md
- tkellogg 12y agoHow long until this hits Homebrew?
- cordite 12y agoDunno, but they already have pre-built installers for nightly.
- valarauca1 12y agoLikely the 1.0 release. Most Linux distros are holding off shipping rust until the 1.0 release.
- steveklabnik 12y agoNope, homebrew has included Rust for a while: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/rust.rb https://github.com/Homebrew/homebrew/blob/master/Library/For...
- waxjar 12y agoHomebrew has formulas for Rust. I installed Rust 0.11 yesterday :)
- sigzero 12y ago0.12.0 is up now.
- steveklabnik 12y ago> (will merge when the bot finishes and goes green) https://github.com/Homebrew/homebrew/pull/33060 https://github.com/Homebrew/homebrew/pull/33060
- eslaught 12y agoIs there a Cargo build on Homebrew?
- 12y ago
- acqq 12y agoReading the new Guide: http://doc.rust-lang.org/guide.html http://doc.rust-lang.org/guide.html "The first thing we'll learn about are 'variable bindings.' They look like this: let x = 5i; " And so on: "let (x, y) = (1i, 2i); let x = 5i; x = 10i; " I had to double check if the default (when the i is not written) is something else than int. It is confusing.
- steveklabnik 12y agoCurrently, there is no default. This is probably changing back. See https://github.com/rust-lang/rust/issues/15526 https://github.com/rust-lang/rust/issues/15526 and the associated issues. The TL;DR is this: not having a default type makes you consider which size to choose. This is generally good. But there are two good cases in which having a default helps a lot: examples and tests. Both of these are small, and don't really care about the details. In real code, inference means you can often not get away with annotating numbers, because the type is inferred. But in these two cases, there often isn't something to do the inference. Long ago, there was fallback, and then it was removed, and now we're considering putting it back. This is a great example of Rust's practicality and a scientific/empiric mindset to building the language.
- acqq 12y agoThanks! I support having the most convenient defaults. Not only for integers, but for other stuff too. Is there a default now for 3.33? Is there a default for "string in quotes"? If there is, integers should be the default too. I believe that everybody can invent as much red tape as he wants, the hard thing is making it concise and effective for the everyday use, not for the writers of compiler. Digressing, were there any discussions about using var like in Swift (instead of let mut)? What is the rationale for not making that more minimalistic?
- steveklabnik 12y agoThe thing is, for floats there's a default that makes sense. For strings, there's a default that makes sense. Integers, on the other hand, are harder. You _probably_ want i32, even on 64 bit machines, but then an i32 can't index an array, so for integers used that way, you want a machine-sized integer.
- rdtsc 12y agoAll this is good stuff. I think soon should be a time to look at performance. Performance should be close to or better than C++ on average. We know about "the root of all evil". But, if there is going to be any large uptake from those using C++ currently (and I imagine a lot of those developers are concerned about performance, memory usage etc), Rust simply has to compete on performance as well. Go in a way started that path. The whole "systems language" re-interpretation and all. But it never quite became the systems systems language. It can't quite eat C's and C++'s lunch figuratively speaking. Rust might be able to do it. But regardless of concurrency, type safety and other features if it cannot be fast enough it will have a hard time.
- steveklabnik 12y agoWe already do pay attention to performance. In general, Rust should already be in the same league as C or C++. Please open issues if you find something that isn't.
- kibwen 12y agoAnd even more important than current benchmark numbers is that the language is explicitly designed to be optimizable, and takes the idea of "zero-cost abstractions" seriously. I can count on two fingers the number of places where we impose dynamic checks by default in the name of safety, and one of those can be unsafely turned off and the other can be safely disabled with proper code structuring. (Theoretically we can also leverage Rust's ownership rules to automatically generate aliasing information. When implemented this should be an across-the-board speed boost for all Rust code in existence, in a way that C and C++ compilers can only dream of.)
- gnuvince 12y agoQuick note: as of 09-Oct-2014 at 18:20 EDT, the page http://www.rust-lang.org/install.html http://www.rust-lang.org/install.html shows the release date of 0.12 as July 2, 2014.
- steveklabnik 12y agoThanks! https://github.com/rust-lang/rust-www/pull/64 https://github.com/rust-lang/rust-www/pull/64 submitted.
- darklajid 12y agoFrom someone that sucks at C (learned a bit here and there a decade ago and never used it) and recently started looking into 'system' languages again: - The community was very friendly, although my questions probably were more on the 'RTFM' side of things - The rust compiler is amazing. The error messages it provides are clear and helpful, often including potential spelling corrections and/or repeating the part of the code that causes trouble, closing with a suggestion to fix that. It's not quite magic, but really impressive and helped me a lot to get started. Being a Windows dev by day I do bemoan the fact that this platform is a bit .. behind, but I'm actively pursuing a sideproject based on rust (on Windows) atm.
- bjz_ 12y ago> The rust compiler is amazing. The error messages it provides are clear and helpful I'm sure that Clang inspired the great error messages - it sets a very high bar for new compilers (and old - GCC is still catching up). > Being a Windows dev by day I do bemoan the fact that this platform is a bit .. behind I'm sure that once 1.0 is released there will be a greater effort to make the Windows experience more seamless. This will be extremely important if we want to convince more game developers to give Rust a go. Have you seen https://github.com/PistonDevelopers/VisualRust/ https://github.com/PistonDevelopers/VisualRust/?
- darklajid 12y agoNope, haven't seen VisualRust before. Thanks. That said, IDE support isn't exactly what I was referring to. - you need to install mingw separately and there are lots of reports about conflicts with other software that might bundle a different version of mingw - installing cargo is weird (so far .. I failed and don't use it) And even with my first baby-steps (i.e. doing basically nothing of value) I discovered some limitations, one being that you cannot create a DLL that exports an unmangled entry point - for stdcall (other calling conventions don't have that issue and follow #[no_mangle] or #[export_name="foo"]. BUT that's really not a huge deal for me. Just a bumpy road at times.