Skip to content

Commit 5e6f946

Browse files
authored
Merge pull request #164 from brson/libs
Libz blitz
2 parents 84f549d + 87c1e61 commit 5e6f946

File tree

1 file changed

+361
-0
lines changed

1 file changed

+361
-0
lines changed

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

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

0 commit comments

Comments
 (0)