Promises

John J Barton johnjbarton at johnjbarton.com
Fri Nov 9 10:08:26 PST 2012


On Fri, Nov 9, 2012 at 9:35 AM, Mark S. Miller <erights at google.com> wrote:

>
>
>
> On Fri, Nov 9, 2012 at 9:01 AM, John J Barton <johnjbarton at johnjbarton.com
> > wrote:
>
>>
>>
>>
>> On Fri, Nov 9, 2012 at 4:33 AM, David Bruant <bruant.d at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> In this message, I'll be sharing some experience I've had with the Q
>>> library. I have worked with it for about 7-8 months in a medium/big Node.js
>>> application (closed source, so I can't link, sorry).
>>> I'll be covering only the parts that I have used during this experience.
>>> It's related to my own writing style and I don't mean that the rest is
>>> useless and should be thrown away, but the subset I'll be covering here has
>>> proven to be sufficient to my needs for several months.
>>>
>>> I would be interested if others could share their experience if they had
>>> a different way of using promises.
>>>
>>
>> I also used Q (a slightly older version) for several months before
>> removing it because of cost/benefit.
>>
>
> I would like to understand this better. When you using only the
> .then/.when callback style, or were you using the .send/.post style to send
> eventual messages to the promised object? In my own code, I use mostly the
> .send/.post style, and I find it substantially improves readability.
>

Only .then/.when. That is the style that many examples promote. I don't
know about .send/.post.  (Style is also important in callback based async
coding, which is why the case against that approach is often over stated).


>
> See <https://docs.google.com/file/d/0Bw0VXJKBgYPMU1gzQ3hkY0Vrbmc/edit>
> (with improved slides at <
> http://code.google.com/p/es-lab/downloads/detail?name=friam.pdf#makechanges>)
> for a particularly elegant example using promises. I would be curious how
> well you could express this without promises.
>

I also encountered a couple of cases where promises work exceptionally
well. If promises were built into the language and debuggers were upgraded,
then I would choose to use them for just these cases. Given both
preconditions I'm unsure I would use promises more broadly: they are not
the panacea I imagined when reading examples written by advocates.  I would
strongly advocate realistic evaluation of a debugging system for promises
(like eg Causeway) before committing to implementing them in the language.

jjb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121109/e6b9a719/attachment-0001.html>


More information about the es-discuss mailing list