Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit 939292f

Browse files
committed
new RFC: 2019 Roadmap!
1 parent 57b1dbf commit 939292f

File tree

1 file changed

+336
-0
lines changed

1 file changed

+336
-0
lines changed

text/000-2019-roadmap.md

Lines changed: 336 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
- Start Date: 2019-01-23
2+
- RFC PR: (leave this empty)
3+
4+
# Summary
5+
6+
<!-- One paragraph explanation of the proposal. -->
7+
8+
**2019 is the year WebAssembly with Rust goes from "usable" to "stable,
9+
batteries-available, and production-ready."**
10+
11+
To realize this goal, the Rust and WebAssembly domain working group will:
12+
13+
* Cultivate a library ecosystem by collaborating on a modular toolkit
14+
15+
* Bring multithreading to Rust-generated Wasm
16+
17+
* Integrate best-in-class debugging support into our toolchain
18+
19+
* Polish our toolchain and developer workflow, culminating in a 1.0 version of
20+
`wasm-pack`
21+
22+
# Motivation
23+
24+
<!-- Why are we doing this? What use cases does it support? What problems does it -->
25+
<!-- solve? What is the expected outcome? -->
26+
27+
This proposed roadmap draws upon
28+
29+
* [the community's blog posts][rustwasm2019-issue] in response to the working
30+
group's [call for roadmap suggestions,][rustwasm2019-call]
31+
32+
* and the working group's core team's intuition and experience.
33+
34+
[rustwasm2019-issue]: https://github.com/rustwasm/team/issues/241
35+
[rustwasm2019-call]: https://rustwasm.github.io/2018/12/06/reflecting-on-rust-and-wasm-in-2018.html#rustwasm2019
36+
37+
# Detailed Explanation
38+
39+
## Collaborating on a Modular Toolkit
40+
41+
> The idea of building [high-level libraries] in a modular way that will allow
42+
> others in the community to put the components together in a different way is
43+
> very exciting to me. This hopefully will make the ecosystem as a whole much
44+
> stronger.
45+
>
46+
> In particular I’d love to see a modular effort towards implementing a virtual
47+
> DOM library with JSX like syntax. There have been several efforts on this
48+
> front but all have seemed relatively monolithic and “batteries included”. I
49+
> hope this will change in 2019.
50+
51+
<cite>&mdash; Ryan Levick in [Rust WebAssembly
52+
2019](https://blog.ryanlevick.com/posts/rust-wasm-2019/)</cite>
53+
54+
> Don't create branded silos. Branding might perhaps be useful to achieve
55+
> fame. But if we truly want Rust's Wasm story to succeed we should think of
56+
> ways to collaborate instead of carving out territory.
57+
58+
<cite>&mdash; Yoshua Wuyts in [Wasm
59+
2019](https://blog.yoshuawuyts.com/wasm-2019/)</cite>
60+
61+
In 2018, we created foundational libraries like [`js-sys` and
62+
`web-sys`][announcing-web-sys]. In 2019, we should build modular, high-level
63+
libraries on top of them, and collect the libraries under an umbrella toolkit
64+
crate for a holistic experience. This toolkit and its libraries will make
65+
available all the batteries you want when targeting Wasm.
66+
67+
Building a greenfield Web application? Use the whole toolkit to hit the ground
68+
running. Carefully crafting a tiny Wasm module and integrating it back into an
69+
existing JavaScript project? Grab that one targeted library you need out from
70+
the toolkit and use it by itself.
71+
72+
* **Modular:** Take or leave any individual component. Prefer interfaces over
73+
implementations.
74+
75+
* **Cultivate collaboration:** We've already seen an ecosystem sprouting up in
76+
the Rust and WebAssembly domain, and lots of great experiments, but we haven't
77+
seen a lot of collaboration between projects. By deliberately creating a space
78+
for collaboration, we can reduce effort duplication, multiply impact, and help
79+
the ecosystem stay healthy.
80+
81+
[announcing-web-sys]: https://rustwasm.github.io/2018/09/26/announcing-web-sys.html
82+
83+
## Multithreading for Wasm
84+
85+
> We must bring Rust’s [fearless
86+
> concurrency](https://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html)
87+
> to the Web!
88+
89+
<cite>&mdash; Nick Fitzgerald in [Rust and WebAssembly in
90+
2019](http://fitzgeraldnick.com/2018/12/14/rust-and-webassembly-in-2019.html)</cite>
91+
92+
> Be the absolute cutting edge when it comes to WebAssembly, we should be
93+
> thinking about being the first to satisfy [threads and atomics].
94+
95+
<cite>&mdash; richardanaya in [My Rust 2019
96+
Dream](https://www.reddit.com/r/rust/comments/aac8zk/my_rust_2019_dream_dominate_the_web/)</cite>
97+
98+
Out toolchain already has [experimental support for multithreading in
99+
Wasm][multithreading]. Browsers are currently shipping `SharedArrayBuffer` and
100+
atomics (the primitives of multithreading for Wasm) behind feature flags, and
101+
they expect to start shipping them enabled by default in 2019.
102+
103+
One of WebAssembly's selling points is the ability to effectively utilize
104+
available hardware. Multithreading extends that story from a single core to
105+
many. While multithreading will be *literally possible* for both JavaScript and
106+
any compiled-to-Wasm language, Rust's unique ownership system makes it
107+
*economically realistic*.
108+
109+
There are some technical snags (see the link above for details) that mean we
110+
can't get Rust's standard library's `std::thread::*` working on Wasm. But it is
111+
still crucial that we have shared implementations of core multithreading
112+
building blocks like thread pools and locks across the ecosystem. In 2019, we
113+
should transform our experimental multithreading support into a production-ready
114+
foundation for multithreading on Wasm, get popular crates like `rayon` working
115+
on the Web, and cash in on Rust's fearless concurrency.
116+
117+
[multithreading]: https://rustwasm.github.io/2018/10/24/multithreading-rust-and-wasm.html
118+
119+
## Debugging
120+
121+
> Before [debugging] is working properly (including variable inspection, which
122+
> doesn't work with wasm at all right now), everything else is just toying
123+
> around.
124+
125+
<cite>&mdash; anlumo in [a comment on
126+
r/rust](https://www.reddit.com/r/rust/comments/aac8zk/my_rust_2019_dream_dominate_the_web/ecqu3wu/)</cite>
127+
128+
> Having [source maps] would be excellent for debugging.
129+
130+
<cite>&mdash; Yoshua Wuyts in [Wasm 2019](https://blog.yoshuawuyts.com/wasm-2019/)
131+
132+
Debugging is tricky because much of the story is out of this working group's
133+
hands, and depends on both the WebAssembly standardization bodies and the folks
134+
implementing browser developer tools instead. However, there are some concrete
135+
steps we can take to improve debugging:
136+
137+
1. Get `println!`, `dbg!`, and friends working out of the box with Wasm. To
138+
achieve this, we will build support for the [WebAssembly reference
139+
sysroot][sysroot] and standard system calls for Wasm that are in the
140+
standardization pipeline.
141+
142+
2. Create the ability to compile our Rust-generated Wasm to JavaScript with
143+
source maps when debugging. Source maps are a limited debug info format for
144+
JavaScript that enable stepping through source locations in a debugger,
145+
instead of stepping through compiler-generated JavaScript code.
146+
147+
3. Add debugging-focused tracing and instrumentation features to our
148+
toolchain. For example, it is currently difficult to debug a JavaScript array
149+
buffer view of Wasm memory getting detached because Wasm memory was
150+
resized. We can make debugging easier by optionally instrumenting `mem.grow`
151+
instructions with logging.
152+
153+
In addition to that, we should work with the WebAssembly standardization bodies
154+
and browser developer tools makers, and actively participate in the WebAssembly
155+
debugging subcharter to create some movement in the debugging space. By keeping
156+
up the environmental and social pressure and lending a hand where we can, we
157+
will eventually have rich, source-level debugging for Wasm.
158+
159+
[sysroot]: https://github.com/WebAssembly/reference-sysroot
160+
161+
## Toolchain and Workflow Polish
162+
163+
> Setting up a Wasm project requires quite some boilerplate. It'd be nice if we
164+
> could find ways to reduce this.
165+
166+
<cite>&mdash; Yoshua Wuyts in [Wasm
167+
2019](https://blog.yoshuawuyts.com/wasm-2019/)</cite>
168+
169+
> There are a few things that we intended to include in `wasm-pack` in 2018 that
170+
> didn’t quite make the cut. [...] We should finish these tasks and polish
171+
> `wasm-pack` into a 1.0 tool.
172+
173+
<cite>&mdash; Nick Fitzgerald in [Rust and WebAssembly in
174+
2019](http://fitzgeraldnick.com/2018/12/14/rust-and-webassembly-in-2019.html)</cite>
175+
176+
In 2019, our toolchain and workflow should feature complete and
177+
polished. `wasm-pack`, being the entry point to our toolchain, will bear the
178+
brunt of this work, but much of it will also be in tools that are invoked by
179+
`wasm-pack` rather than work in `wasm-pack` itself.
180+
181+
* Generate JavaScript API documentation from the Rust doc comments on
182+
`#[wasm_bindgen]` exports.
183+
184+
* Finish and implement the RFC for library crates depending on external NPM
185+
packages. TODO link
186+
187+
* Finish and implement the RFC for local JavaScript snippets. TODO link
188+
189+
* Support running Binaryen's `wasm-opt` on Rust-generated Wasm. TODO link
190+
191+
* Integrate `cargo generate` for new project scaffolding. TODO: one less tool
192+
193+
* RFC and implementation for generating portable, universal NPM packages that
194+
work on the Web, with Node.js, and in any minimal JavaScript environment.
195+
196+
* Define a philosophy for `wasm-pack`'s user experience, interaction, and
197+
display. Once defined and agreed upon, we should triage each `wasm-pack`
198+
subcommand and ensure that it is consistent with our philosophy.
199+
200+
Given that this work is largely about plugging missing holes and improving user
201+
experience, it is a bit of a laundry list. But that is also good sign: it means
202+
that `wasm-pack` is actually fairly close to being feature complete.
203+
204+
After we've finished all these tasks, we should publish a 1.0 release of
205+
`wasm-pack`.
206+
207+
# Rationale, Drawbacks, and Alternatives
208+
209+
<!-- This is your chance to discuss your proposal in the context of the whole design -->
210+
<!-- space. This is probably the most important section! -->
211+
<!-- - Why is this design the best in the space of possible designs? -->
212+
<!-- - What other designs have been considered and what is the rationale for not -->
213+
<!-- choosing them? -->
214+
<!-- - What is the impact of not doing this? -->
215+
216+
We choose to focus our efforts in 2019 where:
217+
218+
1. *We* &mdash; the Rust and WebAssembly working group &mdash; can build and
219+
ship features. Areas where we aren't potentially blocked by external factors,
220+
such as still-in-progress standards.
221+
222+
2. We can leverage advantages that are *unique to Rust* in the WebAssembly
223+
domain.
224+
225+
## Things *We* can Build and Ship
226+
227+
We don't want our fate in anyone's hands but our own.
228+
229+
The toolkit and toolchain polish work don't involve any external entities that
230+
could slow our progress to a halt. For debugging, where the larger story
231+
involves significant consensus with external groups and standards work, we
232+
explicitly choose to focus on what we can do ourselves to improve our own
233+
debugging story. We do not set ourselves up to block on anything produced by the
234+
WebAssembly community group's debugging subcharter, and we won't wait on browser
235+
vendors to implement new Wasm debugging support in developer tools.
236+
237+
Of the roadmap items, the multithreading story has the most risk: our success in
238+
this domain relies on browsers enabling Wasm's multithreading primitives by
239+
default. However, this seems like a relatively safe bet, since the
240+
multithreading primitives have moved past their most experimental phase, [Chrome
241+
is already shipping them enabled by default, and all other major browsers have
242+
implementations that just aren't enabled by default yet.][sab-caniuse]
243+
244+
[sab-caniuse]: https://caniuse.com/#feat=sharedarraybuffer
245+
246+
## Leveraging Unique Advantages
247+
248+
We want to focus our efforts where we get the biggest effort to impact
249+
efficiency, and establish ourselves as leaders in WebAssembly in ways that no
250+
one else even has a route towards catching up.
251+
252+
The multithreading story is perhaps the biggest example of unique advantage:
253+
multithreading is *infamously* bug prone (to say the least!) and Rust's
254+
ownership system eliminates data races at compile time.
255+
256+
By building a modular toolkit of libraries, we bolster our ability to target the
257+
full spectrum from tiny module surgically inserted into an existing JavaScript
258+
application, to building a complete Web application in Rust. Any language that
259+
relies on a garbage collector, fat runtime, or is overly opinionated about FFI
260+
and interaction with the outside world can't reach the tiny module end of that
261+
spectrum.
262+
263+
The toolchain polish and debugging work have less clearly *unique*
264+
advantages. But both are table stakes for a good development experience, and the
265+
par for the course for these things in the Wasm domain is currently so low that
266+
we can and should stand out from the crowd.
267+
268+
## Considered Alternative Roadmap Items
269+
270+
Here are a few alternative items that were considered for the roadmap, perhaps
271+
because they were called out in `#RustWasm2019` posts, but ultimately were not
272+
included.
273+
274+
### Pushing `anyref` Integration into the Rust Language
275+
276+
We've already been well positioned to take advantage of host bindings and GC
277+
reference types once they ship in Wasm via `wasm-bindgen`. We could take it even
278+
further and imagine a future where the Rust language was able to pass around
279+
opaque references to objects in alternative memory spaces (some of which might
280+
be GC'd) in a first class way: structs that are split across memory spaces, fat
281+
pointers into multiple memory spaces, etc.
282+
283+
However, it isn't clear that pushing this all the way into the language will
284+
bring that much utility over the existing ["`anyref` at the edges"
285+
implementation that `wasm-bindgen` already has.][anyref-wasm-bindgen]
286+
Additionally, cashing in on this work could easily be blocked in a couple ways:
287+
`anyref` isn't shipping in any mainstream wasm engine yet, and getting this
288+
language-level integration through the larger Rust RFC process with all of its
289+
stakeholders would happen at a glacial pace (if it even happened!)
290+
291+
[anyref-wasm-bindgen]: https://github.com/rustwasm/wasm-bindgen/pull/1002
292+
293+
### A Focus Only on Pure-Rust Web Applications
294+
295+
We prefer to answer "yes and" to pure-Rust Web applications via the modular
296+
toolkit that can service the full spectrum of tiny module to whole Web app, than
297+
to focus only on the whole Web app end of the spectrum. Our hope with the
298+
toolkit is that a rising tide will lift all boats, regardless where your project
299+
lands on that spectrum.
300+
301+
Additionally, full Web apps are not a *unique* advantage for Rust. JavaScript
302+
has been doing it for a while, and as far as Wasm goes, there are better-funded
303+
"competitors" in the space that will be able to provide a more compelling
304+
monolithic Web app development experience more quickly (via integration with
305+
tooling, existing ecosystems, or throwing money and developers at the
306+
problem). Microsoft and Blazor, Google and Go, bringing existing native
307+
applications to the Web with Emscripten, etc. We should compete where we are
308+
best positioned to do so, and monolithic Web applications is not that.
309+
310+
All that said, if you want to build a whole Web application with Rust-generated
311+
Wasm and don't want to write any JavaScript at all, you should be able to do
312+
so. In fact, [you already can with `#[wasm_bindgen(start)]` and the `no-modules`
313+
target][no-modules]. We will never remove this ability, and the new toolkit will
314+
only make developing a whole Web app easier.
315+
316+
[no-modules]: https://github.com/rustwasm/wasm-bindgen/tree/master/examples/no_modules
317+
318+
### Non-JavaScript and Non-Web Embeddings
319+
320+
While the whole of every non-Web and non-JavaScript WebAssembly embeddings looks
321+
very exciting, each embedding is a unique environment, and there is not yet a
322+
standard set of capabilities available. We don't want to block on waiting for a
323+
full set of standard capabilities to emerge, nor do we want to choose one
324+
particular embedding environment.
325+
326+
We do intend to support the reference sysroot work, and any follow up work that
327+
comes after it, but we will take advantage of these things on a opportunistic
328+
basis rather than making it a roadmap item.
329+
330+
We encourage anyone interested in non-JavaScript and non-Web embeddings to
331+
collaborate with the WebAssembly community group to push this story forward by
332+
defining standard Wasm capabilities!
333+
334+
# Unresolved Questions
335+
336+
To be determined.

0 commit comments

Comments
 (0)