Rust 1.5
blog.rust-lang.org
blog.rust-lang.org
I recently wrote my first Rust [1] project. Great experience, IMO. I faced a lot of interesting challenges because my use case was a little outside of typical. But I tried to minimize 'unsafe' and I was still satisfied with the results so far.
I know I've only just scratched the surface of the language and I'm looking forward to learning more.
ElectricFence is similar but focusing on out-of-bounds memory accesses. Actually, that's not really fault injection, more like sanitizing bad behavior.
There's other fault injection stuff for linux, usually at different layers (I've seen some that use systemtap, e.g.).
I opened an issue [1]. I'll get on it.
I love Rust and am using it more and more. I'm very excited for 'cargo watch'. These tools built into the package manager will be so helpful with peoples' first time Rust experience. I think I'm going to say it, Rust has my favorite package management system of any language I've used.
Side Note: I'm also a fan of the 6 week release assembly line Rust has going on. I'm glad that it's staying consistent.
What are your thoughts on this? Have things changed? Is the assumption just dead wrong, and Rust is in fact tremendous for web application development?
Add JS to that list as well, because I've done a little bit of work in Node, but that was before Coroutines (back in the days of yore when "callback hell" was a thing), so I wasn't nearly as excited at the time as I probably would be now.
Edit: According to Steve Klabnik in his comment below, it is not up-to-date.
I have a deamon running that does a specific reverse proxy thing. I wrote it in Rust, and that has been a very pleasant experience. For example, the excellent support for serialization and deserialization makes working with JSON a breeze :)
Here's a random fact that I've always found interesting: https://crates.io/ uses Rust on the server. It links to libgit, it does a lot of stuff. It uses about 30 megs of memory, resident, at all times. Coming from Rails, that's... shocking.
I'm working on a new project now where my web server will be Node, however much of my api and micro services/jobs will be in Rust. I expect it to go well, we'll see.
2: https://github.com/runarberg/theremins
I'm open to other ideas too, but that seemed like the simplest way to get the error handling out of the way.
Ordinarily I try hard not to complain about syntax, but this seems to cause people to use .unwrap() where it's not safe (like a library).
TL;DR: we're still adjusting process a bit, but the idea is that this is "good enough" to actually land, behind a feature gate, to start gaining experience. We still reserve the right to tweak it before it goes stable, but it's better to get it into people's hands, rather than continue to debate the last few minor points.
I'm quite pleased by the current solution and am not such a big fan of "?".
If you want real do, and I do, then you need HKT, which is a massive upgrade to our type system that will take a very long time. If we can do something simpler in the meantime to ease some pain, then it's worth it.
Very happy to see the tooling improvements, though. Great work!
https://github.com/sanxiyn/sandbox/blob/master/rust/time-2.p...
crates.io backend service:
# Note the thing pulls down lots of dependencies doing
# install, so this is after a "cargo build;cargo clean":
git clone git@github.com:rust-lang/crates.io.git crates.io.git
cd crates.io.git/
./script/init-local-index.sh
multirust run nightly cargo build --release
multirust run nightly cargo clean
# 4 threads, ~100% CPU up to compiling the final cargo.io bit,
# which takes the longest:
git diff
diff --git a/Cargo.toml b/Cargo.toml
index cf99b60..02e54fb 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,7 @@ version = "0.1.0"
[profile.release]
opt-level = 2
+codegen-units = 4
[lib]
name = "cargo_registry"
$ time multirust run nightly cargo build --release
real 1m29.082s
user 4m47.276s
sys 0m6.196s
# Single threades (default Cargo.toml):
real 1m41.210s
user 4m0.376s
sys 0m5.120s
Servo: git clone https://github.com/servo/servo servo.git
cd servo.git/
./mach build --release
(Servo also pulls down lots of dependencies, including a full rust
toolchain...) ./mach clean
time ./mach build --release
Build completed in 791.07s
real 13m11.874s
user 40m21.468s
sys 0m51.304s
At approximately 100% cpu for the first part, either the servo build
script makes sure things are parallelized, or the Cargo.toml-settings
are set for parallell builds (haven't checked).And finally, a smaller project:
git clone https://github.com/Aaronepower/tokei.git
cd tokei/
cargo build --release
cargo clean
$ time cargo build --release
real 0m30.354s
user 0m32.708s
sys 0m0.444s
According to tokei (which is a blazingly fast cloc tool), there's ~100k
cloc of rust in servo, ~7500 cloc of Rust in crates.io (but that doesn't
include all the dependencies...).After doing a clean install of rust stable with multirust, the combined cloc of stuff under ~/.multirust...cargo/src and tokei is ~11.5k cloc of rust, along with ~ 1400 cloc of c++.
That doesn't mean the _discussion_ about how it works has to stop in the meantime, though...
I've been following Rust from sidelines before 1.0 and from my perspective there are advantages but I can also see a lot of pain in porting stuff and moving over and I right now the benefits don't outweigh the risk and cost for me - but having a fast build system (which implies incremental recompilation) along with a default package manager (which it already has) would be enough for me to start working with it seriously.
It's kind of sad that building code is such an instrumental part of developing C++ when it's just about dealing with technical issues of the compiler/language/tools and not the problems I'm trying to solve - anything that gets me away from that while leaving me with similar level of memory control and portability is a big win for me.
So when should I be looking back at it ? 6 months ?
However, there's also something mentioned in this announcement: cargo-check. In terms of the "I'm building a project and I don't want my builds to be slow," I think that cargo-check might even be more important. cargo-check relies on an important insight: many times, when you're compiling, you don't actually care about producing a binary, you care that your code passes typechecking and other passes. cargo-check basically runs those things, and doesn't produce the final binary. Makes sense?
On top of that they have the financial backing of apple.
I got the impression that Linux support is more of a "here iOS/OSX develoeprs - we're aware you don't actually run OSX on your servers so you can share code between client and server now". I was not aware Apple wants to push Swift as a cross platform language.
If it was and their commitment looked credible (ie. they start porting tools like integrating debuggers and stuff on other platforms as well) I would definitely consider it.
So, the basic process of compiling is:
source -> AST -> LLVM IR -> asm
At each step, you can do transforms too, so like, LLVM will take in LLVM IR, but before compiling, will simplify/transform it into other IR.There's a few issues with this. The first is that any processing we want to do, like optimizations, safety checks, etc, has to work on the AST. This means that when the AST changes, these features need to change. This is why compiler plugins aren't stable, we're not ready to stabilize the AST yet. Doing so would mean things like "we can never add a new keyword", or at least, makes that process harder.
The final process for Rust will look like
source -> AST -> HIR -> MIR -> LLVM IR -> asm
HIR is "higher IR" and MIR is "mid IR". In this sense, LLVM IR is a "low IR". There's two important aspects here: the first is that this decouples the AST from things like plugins, which can operate on the HIR, which we will stabilize. The second is that at each step, things get simpler. Here's an example. We have both regular old if statements, and match, which can do more powerful, structural things. Both are fundamentally jump statements, though, and so we can transform the more complex match into the more primitive if. This means that by writing safety checks, optimizations, and other things against MIR, they're both easier to write, as well as more maintainable.There's one other minor benefit: Someone who wants to write an alternate compiler could theoretically write MIR -> ASM, and eliminate LLVM entirely. While we have less than zero percent chance of doing that ourselves, it might be nice if you want to support some sort of esoteric platform LLVM doesn't, for example.
Does that all make sense?
Typecheck happens early, with borrow-checking following soon after, so you get feedback on errors fast, and thus only end up waiting when the compiler is happy with your code. Still, it may be an issue for people who like to do TDD or need to do a lot of run-time verification.
For a big project you'd probably need to split it up into multiple crates to "emulate" incremental compilation, at least until it is supported by the build system.
What is the clean way to upgrade to 1.5 ? I don't think there is some kind of 'rustup.sh upgrade' Delete 1.4 & reinstall ? Or downloading rustup 1.5 will apply a clean install on the existing one ?
Generally speaking, installation is something we're working on: working with Linux package maintainers, rolling rustup and multirust together and making them work well cross-platform, etc.
Or is this it? https://hub.docker.com/r/jimmycuadra/rust/
Container images are great for daemons with possibly complicated dependency sets that might have conflicting version requirements with other packages and can benefit from isolation from other packages that containerization gives, but seem like a pretty heavyweight solution for just installing a compiler.
What I'm not seeing is the value of a Docker image. Rust doesn't have much in the way of runtime dependencies, which is where the value of a container generally comes in. I don't know of a platform where Docker image would work but rustup.sh would not.
Packages are of course preferable if available and up-to-date.
- It is common for languages to have official Docker images (Java, Ruby, Python, Go, Erlang, Haskell, Julia, etc)
- In August the install process didn't work on my Debian system, eventually got guidance for workarounds from IRC
- Our build farm is docker based, application deployment environment is docker based
- Ensures development environments are identical
- Solves the multiple compiler issue
As much as I use Docker, it'd be tough for me to call it heavyweight. In terms of resource consumption Docker is just a neat wrapper over some functionality that is built in to the kernel, there is no "vm" of any sort, which is a common misconception.
$ multirust update
$ multirust show-default
multirust: default toolchain: stable
multirust: default location: (...)
rustc 1.5.0 (3d7cd77e4 2015-12-04)
cargo 0.6.0-nightly (e1ed995 2015-10-22)
$ multirust list-toolchains
beta
nightly
stable
$ du -hs ~/.multirust/
996M /home/e12e/.multirust/Never heard of programming but you still want to compile a project?
Step 1: run rustup.sh (curl -sSf https://static.rust-lang.org/rustup.sh | sh)
Step 2: clone the repo of the project or your regional equivalent
Step 3: cargo build --release (or now with the new cargo install feature, cargo install)
Step 4: Enjoy
https://github.com/Homebrew/homebrew/blob/master/Library/For...
It is 1.4 as I've brewed rust few minutes ago.
And you get the point, don't need to picky on the specifics.
https://github.com/Homebrew/homebrew/commit/dee292132fb73820...
From http://blog.golang.org/go12, "This new release comes nearly seven months after the release of Go 1.1 in May. We anticipate a comparable interval between future major releases." Go 1.3 and 1.4 took six months, 1.5 eight months.