News for hackers. Stuff that matters.
Re:Promises and Lisp by javajosh on Tuesday December 23, 2014 @08:42PM (#8791161)
Debugging is a bit of a challenge with promises.

Indeed, and that is why I am personally not really that bullish on promises, at least not how they are currently implemented. When you're debugging you want access to the implicit state-machine that the promise statement constructed, but at least in JS such state is hidden away in the `then()` function.

A good compromise (which I'm currently exploring in JS) is to make the state-machine navigable from the root, giving you the ability to examine it and mutate it explicitly during a debug session.

Re:Promises and Lisp by Arnavion on Tuesday December 23, 2014 @09:07PM (#8791226)
Libraries like bluebird will give you pretty stack traces that track the sequence of then calls, almost as if it was a single sequential execution. This helps with debugging.

Alternatively you can use the yield-spawn method of getting rid of then() altogether. Then you get code that looks sequential as well, and the browser gives you nice stack traces.

This doesn't help with modifying values during debugging as you mentioned, but it does solve the problem of seeing the "caller" stack frames.

Re:Promises and Lisp by chaitanya on Tuesday December 23, 2014 @09:00PM (#8791208)
> A good compromise (which I'm currently exploring in JS) is to make the state-machine navigable from the root, giving you the ability to examine it and mutate it explicitly during a debug session.

You might also want to check out the JS library q, which has support for stack traces that span async jumps if a promise errors out https://github.com/kriskowal/q#long-stack-traces

Re:Promises and Lisp by Arnavion on Tuesday December 23, 2014 @09:15PM (#8791245)
I would not recommend new projects to use Q when Bluebird exists. The latter is better in every way - perf, features and tracking the ES6 Promise API more closely.
Re:Promises and Lisp by chaitanya on Tuesday December 23, 2014 @10:35PM (#8791431)
Thanks. I had not heard about Bluebird before.