Skip to content

add various notes, change some wording - #402

Open
robamu wants to merge 4 commits into
mainfrom
more-async-slide-improvements
Open

add various notes, change some wording#402
robamu wants to merge 4 commits into
mainfrom
more-async-slide-improvements

Conversation

@robamu

@robamu robamu commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 22, 2026

Copy link
Copy Markdown

Deploying ferrous-systems-rust-training with  Cloudflare Pages  Cloudflare Pages

Latest commit: be16011
Status: ✅  Deploy successful!
Preview URL: https://74a41923.ferrous-systems-rust-training.pages.dev
Branch Preview URL: https://more-async-slide-improvement.ferrous-systems-rust-training.pages.dev

View logs

@robamu
robamu marked this pull request as ready for review July 27, 2026 10:00

- Imperative: Statements in synchronous code are just executed step-by-step.

## Async language support

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a new slide. I think the auto-generation of state machines is a fact worth mentioning?
In embedded, we commonly replace annoying state machines using async, which is really nice.

* sync programming often has imperative behaviour
* async programming is about constructing a process at runtime and then executing it
* this process is called the "futures tree"
* async programming is about constructing an execution plan and then letting an executor run it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is "execution plan" something that makes sense here?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really; the executor doesn't know ahead of time what's going to be run, and the async task can spawn more tasks at runtime. see https://jyn.dev/what-is-a-build-system-anyway/#applicative-and-monadic-structure for more discussion.

@robamu
robamu requested review from Copilot, listochkin and skade and removed request for Copilot July 27, 2026 10:03
## Async

* Built from important "building blocks"
* Built from important building blocks, which are partially baked into the language

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering why "building blocks" was in quotes, was there a specific reason? I also mentioned that the async/await is partially baked into the language. is this superfluous?

* sync programming often has imperative behaviour
* async programming is about constructing a process at runtime and then executing it
* this process is called the "futures tree"
* async programming is an abstraction that allows developers to define pausing points where

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paraphrased from https://doc.rust-lang.org/book/ch17-00-async-await.html. I think this is an excellent simplification for explaining the difference between sync / async.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would phrase this as "waiting points" to closer parallel the await syntax, or "yield points" to parallel your wording below.

@robamu
robamu force-pushed the more-async-slide-improvements branch from dcb9e74 to 4f98604 Compare August 21, 2026 08:17
@robamu
robamu force-pushed the more-async-slide-improvements branch from 99f0752 to 44eaaa2 Compare August 21, 2026 08:21
Note:

- function must be `async` so `await` can be used inside it.
- The code between two `await`ion points has a regular synchronous flow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be worth mentioning? at awaition points, the executor might pause and do some other pending work, but the flow between the awaition points is still regular synchronous code.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is very worth mentioning. you might be interested in https://ryhl.io/blog/async-what-is-blocking/, particularly the bit that says "other tasks on the same runtime will stop running until the thread is no longer being blocked".

@jyn514 jyn514 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on why the existing wording is there, but I've done a pass confirming factual changes. This looks good overall :) just small wording suggestions.

* sync programming often has imperative behaviour
* async programming is about constructing a process at runtime and then executing it
* this process is called the "futures tree"
* async programming is an abstraction that allows developers to define pausing points where

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would phrase this as "waiting points" to closer parallel the await syntax, or "yield points" to parallel your wording below.


Note:

- Imperative: Statements in synchronous code are just executed step-by-step.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Imperative: Statements in synchronous code are just executed step-by-step.
- Imperative: Statements in single-threaded synchronous code are always executed in order. Statements in asynchronous code may be executed out-of-order, even in a single thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the "out-of-order" related to here? because some processors can re-order or perform "out-of-order" execution on synchronous code as well, right?

## Async language support

* `async` functions can define yield points where the execution can be paused, represented by
`await`ion points.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`await`ion points.
`.await` syntax.

Note:

- function must be `async` so `await` can be used inside it.
- The code between two `await`ion points has a regular synchronous flow.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, this is very worth mentioning. you might be interested in https://ryhl.io/blog/async-what-is-blocking/, particularly the bit that says "other tasks on the same runtime will stop running until the thread is no longer being blocked".


Note:

- Helpful mental model: A `async` function is a regular synchronous functions that returns a `Future`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯. effectively async fn is a promise to the reader "no synchronous work happens before i return a Future".


Note:

- Alternative wording: A future can be resolved or polled to completion.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"resolved or polled to completion" makes it sound like these are two different things, but they're the same. i would say "futures can be resolved by polling them to completion, or canceled by dropping them".

Comment on lines +95 to +96
- On full operating systems, mechanisms like `epoll` are used
- On embedded systems, interrupts are used to advance or complete operations

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this mingles implementation details with your runtime environment. you can have a hosted system that uses Unix signals for progress, and you can have an embedded system that uses spin-loops to poll without needing interrupts.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe still useful to keep them as examples?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 examples seem good, as long as you make it clear that hosted/embedded is independent of polling/event-wakers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I updated this again. Considering that most use-cases will use an event driven mechanism, what do you think about the current version?

@robamu
robamu requested a review from jyn514 August 21, 2026 14:37
Comment on lines +96 to +97
- On full operating systems, OS mechanisms like `epoll`.
- On embedded systems, interrupts to advance or complete operations.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still confuses polling/event-driven with hosted/embedded. i would prefer to state the two axes separately.

@robamu
robamu requested a review from jyn514 August 24, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants