Skip to content

Commit 09a5c14

Browse files
committed
Libz Blitz draft
1 parent 3df6b8c commit 09a5c14

File tree

1 file changed

+360
-0
lines changed

1 file changed

+360
-0
lines changed

_posts/2017-05-05-libz-blitz.md

Lines changed: 360 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,360 @@
1+
---
2+
layout: post
3+
title: "The Rust Libz Blitz"
4+
author: Brian Anderson, David Tolnay, and Aaron Turon
5+
description: "Improving the quality and maturity of Rust's core ecosystem"
6+
---
7+
8+
To help bring our [2017 vision for Rust] to fruition, the Rust subteams are
9+
launching initiatives targeted at specific roadmap goals. **This post covers the
10+
library team's major initiative: raising a solid core of the Rust crate
11+
ecosystem to a consistent level of completeness and quality.** This work is
12+
guided in part by what we learned in producing the Rust standard library, and
13+
will result in a "cookbook" chock full of ready-made examples for common tasks,
14+
drawing from a careful selection of Rust crates.
15+
16+
[2017 vision for Rust]: https://blog.rust-lang.org/2017/02/06/roadmap.html
17+
18+
## Batteries included?
19+
20+
**You can't be productive in a language without libraries that are easy to find
21+
and use.** Of course, the easiest library to find is the standard library, and
22+
many languages have taken a "batteries included" approach that includes APIs for
23+
a broad set of tasks directly in the standard library. There's a lot of upside
24+
to doing so: it means there's just one place to look for common tasks, with APIs
25+
that (hopefully!) cohere across tasks, compatibility across the ecosystem, and a
26+
promise of library maintenance. What's not to like?
27+
28+
There's a countervailing mindset which, in its harshest terms, says "the
29+
standard library is where code goes to die" (a complaint sometimes heard about
30+
batteries-included standard libraries). Because the standard library is coupled
31+
to the language itself, it is released at the same frequency as the language is,
32+
and making breaking changes means breaking the whole language. For these reasons
33+
and others, standard libraries tend to evolve conservatively.
34+
35+
As usual in the Rust world, our goal is to have our cake and eat it too. **Can
36+
we provide something like a batteries-included experience, without ossifying
37+
that code in the standard library?** This is a particularly vital question for
38+
Rust because, as a community, we are still rapidly exploring and iterating on
39+
best practices for ownership-based API design.
40+
41+
The key ingredient to our approach is [Cargo], the package manager that shipped
42+
with Rust 1.0 and has been improving ever since. Cargo provides a unified
43+
dependency and workflow story across the entire Rust ecosystem, and makes adding
44+
dependencies a painless and relatively low-risk proposition. The ability to
45+
share code with ease is a powerful change to the character of, and audience for,
46+
traditional systems programming tasks.
47+
48+
[Cargo]: https://blog.rust-lang.org/2016/05/05/cargo-pillars.html
49+
50+
Because of Cargo, we can "include batteries" without literally putting them into
51+
the standard library; pulling in other crates is nearly as easy as using the
52+
standard library (and will get even easier this year). But to capitalize on this
53+
ability to the fullest, we need to have excellent libraries. **Our mission for
54+
2017 is to ensure that crates are available for a wide swath of common tasks and
55+
that they are *discoverable*, *cohesive*, *featureful*, and *well-documented*.**
56+
57+
## The Rust Libz Blitz
58+
59+
Fortunately, while the standard library has stayed small and focused, the
60+
crates.io ecosystem has been growing at breakneck pace. So the challenge here
61+
isn't greenfield library work. It's more a question of: **how can the Rust
62+
community work in a focused way to polish, consolidate, and surface a core set
63+
of libraries for essential tasks?** Our answer is the Rust Libz Blitz.
64+
65+
The basic idea is to:
66+
67+
- Collectively review a few crates at a time in a shared forum. The review draws
68+
in part from a set of [API guidelines].
69+
- Every two weeks, hold a library team meeting focused on open questions around
70+
one of these crates, with the author in attendance.
71+
- Push this feedback onto a tracking issue for the crate, and point the Rust
72+
community there to help shoulder the burden of making improvements.
73+
- Write up entries for each crate in a new Rust Cookbook, which will make it
74+
easy to discover the crate and jump into using it.
75+
76+
The Rust library team has been quietly engaging in this process already for the
77+
past couple of months, to sort out the kinks. But now, we want to open it up to
78+
the whole Rust community. In the rest of the post, we'll dive a bit more deeply
79+
into the mechanics and goals of this process.
80+
81+
### Rust standards of quality
82+
83+
In all the work on the standard library, we have gained a sense of what makes
84+
Rust APIs great: principles like "make performance characteristics clear" and
85+
"use ownership to encapsulate invariants"; consistent naming conventions like
86+
`mut`, `ref`, `as`, `into`, that let users intuit what they don't know
87+
from what they do; small details of presentation that add up, like consistently
88+
documentating possible error cases in a dedicated "Errors" section; and so many
89+
more factors to consider when publishing Rust crates.
90+
91+
In 2017 we plan to apply the principles behind the design of `std` to an
92+
ever-widening foundation of critical Rust libraries. Along the way we will
93+
document what we learn about Rust library design.
94+
95+
The product of this process will be a mature core of libraries together with a
96+
set of [API guidelines] that Rust authors can follow to gain insight into the
97+
design of Rust and level up crates of their own interest. Today those guidelines
98+
are in a very early state, but give you a sense of where we are headed with this
99+
effort. Take a look and file issues where things are unclear or missing!
100+
101+
[API guidelines]: https://github.com/brson/rust-api-guidelines
102+
103+
### Rust standards of documentation
104+
105+
We recently ran a small survey to see what Rust programmers care most about when
106+
evaluating a crate. The [most common criterion], by far, was documentation. So
107+
a big part of the Libz Blitz process will be evaluating and improving the
108+
documentation of the targeted crates, which will supplement ongoing efforts to
109+
[rewrite the Rust book] and provide comprehensive [examples] for the standard
110+
library. The API guidelines contain a section dedicated to great documentation,
111+
and we aim for a consistent, easy to navigate docs experience across all of the
112+
core crates.
113+
114+
[most common criterion]: https://github.com/rust-lang/rfcs/blob/master/text/1824-crates.io-default-ranking.md#factors-considered-when-ranking-crates
115+
[rewrite the Rust book]: https://github.com/rust-lang/book/
116+
[examples]: https://github.com/rust-lang/rust/issues/29329
117+
118+
Beyond documentation within the crates themselves (which tends to be more of the
119+
"reference" flavor), we are also starting a [Rust Cookbook], which will be
120+
organized around problems you want to solve, and provide quick, concrete example
121+
code you can drop directly into your project, drawing from a variety of crates
122+
(including the standard library). Examples like these are one of the most useful
123+
tools for quickly getting productive with a library, and collecting them all in
124+
one place, organized by problem, will help get us to a "batteries included"
125+
experience when working with Rust.
126+
127+
Part of the work done in the Libz Blitz for each crate will be identifying the
128+
key problem statements the crate is trying to address, and adding strong
129+
examples for each to the cookbook.
130+
131+
[Rust Cookbook]: https://github.com/brson/rust-cookbook
132+
133+
### Rust standards of discoverability
134+
135+
Perhaps the biggest downside to having a small standard library is the problem
136+
of discoverability: when a Rust programmer needs to take on a task not covered
137+
by the standard library, how do they figure out where to look?
138+
139+
The cookbook mentioned above will undoubtedly become a major part of our
140+
answer. But at the same time, we want to ensure that there's space for new
141+
crates to emerge, and that people can easily find crates beyond the most common
142+
problem areas. To that end, we're attacking discoverability head on, by rolling
143+
out badges for various quality indicators on crates.io, and greatly improving
144+
the default ranking of results (a design debated vigorously through [an
145+
RFC]). There's plenty of room for more work here, so if you have ideas about
146+
further improving discoverability on crates.io, [please start a thread]!
147+
148+
[an RFC]: https://github.com/rust-lang/rfcs/pull/1824
149+
[please start a thread]: https://internals.rust-lang.org/
150+
151+
### Rust standards of community
152+
153+
We have some idea of what goes into publishing exceptional Rust crates, but the
154+
Rust library team is not the sole authority of Rust API design—the Rust crate
155+
ecosystem is created by all of us together and there are many lessons yet to
156+
learn. In recognition of that, **the library team is architecting our efforts to
157+
be as welcoming and inclusive as we can**.
158+
159+
We will kick off forum discussions for evaluating existing crates that we
160+
believe are vital to set on a path toward stability, and which mostly need
161+
polish-level work to get there. These evaluations will be collaborative and
162+
intended for public commentary. They are designed to identify any issues
163+
separating the crate from "1.0" status (in terms of quality and API stability,
164+
as well as literal version number). Issues may include poor adherence to Rust
165+
API design principles, substantial missing functionality, planned API refactors,
166+
incomplete documentation, or any number of unique circumstances.
167+
168+
We'll have a small handful of such evaluations going on in parallel. Every two
169+
weeks, the library crate will take up one of the evaluations for discussion in
170+
our regular video conference, which will be recorded and made accessible on [Air
171+
Mozilla]. One goal of these meetings will be to plan out a roadmap for
172+
stabilizing the crate in question. The other goal will be to identify any
173+
lessons to be learned from the crate and distill those into broadly applicable
174+
API guidelines.
175+
176+
[Air Mozilla]: https://air.mozilla.org/
177+
178+
We will have a rotating band of guests (including the crate authors) at the
179+
video conferences by invitation, in order to strengthen the bonds between the
180+
Rust team and the authors of the Rust ecosystem and to foster shared values
181+
among the same.
182+
183+
Based on the evaluations and library team review, we will file issues that we
184+
believe are important to resolve before producing a stable release of the
185+
crate. **We are counting on many of these issues being amenable to casual
186+
contributions**.
187+
188+
Here are the issues that arose from the very simple [`byteorder`]
189+
crate (all resolved now):
190+
191+
- [x] [Add a supertrait to hide trait details](https://github.com/BurntSushi/byteorder/issues/69)
192+
- [x] [`ByteOrder::default` should `panic!` not `unreachable!`](https://github.com/BurntSushi/byteorder/issues/68)
193+
- [x] [Put panic and error docs in "Panics" and "Errors" sections](https://github.com/BurntSushi/byteorder/issues/72)
194+
- [x] [Make sure there are enough examples](https://github.com/BurntSushi/byteorder/issues/75)
195+
- [x] [Add CI badges to Cargo.toml](https://github.com/BurntSushi/byteorder/issues/74)
196+
- [x] [Add "categories" to Cargo.toml](https://github.com/BurntSushi/byteorder/issues/73)
197+
- [x] [Add `#[doc(html_root_url)]`](https://github.com/BurntSushi/byteorder/issues/77)
198+
199+
Beyond `byteorder` we've already worked this process for several other simple
200+
crates to get a feel for it: [`bitflags`], [`tempdir`], [`flate2`], and
201+
[`lazy_static`]. Even these, the most basic of crates, have some work left to do
202+
but you can expect them to have "1.0" releases soon. As the crates under
203+
evaluation grow in scope, presumably the tasks that arise will grow as well.
204+
205+
[`bitflags`]: https://github.com/rust-lang-nursery/bitflags
206+
[`tempdir`]: https://doc.rust-lang.org/tempdir/tempdir/index.html
207+
[`flate2`]: https://docs.rs/flate2
208+
[`lazy_static`]: https://docs.rs/lazy_static
209+
210+
211+
### What crates are we going to focus on?
212+
213+
Rust has some amazing libraries in the works: things like [`tokio`]
214+
which is a really fast asynchronous I/O framework; like [`diesel`], a
215+
really fast library for interacting with database tables; and like
216+
[`rocket`], a really fast web framework.
217+
218+
[`tokio`]: https://tokio.rs/
219+
[`diesel`]: https://diesel.rs/
220+
[`rocket`]: https://rocket.rs/
221+
222+
We are not going to be touching them.
223+
224+
These high-profile libraries are built on **dozens of smaller crates that
225+
perform crucial functions across the ecosystem**: random number generation,
226+
memory mapping, compression, and so much more. We need to polish off the lower
227+
layers of the Rust stack so that those high-level libraries have a stable
228+
foundation to build on.
229+
230+
Focusing on these lower layers is not only a practical consideration but a
231+
technical one—a crate should not be stable until its public dependencies are
232+
stable. Consider what it would mean for a hypothetical [`diesel`] 1.0 to export
233+
a function returning a type from a still-rapidly-developed [`uuid`] 0.5. Before
234+
long it would be incompatible with other libraries using newer versions of
235+
`uuid`.
236+
237+
[`uuid`]: https://doc.rust-lang.org/uuid/uuid/index.html
238+
239+
Furthermore, many of these high-level libraries are very much undergoing their
240+
own rapid development, with their own strong leadership. We don't want to impose
241+
on those crates' authors' abilities to experiment with their designs by
242+
pressuring them to declare crates stable before they are ready. Those libraries
243+
will mature in time.
244+
245+
But there are many foundational libraries that have reached relative stability,
246+
and are in some cases functionally complete and being widely used in
247+
production. Some need little work to put them across the finish line. Some, like
248+
the [`rand`] crate, are widely used but known to have unsatisfactory designs. We
249+
want to finally put those crates to bed.
250+
251+
[`rand`]: https://doc.rust-lang.org/rand/rand/index.html
252+
253+
We are currently drawing this list of foundational crates by combining crates.io
254+
dependency data, various existing curated crate listings, and good old gut
255+
feeling. The exact list is definitely up for debate, and we hope that the
256+
broader community will also apply this process completely independently to
257+
crates the libs team won't have time to discuss.
258+
259+
### How to help
260+
261+
We're glad you asked! Creating a solid core of libraries for a young
262+
language is not the work of a single person or team—it is the work of
263+
the entire community. The central point of coordination is a [thread
264+
on the Rust internals forum]. Read that thread for all the dirty
265+
details about what we're doing, and for ongoing opportunities to get
266+
involved.
267+
268+
[thread on the Rust internals forum]: TODO
269+
270+
Roles that need your help:
271+
272+
- **Crate lead**. Each crate needs a volunteer to lead the evaluation
273+
effort. That entails starting up a thread, breaking up the evaluation work
274+
into small work items that can be taken on by others in the community, keeping
275+
the discussion moving in productive directions, making sure the evaluation is
276+
completed on time, and finally, presenting the results at the libs team meeting.
277+
278+
*Anyone can be a crate lead, but it's a substantial commitment and is largely
279+
about organization, communication, and consensus, and requires presenting to
280+
the libs team in a video meeting.*
281+
282+
- **Crate evaluator**. This is the preliminary work of comparing a crate to the
283+
API guidelines, identifying deficiencies, and raising observations about API
284+
design that may impact the guidelines. It will often require working with the
285+
crate author to understand a crate's known shortcomings.
286+
287+
Each evaluation will be published to the coordination thread, providing an
288+
opportunity for general feedback. Open feedback allows for a wide range of
289+
voices to be heard and is an important check against design myopia.
290+
291+
*This effort is collaborative and everyone is welcome to participate in this
292+
way at any time. The crate lead will help create opportunities to jump in.*
293+
294+
- **Documentation slinger**. A lot of the work involved in getting a crate up to
295+
full quality is improving documentation, including writing up cookbook entries.
296+
There will be lots of opportunities for this kind of high value work.
297+
298+
*Everyone is welcome to participate in this way at any time. The crate lead will help create opportunities to jump in.*
299+
300+
- **Library hacker**. Somebody must do the programming work of resolving the
301+
issues on the roadmap to stability for each crate. We expect to produce many
302+
discrete work items and that many of them will be accessible to inexperienced
303+
Rust programmers.
304+
305+
*Everyone is welcome to participate in this way at any time. The crate lead
306+
will help create opportunities to jump in.*
307+
308+
- **Library designer**. There remain some important libraries that are only
309+
lightly maintained but are known to require significant design work (again
310+
thinking of [`rand`] especially). These will not improve without a dedicated
311+
and skilled author to drive them forward. We are going to be looking out for
312+
authors with the design skills necessary to fix the problems, and the social
313+
skills necessary to navigate the process.
314+
315+
*We will occasionally make pleas for help on specific design matters as they
316+
arise.*
317+
318+
- **Libs team guest**. The library team will spend one of their video meetings
319+
reviewing each crate evaluation. We hope that the crate authors will be
320+
interested in joining us, sharing their unique expertise, and getting to know
321+
the libs team. This kind of interaction creates strong bonds in a way that
322+
communicating through text does not. We hope this will foster shared values
323+
across the ecosystem, and pave the way for expanding the libs team more
324+
formally.
325+
326+
*This will be by invitation and focused on authors with an existing reputation
327+
for high quality work and productive collaboration.*
328+
329+
- **Crate author**. The libs team has some specific functionality and crates it
330+
wants to focus on this year. Outside of that, we are hopeful that the process
331+
and guidelines we develop will be widely useful and that crate authors will
332+
independently seek to evaluate and improve their own crates in similar ways.
333+
334+
## The TL;DR
335+
336+
Here's the plan:
337+
338+
- We will directly improve the most important crates you use every
339+
day.
340+
- We will provide crate authors the guidance they need to do the same,
341+
in the form of **[API guidelines]**.
342+
- We will create an endless stream of accessible contribution
343+
opportunities that directly contribute to key Rust strategic goals.
344+
- We will produce cohesive documentation on how to use Rust's most
345+
foundational crates, in the form of a **[crate cookbook]**.
346+
- We will launch a self-sustaining process of library improvement that
347+
can by applied consistently across the entire ecosystem.
348+
349+
Come help us make this happen!
350+
351+
[crate cookbook]: https://brson.github.io/rust-cookbook/
352+
353+
[regex]: http://blog.burntsushi.net/ripgrep/
354+
[webrender]: https://air.mozilla.org/bay-area-rust-meetup-february-2016/
355+
[`memmap`]: https://github.com/danburkert/memmap-rs
356+
[`tempdir`]: https://doc.rust-lang.org/tempdir/tempdir/index.html
357+
[`fs2`]: https://github.com/danburkert/fs2-rs
358+
[`byteorder`]: https://docs.rs/byteorder
359+
[`iron`]: http://ironframework.io/doc/iron/
360+
[`diesel`]: https://diesel.rs/

0 commit comments

Comments
 (0)