# coroutines


04/26/2018, 11:33 PM
even if we for-go the "use a channel not a blockable queue", which is rather abstract, you could use standard kotlin
for something like
Copy code
launch {
  run(BLOCKABLE_THREAD_POOL) { staticallyKnownAsBlockingQueueInstance.take() }
inducing a compiler error at
... unlness kotlinx.coroutines can be updated to include such a dispatcher embedded in itself.


04/27/2018, 3:37 PM
I'm not really sure that you can create a usable language that excludes all potential routes to shooting yourself in the foot. The aim of a good language should be to keep things as simple as possible so that any potential pit-falls can be identified via code review.


04/27/2018, 5:51 PM
I agree, but java has so much baggage at this point, I feel like some kind of comprehensive picture should be built about what kinds of tools can be employed to stop people from shooting themselves in the foot ("safeties"), how effective those safeties might be, and where they can be introduced. Coroutines is not the only example where they might be useful --code contracts is another. The thing is that coroutines might allow people doing functional testing to assume correctness despite some leviathan they've introduced through improper threading. Consider making IO blocking (eg WatchService.take()) on the Common pool. Such an application would work until you're watching mas many directories as you have CPUS on your machine. This is a nasty bug by any definition.
I donno, concurrency on the jvm scares me, and I think kotlin is positioned to do better than simply throw up its hands and say "heres another tool"