# @schedule considered harmful

**URL:** <https://discourse.julialang.org/t/schedule-considered-harmful/10540>\
**Category:** Internals & Design\
**Tags:** design\
**Created:** [April 25, 2018, 4:57pm UTC](https://discourse.julialang.org/t/schedule-considered-harmful/10540 "2018-04-25T16:57:24Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![non-Jedi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/non-jedi/32/3645_2.png) [@non-Jedi](https://discourse.julialang.org/u/non-Jedi)\
**Post date:** [April 25, 2018, 4:57pm UTC](https://discourse.julialang.org/t/schedule-considered-harmful/10540/1 "2018-04-25T16:57:25Z")

</div>

I read [this article from hacker news about  
asyncronicity](https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/#id4)  
today and decided to see how well the concepts there mapped to scheduled `Task`s  
in Julia (I haven’t had occasion to use `Task`s myself yet). To my  
gratification, the approach to asyncronicity advocated in the article already  
one of the most natural ways to do async in Julia.

For those who don’t have time to read the article, it basically argues that  
scheduling a Task/coroutine to run on a “background” thread (`@schedule` in  
Julia) is a misfeature in much the same way as `goto` is a misfeature: both, if  
they occur inside a function break assumptions programmers usually make about  
the effects of calling a function in a way that cannot be distinguished at the  
call-site. As an example in Julia, consider if somewhere deep in the dark  
crevasses of a library you’re using, a function `schedule`s something that never  
yields; since Julia has a single global scheduler (afaict), anything you  
scheduled after that would never run.

So if we accept that ad-hoc scheduling is a misfeature, what’s the minimum set  
of changes we’d need to make to Julia to get rid of it while still allowing  
powerful asyncronicity?

1. Deprecate `@schedule` and `schedule` for use in library code.
2. Change `@async` so that it only `schedule`s `Task`s when inside a `@sync`  
block.
3. (Optional) Implement error propagation as described in the linked article.

As far as I can tell, that’s it (I’m sure there’s something I’m missing). Any  
thoughts? Is there something you can currently do with `@schedule` that couldn’t  
be done by wrapping it up in a `@sync` block? If so, should that be done?

---

_[View the full topic](https://discourse.julialang.org/t/schedule-considered-harmful/10540)._
