5 ms·
I think you are absolutely right about everything you mentioned, except for one: > I am not convinced one can make something solving all the things Rust solves
by gavinhoward 4y ago
I think you are absolutely right about everything you mentioned, except for one:
> I am not convinced one can make something solving all the things Rust solves which is substantially simpler as language.
You could be right about this, but boy, I hope you are wrong. And I'm trying to prove that it's possible.
I think the answer is structured concurrency [1], and here's why:
1. Structured concurrency can replace everything async/await can do. At least, I believe so, kind of like it's believed that structured programming can replace any unstructured use of goto.
2. If you extend structured concurrency a bit so that the thread tree is actually a DAG [2], you basically get a borrow checker for free because every item is rooted in a thread stack somewhere, and where it is rooted is always before everything that it could own and after everything that could own it.
3. Making the thread tree a DAG also means it's easy to implement RAII and have it work meaning no use-after-free, no double frees, etc.
Put that on top of a language that has memory safety by default, and you will have everything that Rust gives you without the complexity.
This isn't theoretical; I have implemented this in C. [3] (See [4] for a use of it.) I have even implemented bounds checking in C. [5]
However, I'm also implementing a programming language with these ideas (see [6] for the example file and [7] within that file for how structured concurrency might be exposed in the language).
As for readability, I do think that what I have is readable. However, I appreciate comments; readability is important to me too, but I've spent so long with this work that I am blind to what is actually readable to other people.
[1]: https://gavinhoward.com/2019/12/structured-concurrency-definition/ https://gavinhoward.com/2019/12/structured-concurrency-defin...
[2]: https://lobste.rs/s/8msejg/notes_on_structured_concurrency_go#c_wkxbvb https://lobste.rs/s/8msejg/notes_on_structured_concurrency_g...
[3]: https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/threadset.h#L104-L115 https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/...
[4]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/rig/build.c#L972-L1020 https://git.yzena.com/Yzena/Yc/src/branch/master/src/rig/bui...
[5]: https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/array.h#L208-L263 https://git.yzena.com/Yzena/Yc/src/branch/master/include/yc/...
[6]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/example.y https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/exa...
[7]: https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/example.y#L757-L765 https://git.yzena.com/Yzena/Yc/src/branch/master/src/yao/exa...