As I understand it[1], to achieve true concurrency on a single computer, you need to ensure that app code sits in one of the core-private caches (L1, L2, but not L3).
This suggests writing all code in something ultra-tiny, like Sector Lisp[2], then P.Eng'ing (Production Engineering) it by rewriting only the 5% of code that actually matters for efficiency in a general-purpose language or assembler. Sector Lisp is a modern version of McCarthy’s Lisp[3], with a better garbage collector based on pure FP (Functional Programming) principles.
This idea should also work on truly distributed networks of things like 1,000s of Arduinos (or laptops on internet, or, whatever).
For this kind of P.Eng'ing, I would look to early work on compilers, namely Cordy's Orthogonal Code Generator[4] or Fraser/Davidson peepholing[5]. OCG shows how to write a declarative tree to automagically port code to specific architectures. RTL (Fraser/Davidson’s Register Transfer Language) predates OCG and is used in GCC. Both of these technologies use the idea of 2-stage code emission:
Emit dumb code, for a generalized intermediate language. But, correct code.
Automatically rewrite the dumb code into actual code for given specific CPU architectures.
Both techniques could be further optimized using Dragon-book[6] techniques. I would guess that LLVM[7] or WASM[8, 9] could be intermediate-intermediate languages sitting between steps (1) and (2).
Bibliography
[1] Async vs. Sync from https://programmingsimplicity.substack.com/p/async-vs-sync?r=1egdky
[2] sector lisp from https://justine.lol/sectorlisp2/
[3] The Most Beautiful Program Ever Written from
[4] J. R. Cordy. An Orthogonal Model for Code Generation.
[5] Jack W. Davidson, and Christopher W. Fraser. The Design and Application of a Retargetable Peephole Optimizer.
[6] Compilers: Principles, Techniques, and Tools (aka The Dragon Book) from https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
[7] LLVM from https://en.wikipedia.org/wiki/LLVM
[8] Web Assembler (WASM) from https://webassembly.org
[9] WASM From The Ground Up from https://wasmgroundup.com
See Also
References: https://guitarvydas.github.io/2024/01/06/References.html
Blog: guitarvydas.github.io
Videos: https://www.youtube.com/@programmingsimplicity2980
Discord: https://discord.gg/65YZUh6Jpq
Leanpub: [WIP] https://leanpub.com/u/paul-tarvydas
Gumroad: tarvydas.gumroad.com
Twitter: @paul_tarvydas