]> git.proxmox.com Git - rustc.git/blame - vendor/salsa/FAQ.md
New upstream version 1.48.0+dfsg1
[rustc.git] / vendor / salsa / FAQ.md
CommitLineData
f035d41b
XL
1# Frequently asked questions
2
3## Why is it called salsa?
4
5I like salsa! Don't you?! Well, ok, there's a bit more to it. The
6underlying algorithm for figuring out which bits of code need to be
7re-executed after any given change is based on the algorithm used in
8rustc. Michael Woerister and I first described the rustc algorithm in
9terms of two colors, red and green, and hence we called it the
10"red-green algorithm". This made me think of the New Mexico State
11Question --- ["Red or green?"][nm] --- which refers to chile
12(salsa). Although this version no longer uses colors (we borrowed
13revision counters from Glimmer, instead), I still like the name.
14
15[nm]: https://www.sos.state.nm.us/about-new-mexico/state-question/
16
17## What is the relationship between salsa and an Entity-Component System (ECS)?
18
19You may have noticed that Salsa "feels" a lot like an ECS in some
20ways. That's true -- Salsa's queries are a bit like *components* (and
21the keys to the queries are a bit like *entities*). But there is one
22big difference: **ECS is -- at its heart -- a mutable system**. You
23can get or set a component of some entity whenever you like. In
24contrast, salsa's queries **define "derived values" via pure
25computations**.
26
27Partly as a consequence, ECS doesn't handle incremental updates for
28you. When you update some component of some entity, you have to ensure
29that other entities' components are updated appropriately.
30
31Finally, ECS offers interesting metadata and "aspect-like" facilities,
32such as iterating over all entities that share certain components.
33Salsa has no analogue to that.
34