3 ms·
You have a similar problem in nodejs - if the api you want to use is async it has to take callbacks, so if you have to do something with that result you have to
by mangecoeur 11y ago
You have a similar problem in nodejs - if the api you want to use is async it has to take callbacks, so if you have to do something with that result you have to nest in another callback etc... it gets ridiculous. But it's pretty much a fundamental issue with async code - to keep things async then you have to set up the whole interdependent network of functions to be able to work async, since you don't know when anything is going to return its value.
It takes some getting used to - I think Python people are likely to have more trouble with this precisely because Python is a very clear, explicit, and mostly imperative language -you can read Python code as a sequence of instructions and that will be pretty much the way it gets executed, which makes understanding programs very easy. Async is simply a less intuitive way to program, so to adopt it you have to be sure it's worth the hassle of giving up easily understood code.
- deleted 11y ago[deleted]