Earlier quoted context omitted.
Functional programs don't make this easier. And don't say "monad transformer stacks" somehow solve this problem in an easier way.
Not necessarily because it is functional, but Erlang makes this vastly easier. I find the "oh you changed tiny piece of logic, you should totally have to refactor every line of code that follows it" very strange. It obviously sucks, there are far better ways to handle it and they are slowly making it into the language.
Escape from Callback Hell
81–86 of 86 posts
Re: Escape from Callback Hell
#82Earlier quoted context omitted.
> They're just continuations, seriously, what's everyone's problem? That they're badly made continuations, without support from the language. > If you feel like your code is nesting too deep, you define the function elsewhere and just reference it by name. Then you don't get access to the current scope. At the cost of moving stuff out of where it's invoked, so making code harder to read. The problem with callback hel…
Something lie this? http://taskjs.org/
Re: Escape from Callback Hell
#83I dont find that promises really help callback hell that much, they are useful but in the case of doing a series of sequential async functions the result is pretty similiar (the promises version is usually longer) I got to write some firefox only code recently and added a delay to a function by just adding ... some code setTimeout(continueFun, 5000) yield; ... more code it felt like magic, I dont like generators and…
Re: Escape from Callback Hell
#84I dont find that promises really help callback hell that much, they are useful but in the case of doing a series of sequential async functions the result is pretty similiar (the promises version is usually longer) I got to write some firefox only code recently and added a delay to a function by just adding ... some code setTimeout(continueFun, 5000) yield; ... more code it felt like magic, I dont like generators and…
https://github.com/fzzzy/pavel.js
The only caveat is that you do have to write "yield receive('pattern')" instead of just "receive('pattern')".
Re: Escape from Callback Hell
#85Earlier quoted context omitted.
Haskell definitely makes it easier. You can use preemptive green threads with almost all the ease of cooperatively multitasked code because of the prevalence of immutability. You get the performance benefits of non-blocking code. The simplicity benefits of blocking code. And (almost) none of the threading hell you get in imperative languages.
Are they really preemptive? How does the scheduler decide when to switch?
This is some documentation of the scheduler: http://blog.ezyang.com/2013/01/the-ghc-scheduler/
Re: Escape from Callback Hell
#86Earlier quoted context omitted.
Of course it's different. What if the IO fails?
Then the program dies with an exception. What if a memory allocation in a Haskell program fails? It can happen just as well because allocating memory is an impure operation which you still have to perform from pure functions. Haskell just happens to pretend it has infinite memory available because forcing the programmer to attempt handle out of memory conditions would be impractical and annoying. Haskells "purity" is…