I really think C# & Python will be jealous of the languages mentioned and puts them in an odd spot from language design perspective.
I really think C# & Python will be jealous of the languages mentioned and puts them in an odd spot from language design perspective.
https://github.com/python-greenlet/greenlet
has been available for quite some time in Python (gevent probably being its most used flavor).
i.e.: just because it's not in the standard library doesn't mean it's not available (so, you can actually choose whether you'd like to use async/await or greenlets).
I must say that the main usage I personally had of greenlets didn't have it in mind initially (it was used in an existing application where making the coloring wasn't really feasible as it was a huge app already and adopting green threads was much less work).
https://www.reddit.com/r/rust/comments/7x0icm/regarding_gree...
https://github.com/rust-lang/rfcs/blob/master/text/0230-remo...
> Initially, Rust supported only the green threading model. Later, native threading was added and ultimately became the default.
For green threads the stdlib would have to be designed around them (again) or they'd feel like something bolted on the side with two sets of APIs for everything. This is also the case for async/await but that means green threads don't have an advantage there. If you have to worry about Task vs Thread, make sure you all the right APIs from each, figure out what to do for TLS in Tasks, etc then you may as well just use the one that is more efficient.
Although the coloring problem is only a problem if red functions are harder to use. Not sure marking all functions with "suspend" would make it any worse, besides infecting the codebase.
https://elizarov.medium.com/how-do-you-color-your-functions-...
I am also not sure how this explicit marking would work with interfaces. Can you create an interface that can be implemented by both suspending and synchronous functions?
I do know you can at least specify suspend in an interface method to enforce its implementers to be suspending too. Note that this is e.g impossible in typescript..
You restated the idea of function colouring without further elaborating why it is a problem.
If your thread can afford to block and want to call a suspend function, use `runBlocking`. If your thread cannot block, having `suspend` in the type just saves you from a bug.
If runblocking can't allow non-suspending function then you got a problem because that mean a method implementing an interface can either be suspending or not and therefore for one of two implementation, fail.
`fun main() = runBlocking<Unit> {`
https://kotlinlang.org/docs/composing-suspending-functions.h...
Quoting the post:
> Having to mark asynchronous functions with suspend modifier is a small price to pay, but in return you get better insight into your code.
Also you can do `suspend fun main()`
Did you not read my second paragraph?
It felt like a question more than a complaint.
> create an interface that can be implemented by both suspending and synchronous functions
If interface has a suspending method, the implementations will also be suspending. But you can choose not to make any suspend calls in the method body. Not being able to say "this particular implementation of a red interface is blue" has never bothered me.
In theory, such a system could be implemented on C# with the same sort of gotchas as Java virtual threads. I don't think there's a fundamental design conflict.
https://github.com/openjdk/jdk/pull/8166
1,140 files, (+98,553 −9,862 LOC) and those lines of code are mostly horribly fiddly low level assembly/compiler hacking. This is partly why it took years of development.
Most people don't realize this, especially because in the later stages of course many others contributed, but Loom is in some sense one man's journey. Before he worked at Oracle Ron Pressler spent years writing a library called Quasar which implemented fibers on top of the JVM using bytecode rewriting and some low level hackery with internal APIs. At some point he became available for hiring and Oracle brought him on board, as by that point he was not only an expert in fiber implementations but also the JVM. That was the genesis of Loom.
Something I've learned from following the intricacies of VM development is that what we get is very much a result of hidden human stories as well as technical decisions. Features happen or don't happen on the basis of who was available to be hired at the time, as much as cold calculations of performance impacts. In turn that depends heavily on the vagaries of personal lives. The skills needed to do this work aren't that easy to find on the open market and training takes a long time.
For other VM implementors to do this, and realistically only .NET has the sort of languages where it makes sense (JS doesn't), well, it'd take a long time even if they start today and there's no guarantee of success.