Skip to content

Commit 7f35376

Browse files
committed
Initial sketch: the next year of Rust
1 parent 2da0974 commit 7f35376

File tree

1 file changed

+158
-0
lines changed

1 file changed

+158
-0
lines changed

_posts/2015-08-13-Next-year.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
---
2+
layout: post
3+
title: "The next year of Rust"
4+
author: Nicholas Matsakis and Aaron Turon
5+
description: "Our vision for Rust in 2016."
6+
---
7+
8+
It's now been 12 weeks since the release of Rust 1.0, and we'd like to take this
9+
opportunity to **talk a bit about what 1.0 meant in hindsight, and where Rust is
10+
going in the next year**.
11+
12+
### The next year of Rust
13+
14+
> We recently held the first-ever Rust conference, [RustCamp][rustcamp] 2015,
15+
which sold out with 160 attendees. It was amazing to see so much of the Rust
16+
community in person, and to see the vibe of our online spaces translate into a
17+
friendly and approachable meatspace event. The day opened with a keynote from
18+
Nicholas Matsakis and Aaron Turon laying out the core team's view of where we
19+
are and where we're headed. The
20+
[slides are available online](http://rustcamp.com/RustCampKeynote.pdf), but this
21+
post serves as the missing soundtrack.
22+
23+
[rustcamp]: http://rustcamp.com/
24+
25+
#### What 1.0 was about
26+
27+
In hindsight, Rust 1.0 was about nailing down three key concerns: clarity,
28+
stability, and community. Stability, we've discussed quite a bit in
29+
[previous posts][deliverable]. And, of course, community has always been one of
30+
Rust's greatest strengths. But in the year leading up to 1.0 in particular, we
31+
introduced and refined the [RFC process][rfcs], culminating with
32+
[subteams][subteams] to manage RFCs in each particular area. Community-wide
33+
debate on RFCs was indispensable for delivering a quality 1.0 release.
34+
35+
All of this refinement prior to 1.0 was in service of clarifying what Rust
36+
represents:
37+
38+
- Memory safety without garbage collection
39+
- [Concurrency without data races][fearless]
40+
- [Abstraction without overhead][traits]
41+
- [Stability without stagnation][deliverable]
42+
43+
Altogether, **Rust is exciting because it is empowering: you can hack without
44+
fear**. And you can do so in contexts you might not have before, dropping down
45+
from Ruby or Python, making your first foray into systems programming.
46+
47+
That's Rust 1.0; what's next?
48+
49+
[deliverable]: http://blog.rust-lang.org/2014/10/30/Stability.html
50+
[rfcs]: https://github.com/rust-lang/rfcs#when-you-need-to-follow-this-process
51+
[subteams]: https://github.com/rust-lang/rfcs/pull/1068
52+
[fearless]: http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html
53+
[traits]: http://blog.rust-lang.org/2015/05/11/traits.html
54+
55+
#### Where we go from here
56+
57+
After much discussion within the core team and with the broader community, we've
58+
identified a number of improvements we'd like to make over the course of the
59+
next or so, falling into three broad categories:
60+
61+
- Doubling down on infrastructure;
62+
- Zeroing in on gaps in key features;
63+
- Branching out into new places to use Rust.
64+
65+
Let's look at some of the biggest plans in each of these categories.
66+
67+
#### Doubling down: infrastructure investments
68+
69+
**Crater**.
70+
71+
**Incremental compilation**. [MIR][mir]
72+
73+
[mir]: https://github.com/rust-lang/rfcs/pull/1211
74+
75+
**IDE integration**.
76+
77+
#### Zeroing in: closing key gaps in our features
78+
79+
**Specialization**. The idea of zero-cost abstractions breaks down into two
80+
separate goals, as identified by Stroustrup:
81+
82+
- What you don't use, you don't pay for.
83+
- What you do use, you couldn't hand code any better.
84+
85+
Rust 1.0 has essentially achieved the first goal, both in terms of language
86+
features and the standard library. But it doesn't quite manage to achieve the
87+
second goal. Take the following trait, for example:
88+
89+
~~~~rust
90+
pub trait Extend<A> {
91+
fn extend<T>(&mut self, iterable: T) where T: IntoIterator<Item=A>;
92+
}
93+
~~~~
94+
95+
The `Extend` trait provides a nice abstraction for insert data from any kind of
96+
iterator into a collection. But with traits today, that also means that each
97+
collection can provide only one implementation that works for *all* iterator
98+
types, which requires actually calling `.next()` repeatedly. In some cases, you
99+
could hand code it better, e.g. by just calling `memcpy`.
100+
101+
To close this gap, we've proposed [specialization][specialization], allowing you
102+
to provide multiple, overlapping trait implementations as long as one is clearly
103+
more specific than the other. Aside from giving Rust a more complete toolkit for
104+
zero-cost abstraction, specialization also improves its story for code
105+
reuse. See [the RFC][specialization] for more details.
106+
107+
[specialization]: https://github.com/rust-lang/rfcs/pull/1210
108+
109+
**Borrow checker improvements**. The borrow checker is, in a way, the beating
110+
heart of Rust; it's the part of the compiler that lets us achieve memory safety
111+
without garbage collection, by catching use-after-free bugs and the like. But
112+
occasionally, the borrower checker also "catches" non-bugs, like the following
113+
pattern:
114+
115+
~~~~rust
116+
match map.find(&key) {
117+
Some(...) => { ... }
118+
None => {
119+
map.insert(key, new_value);
120+
}
121+
}
122+
~~~~
123+
124+
Code like the above snippet is perfectly fine, but the borrow checker struggles
125+
with it today because the `map` variable is borrowed for the entire body of the
126+
`match`, preventing it from being mutated by `insert`. We plan to address this
127+
shortcoming soon by refactoring the borrow checker to view code in terms of
128+
finer-grained ("non-lexical") regions -- a step made possible by the move to the
129+
MIR mentioned above.
130+
131+
**Plugins**. There are some really neat things you can do in Rust today -- if
132+
you're willing to use the Nightly channel. For example, the [regex crate][regex]
133+
comes with macros that, at compile time, turn regular expressions directly into
134+
machine code to match them. Or the [rust-postgres-macros crage][postgres], which
135+
checks at compile time for valid SQL syntax. Crates like these and others make
136+
use of a highly-unstable compiler plugin system that currently exposes far too
137+
many compiler internals. We plan in the next couple of months to propose a new,
138+
robust design that closes these holes and provides good support for hygienic
139+
macro expansion as well.
140+
141+
[regex]: https://github.com/rust-lang/regex
142+
[postgres]: https://github.com/sfackler/rust-postgres-macros
143+
144+
#### Branching out: taking Rust to new places
145+
146+
**Cross-compilation**.
147+
148+
**Cargo install**. [RFC][cargoinstall]
149+
150+
[cargoinstall]: https://github.com/rust-lang/rfcs/pull/1200
151+
152+
**Tracing hooks**. One of the most promising way of using Rust is by "embedding"
153+
Rust code into systems written in higher-level languages like [Ruby][skylight]
154+
or Python. This embedding is usually done by giving the Rust code a C API, and
155+
works reasonably well when the target sports a "C friendly" memory management
156+
scheme like reference counting or conservative GC.
157+
158+
[skylight]: http://blog.skylight.io/bending-the-curve-writing-safe-fast-native-gems-with-rust/

0 commit comments

Comments
 (0)