Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-19 Thread Tab Atkins Jr.
Please don't top-post. On Thu, Jul 18, 2013 at 6:28 PM, Silvia Pfeiffer silviapfeiff...@gmail.com wrote: Promises are new to browsers and people who have used them before have raised issues about the extra resources they require. It may be a non-issue in the browser, but it's still something

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-18 Thread Silvia Pfeiffer
Promises are new to browsers and people who have used them before have raised issues about the extra resources they require. It may be a non-issue in the browser, but it's still something we should be wary of. Would it be possible for the first browser that implements this to have both

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Ian Hickson
On Wed, 19 Jun 2013, Justin Novosad wrote: I was about to launch the implementation of window.createImageBitmap in Blink, and I received feedback on the blink-dev mailing list that the Promise API is the wave of the future for asynchronous JS, and that the new createImageBitmap method

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Silvia Pfeiffer
On 18 Jul 2013 07:08, Ian Hickson i...@hixie.ch wrote: On Wed, 19 Jun 2013, Justin Novosad wrote: I was about to launch the implementation of window.createImageBitmap in Blink, and I received feedback on the blink-dev mailing list that the Promise API is the wave of the future for

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Ian Hickson
On Thu, 18 Jul 2013, Silvia Pfeiffer wrote: There are basically two styles: - constructors (new Date(), new Function(), etc) - factory methods on the parent object (document.createElement(), implementation.createDocument(), context.createLinearGradient(), etc) Do we have a

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Silvia Pfeiffer
On 18 Jul 2013 07:57, Ian Hickson i...@hixie.ch wrote: On Thu, 18 Jul 2013, Silvia Pfeiffer wrote: There are basically two styles: - constructors (new Date(), new Function(), etc) - factory methods on the parent object (document.createElement(),

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Ian Hickson
On Thu, 18 Jul 2013, Silvia Pfeiffer wrote: In this case you did remove the non-promise based approach - presumably because it has not been implemented in browsers yet, which is fair enough for browsers. Right. However, for JS developers it means that if they want to use this

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Jonas Sicking
On Wed, Jul 17, 2013 at 3:12 PM, Silvia Pfeiffer silviapfeiff...@gmail.com wrote: I guess I'm asking for JS dev input here... FWIW, the feedback I've heard from JS devs is a touchingly agreement about how much create* functions suck. / Jonas

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Justin Novosad
On Wed, Jul 17, 2013 at 6:54 PM, Ian Hickson i...@hixie.ch wrote: On Thu, 18 Jul 2013, Silvia Pfeiffer wrote: At the same time, I think we should follow a clear pattern for introducing a Promise based API, which the .create() approach would provide. I don't understand what that means.

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Silvia Pfeiffer
On Thu, Jul 18, 2013 at 10:00 AM, Ian Hickson i...@hixie.ch wrote: On Wed, 17 Jul 2013, Justin Novosad wrote: On Wed, Jul 17, 2013 at 6:54 PM, Ian Hickson i...@hixie.ch wrote: On Thu, 18 Jul 2013, Silvia Pfeiffer wrote: At the same time, I think we should follow a clear pattern for

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Anne van Kesteren
On Wed, Jul 17, 2013 at 5:22 PM, Silvia Pfeiffer silviapfeiff...@gmail.com wrote: It may well be that Promises are the right way to go for createImageBitmap(), but we are blazing a new trail here and need to be careful about the implications. For example, here is an interesting discussion

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Ian Hickson
On Thu, 18 Jul 2013, Silvia Pfeiffer wrote: We have the same issues with WebRTC, which already has a callback based API, but there is a suggestion to replace/augment with a Promise based API, so I just wanted to understand the motivation, potential complications and implications.

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Ruben Rodriguez II
This is exactly what I was thinking when I was reading this. I have been building a game engine with async JS and I have run into situations where promises were absolutely sapping performance. I would encourage people to look over even the faster promise libraries and understand just how much

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Tab Atkins Jr.
On Jul 17, 2013 8:40 PM, Ruben Rodriguez II wha...@therealcha0s.net wrote: This is exactly what I was thinking when I was reading this. I have been building a game engine with async JS and I have run into situations where promises were absolutely sapping performance. I would encourage people

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Silvia Pfeiffer
On Thu, Jul 18, 2013 at 10:39 AM, Ian Hickson i...@hixie.ch wrote: On Thu, 18 Jul 2013, Silvia Pfeiffer wrote: We have the same issues with WebRTC, which already has a callback based API, but there is a suggestion to replace/augment with a Promise based API, so I just wanted to understand the

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Damon Oehlman
I think all I would say with regards to implementing promises is that it's too early. Primarily for these reasons: - The developer community (primarily JS) is still debating the semantics of promises. There is the promises a+ spec ( http://promises-aplus.github.io/promises-spec/) which has

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Ruben Rodriguez II
On 07/17/2013 07:51 PM, Tab Atkins Jr. wrote: On Jul 17, 2013 8:40 PM, Ruben Rodriguez II wha...@therealcha0s.net wrote: This is exactly what I was thinking when I was reading this. I have been building a game engine with async JS and I have run into situations where promises were absolutely

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-07-17 Thread Tab Atkins Jr.
On Jul 17, 2013 9:00 PM, Ruben Rodriguez II wha...@therealcha0s.net wrote: On 07/17/2013 07:51 PM, Tab Atkins Jr. wrote: On Jul 17, 2013 8:40 PM, Ruben Rodriguez II It'll take 1 day to wrap your API with a promise-based API for people who would make that tradeoff. If you sacrifice speed

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-20 Thread Justin Novosad
On Wed, Jun 19, 2013 at 10:18 PM, Anne van Kesteren ann...@annevk.nlwrote: I think something like interface ImageBitmap { static Promise create(ImageBitmapSource image, optional long sx, long sy, long sw, long sh); }; would be much nicer. I agree it would be nicer, but it seems less

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-20 Thread Tab Atkins Jr.
On Thu, Jun 20, 2013 at 7:08 AM, Justin Novosad ju...@google.com wrote: On Wed, Jun 19, 2013 at 10:18 PM, Anne van Kesteren ann...@annevk.nlwrote: I think something like interface ImageBitmap { static Promise create(ImageBitmapSource image, optional long sx, long sy, long sw, long sh); };

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-20 Thread Rick Waldron
On Thu, Jun 20, 2013 at 1:23 PM, Tab Atkins Jr. jackalm...@gmail.comwrote: On Thu, Jun 20, 2013 at 7:08 AM, Justin Novosad ju...@google.com wrote: On Wed, Jun 19, 2013 at 10:18 PM, Anne van Kesteren ann...@annevk.nl wrote: I think something like interface ImageBitmap { static

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-20 Thread Tab Atkins Jr.
On Thu, Jun 20, 2013 at 3:32 PM, Rick Waldron waldron.r...@gmail.com wrote: On Thu, Jun 20, 2013 at 1:23 PM, Tab Atkins Jr. jackalm...@gmail.com wrote: There's really no consistency here anyway, and the Interface.create() idiom is pretty easy and nice. I wonder - perhaps we can call the

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-20 Thread Anne van Kesteren
On Thu, Jun 20, 2013 at 11:08 PM, Justin Novosad ju...@google.com wrote: I agree it would be nicer, but it seems less consistent with other existing APIs. The factory methods we have thus far should probably not be taken as precedent. Almost nobody likes them. URL.createObjectURL() is somewhat

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-20 Thread Tab Atkins Jr.
On Thu, Jun 20, 2013 at 6:44 PM, Anne van Kesteren ann...@annevk.nl wrote: On Thu, Jun 20, 2013 at 11:08 PM, Justin Novosad ju...@google.com wrote: I agree it would be nicer, but it seems less consistent with other existing APIs. The factory methods we have thus far should probably not be

[whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-19 Thread Justin Novosad
I was about to launch the implementation of window.createImageBitmap in Blink, and I received feedback on the blink-dev mailing list that the Promise API is the wave of the future for asynchronous JS, and that the new createImageBitmap method should use Promises. Current spec:

Re: [whatwg] Proposal: createImageBitmap should return a Promise instead of using a callback

2013-06-19 Thread Anne van Kesteren
On Wed, Jun 19, 2013 at 10:19 PM, Justin Novosad ju...@google.com wrote: The proposal is to change the ImageBitmapFactories IDL to something like this: [NoInterfaceObject] interface ImageBitmapFactories { Promise createImageBitmap(ImageBitmapSource image, optional long sx, long sy, long