Rust as a High Level Language

I agree it is important to identify Rust's focus and strengths.

Unless I am reading too much between the lines, you are ostensibly oversimplifying the issue of concurrency.

First of all, let's establish for all readers that parallelism is not concurrency{1}. Parallelism is partitioning the algorithm into chunks that can run independently for performance. Concurrency is the avoidance of blocking a thread, for performance and to reduce latency of interactivity. For performance, we prefer to use the minimum number of threads because each thread adds task switching and stack memory overhead, yet we also don't want fewer threads running than there are CPU cores{2}.

Concurrency is not achieved just by having tasks running on separate threads and passing data between them. Rather concurrency is fundamentally about avoiding all thread sequencing primitives{3} and instead forming an inductive algebra code path DAG (directed acyclic graph) of asynchronous futures{4}, or inverting the control into a reactionary coinductive algebra dependency DAG driven by an event loop{5}. In the former case, afaics we must have either GC or ARC (with strong and weak references) else I visualize that the resource lifetime management is going to infect everything and get far too hairy to be justified except where GC performance is absolutely intolerable.

In the asynchronous DAG model, the code path (distinguished from thread) can be entire blocked while awaiting the future (thus no possibility for a race condition) or it can split with one code path continuing immediately and thus in this case one of the splits has to receive an immutable reference. I don't really see how mutable resource borrowing can help us because in the former case the code is blocked and in the later case it doesn't wait for the future to return? Seems we merely need to have our future enforce that one of the splits takes an immutable reference to any data that both of the splits can reference.

And I am conjecturing that we will not get clean code without native support for generators, coroutines, and/or continuations. I intend to dig deeper into the details of that in the future to test my intuition with detailed examples.

YouTube links below skips into the same video, Sean Parent: Better Code: Concurrency:

  1. Parallelism and Concurrency, Revisited | Existential Type
    https://www.youtube.com/watch?v=32f6JrQPV8c#t=511

  2. https://www.youtube.com/watch?v=32f6JrQPV8c#t=951
    https://www.youtube.com/watch?v=32f6JrQPV8c#t=3766
    https://www.youtube.com/watch?v=32f6JrQPV8c#t=4495

  3. https://www.youtube.com/watch?v=32f6JrQPV8c#t=531
    https://www.youtube.com/watch?v=32f6JrQPV8c#t=52
    https://www.youtube.com/watch?v=32f6JrQPV8c#t=684

  4. https://www.youtube.com/watch?v=32f6JrQPV8c#t=2164

  5. https://www.youtube.com/watch?v=32f6JrQPV8c#t=3288
    https://www.youtube.com/watch?v=32f6JrQPV8c#t=3632

1 Like