4 ms·
Better never use Promises at all, it is no solution for a problem, instead it makes code only more ambiguous IMHO. And indeed mixing it with callbacks or async
by uranian 10y ago
Better never use Promises at all, it is no solution for a problem, instead it makes code only more ambiguous IMHO. And indeed mixing it with callbacks or async libraries makes it even worse..
I've once had a very nasty bug keeping me busy for days, where somewhere in a complex structure of multiple promises I somehow forgot to return a call to a resolve. With all these new Promise(), .then(), .catch(), resolve's and reject's nested it's very easy to miss one, and very hard to read where the bug sits.
Maybe it's just me, but I never had such a severe bug with the simplicity of the standard async callback pattern. I Never used promises again, still enjoying that decision.
- l1ambda 10y agoPromises enable async "stacktraces" though. With just callbacks, when an exception is thrown there is not the complete "stack", and little hope of debugging.
- josteink 10y ago> I've once had a very nasty bug keeping me busy for days, where somewhere in a complex structure of multiple promises I somehow forgot to return a call to a resolve. Promises allow, enable and encourage composition. If you use them correctly no single promise should ever be so large that this becomes a problem. That said, you can write spaghetti in any language and platform. If you're the kind to write 100+ line async functions, no framework or technique will help you keep your code tight and solid.
- wging 10y agoMy experience has been exactly the reverse. Promises have made async code much easier to read and understand. There is a little learning curve, but it's not so bad.
- kevinmannix 10y agoTotally agree. There's a sense of satisfaction when refactoring legacy callback code to a simple promise chain. It's even better when the functions called in succession have names that read out concisely and clearly the behavior of the Promise chain as a whole
- uranian 10y agohaha, totally happy for you guys enjoying Promises, it apparently works for you and that's what counts. I also enjoy refactoring callback code, only without the use of Promises, because I don't prefer them to compose and create a nice readable flow. There is a little learning curve though, but it's not so bad.
- deleted 10y ago[deleted]