Announcing Rust 1.12
blog.rust-lang.org
blog.rust-lang.org
(Which isn't to overshadow Jonathan Turner's heroic compiler error message overhaul that has been long in the works, or the dozens and dozens of new volunteers who answered the call to help us transition: https://github.com/rust-lang/rust/issues/35233 . But I've had the new error messages enabled for months now, and it's easy to forget that not everyone has been enjoying them this whole time!)
> Faster compilation time [...] Faster execution time [...] More precise type checking
* 1.11: "old trans" by default, MIR with a flag
* 1.12: MIR by default, "old trans" with a flag
* 1.13: MIR only, "old trans" is gone
Given that we've had 6 weeks so far with MIR-by-default, everything is looking good, but in theory, making it more widely available might turn up issues. If something catastrophic happens, in theory, old trans could be brought back. So we'll see how the next few weeks goes.That doesn't mean _no_ work has been done on non-lexical lifetimes, see http://smallcultfollowing.com/babysteps/blog/2016/05/09/non-... (that's a link to the last of three posts). But there's still work to write an actual RFC, discuss it, and then land it.
(Edited after @steveklabnik corrected me)
PRs in that repo are a much bigger deal than issues: issues are a place to talk in a general sense and see if others are interested in the feature, but converting that into an actual, actionable RFC is a lot of work. I'm not aware of any actual RFC for non-lexical lifetimes, because everyone who would do such a thing knew we had to wait for MIR to shake out before they were realistically possible, and so writing an RFC before then would mostly be a waste of time.
I've always thought that Rust's command line tooling is really top notch. The language may be complex, but the authors of rustc make it a point of pride to make it as easy as possible for users anyway. The new errors will make it that much easier to learn and be productive in Rust.
Also, the community involvement in this release is really spectacular. There were 83 participants working together on the new error messages [3] and 176 total involved directly with the rust compiler just for 1.12! (ok, well, including a few bots)
[1] https://internals.rust-lang.org/t/compiler-errors-for-humans... [2] https://www.reddit.com/r/rust/comments/3totkg/dybuk_the_elml... [3] https://github.com/rust-lang/rust/issues/35233
Compared to what?
Edit: This was not meant as a slight, I quite like Rust's comapritive simplicity when held up to other non-GC 'systems' languages.
For the record, I prefer rust.
I need
* json/gzip/etc. * string manipulation * good unicode support (normalization, etc.)
not much actually.
And one important question: which one do you think is best for large projects? Both were built to deal with difficulties rising from large projects but took two opposite directions...
I will say that all strings in Rust are Unicode, so the support is there.
Edit to your question about large projects: I think Rust's type system will prove to be a long-term benefit for large projects. The type system / borrow checker combination is the secret sauce of Rust.
* https://crates.io/crates/serde_json [1]
* https://crates.io/crates/flate2
* https://crates.io/crates/unicode-normalization
"String manipulation" is a bit broad, but Rust's string types are already pretty rich.[1]: small caveat here: this crate works on stable, but is more convenient on nightly. (Think "right now it's "go generate" but eventually it will be easier than that). We're close to stabilizing the stuff that it needs to be convenient on stable, but the earliest that could land in stable is Dec 22. (I just did this math yesterday.)
Serde (https://serde.rs/) is probably what you're looking for for serialization tasks.
I'm not really sure that's true. Rust probably has a smaller standard library overall, but there are things that it has that Go doesn't: B-trees, native OS string encodings, functional tools, round(), etc.
The bigger point is that the crates.io ecosystem readily has support for everything you're asking for, and it's much easier to pull in third-party dependencies in Rust.
(BTrees, on the other hand, thrive)
For Unicode support, here are crates for normalization https://crates.io/crates/unicode-normalization and segmentation (working with grapheme clusters and so on) https://crates.io/crates/unicode-segmentation
Re: "string manipulation" what do you need? Rust has a rich set of methods built in to its two native string types, (e.g. left-padding https://doc.rust-lang.org/std/fmt/struct.Formatter.html#meth... :P ), and we're open to adding more if there's demand for them.
What you're referring to (programs and behaviors) is not what I was referring to (language details).
The pretense that C is a simple language is equivocation, in my opinion.
https://en.wikipedia.org/wiki/Modula-3
So, that's my baseline if we're excluding functional programming elements. Maybe that with Design-by-Contract and SCOOP from Eiffel. I'd add borrow checker from Rust for unsafe sections as an option. Past that, you've already knocked out vast majority of issues while retaining rapid development.
If functional programming, I'd start with a PreScheme (C replacement), bring it closer to Racket on static or dynamic side for power, build in safety analysis, and sugar coat it with nice syntax + standard library. Julia language did something similar to that approach with femtolisp at the core. Also easy to read and learn for a language so powerful.
I currently recommend Rust over most C alternatives due to the attributes in its motto plus strong community (most important) around it. The simpler alternatives in this niche got little traction for various reasons that are more social or economic than technical. So, if you're jumping on a wave, might as well pick the one that's safe and fast by default.
The biggest issues I've seen lie at the safe/unsafe boundary. Things that are trivial to write without safety guarantees in C++ become more verbose (at least) in Rust.
On one hand we need to still be able to do low-level stuff on "as needed" basis, but on the other hand it needs to be hard and explicit so that route is only taken as least resort and very easy to track down, even without help from tools.
The thing that (currently) trips me up the most is figuring out when when I've to dereference something, and why, when I've to pass a reference to something and why, etc. Sometimes I do end up with a touch of operator soup.
This is a very common experience! One of the goals this year is to ease this painpoint.
I was just browsing the apidocs of peek_mut. Can you share a motivating use case? It wasn't immediately obvious to me.
It's basically replacing the former (never stabilized) `push_pop` and `replace`, which Python folks can relate to similar methods in their `heapq`, for instance. With separate `push` and `pop` calls, the heap must be sifted twice, but with `peek_mut` you can update the head in-place and sift only once.
Looks like it's to do something with the top data without the overhead of pop()+push()
Edit: ninja'd
This will be nice. I couldn't possibly sell rust to my employers if we had to go to an outside source for packages like [EDIT: rust/crate currently does, with crates.io]. Being able to host our own mirrors (for CM purposes, if nothing else) is essential.
Definitely like this new approach though.
09/29/2016 04:51 PM 1,746,638 main.exe
09/29/2016 04:51 PM 43 main.rs
1.7Mb for the exe from 43 bytes of code on windows 10. :/AllTheLibs? I'm hoping I can improve on that a bit.
cargo build --releaseWorking through more of it today.
If each 43 bytes you compiled expanded to ANOTHER 1.7mb, then, yeah, that's not good, but that isn't the case here.
The rust generated binary is statically linked and self-contained. It is pretty neat that it takes less than 2MB. In debug mode even, by the looks of it.
If an application wants to be included in the standard install of, say, Ubuntu, one of the biggest costs from the Ubuntu maintainer's point of view is going to be "how much space will this take up on the iso, and what are we going to have to remove if we include this?" If the binaries are very small, it's a lot easier to make the case that they should be included.
The only windows code I have compiled has been FreePascal and that wasn't this crazy.
Similar to what sebcat showed above, I've done a bit of assembly on systems 8bit and up including nasm on linux, so not used to binaries with this sort of baggage. Wasn't trying to paint rust in a negative light, just came as a surprise when I ran that first compile.
$ musl-gcc -static -Os -s -o hello hello.c
$ ls -la hello
-rwxrwxr-x. 1 sebastian sebastian 5344 Sep 30 06:22 hello
$ ldd hello
not a dynamic executable
$ ./hello
Hello, World
384 Byte hello world using NASM and ld on linux/amd64: BITS 64
global _start
%define SYS_write 1
%define SYS_exit 60
%define STDOUT_FILENO 1
section .text
_start:
call after
strHello: db 'Hello, World!',10
lenHello equ $-strHello
after:
pop rsi
mov rdx, lenHello
mov rax, SYS_write
mov rdi, STDOUT_FILENO
syscall
mov rax, SYS_exit
xor rdi, rdi
syscall
Most of the size overhead in the latter example comes from the ELF header, so by paying a bit more attention to the linker scripts, or just inlining a small ELF header with db in the asm file, it would be even smaller.Just for size comparison. I am sure that it's quite possible to generate small Rust binaries as well.
> I am sure that it's quite possible to generate small Rust
> binaries as well.
Indeed, here's a 151-byte hello world[0] in Rust: http://mainisusuallyafunction.blogspot.com/2015/01/151-byte-...As always, I've updated my Docker image for 1.12. Both the "1.12.0" and "latest" tags are now 1.12: https://hub.docker.com/r/jimmycuadra/rust/
Trying it out now.