On 'function coloring' (2018)
I often hear that if a distinction exists, it should be represented in the type system; functions are either async or not, so we should track it at compile time.<p>The thing most people don&#x27;t understand about language design is that if you follow this line of thinking to the extreme, your complexity goes through the roof as all of the infectious constraints spread upward through your call graph, sometimes conflicting with other constraints.<p>Rust is an interesting data point. It already has at least three infectious mechanisms, which spread constraints upwards (async vs synchronous, Sync vs !Sync (&quot;data coloring&quot;), &amp;mut and borrowing in general). If you&#x27;ve ever been unable to propagate these infectious constraints upward because you couldn&#x27;t change your signature (because it was a public stable API, or it was a trait override, or it was a `drop` method) then you&#x27;ve felt this complexity first hand. I believe this is the main reason that we see less (healthy) abstraction in Rust compared to other languages.<p>Instead, I think a language should use these kinds of &quot;infectiousnesses&quot; <i>very</i> sparingly. In this order:<p>* Find a solution that doesn&#x27;t involve infectiousness. I think Loom did really well here.<p>* Add an escape hatch (not one that stalls the entire async runtime, preferably). For example, interfaces are a good escape hatch for static types.<p>* I very much like MrJohz&#x27;s suggestion in [0]: invert a feature&#x27;s infectiousness by changing the default color.<p>If I had one PL-related wish, it would be for a mechanism that&#x27;s non-infectious like Loom, but didn&#x27;t involve its stack copying and didn&#x27;t need a runtime. I have a few ideas along those lines, but we&#x27;ll see if they pan out.<p>[0] <a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;ProgrammingLanguages&#x2F;comments&#x2F;vofiyv&#x2F;comment&#x2F;ied4gaw&#x2F;?utm_source=reddit&amp;utm_medium=web2x&amp;context=3" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;ProgrammingLanguages&#x2F;comments&#x2F;vofiy...</a>