W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2013

Re: [whatwg] asynchronous JSON.parse and sending large structured data between threads without compromising responsiveness

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 7 Aug 2013 21:21:17 +0000 (UTC)
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Message-ID: <alpine.DEB.2.00.1308072118270.27623@ps20323.dreamhostps.com>
Cc: whatwg@lists.whatwg.org
On Tue, 6 Aug 2013, Boris Zbarsky wrote:
> On 8/6/13 5:58 PM, Ian Hickson wrote:
> > 
> > Parsing is easy to do on a separate worker, because it has no 
> > dependencies -- you can do it all in isolation.
> 
> Sadly, that may not be the [case].
> 
> Actual JS implementations have various "thread-local" data that objects 
> depend on (starting with interned property names), such that it's not 
> actually possible to create an object on one thread and use it on 
> another in many of them.

Yeah, the final step of parsing a JSON string might require sync access to 
the target thread.


> > > For instance, how would you serialize something as simple as the 
> > > following?
> > > 
> > > {
> > >    name: "The One",
> > >    hp: 1000,
> > >    achievements: ["achiever", "overachiever", "extreme overachiever"]
> > >     // Length of the list is unpredictable
> > > }
> > 
> > Why serialise it? If you want to post this across a MessagePort to a 
> > worker, or back from a worker, why not just post it?
> > 
> >     var a = { ... }; // from above
> >     port.postMessage(a);
> 
> This in practice does some sort of serialization in UAs.

Indeed. My question was why do it manually.


> > why not just do this in C++?
> 
> Let's start with "because writing C++ code without memory errors is 
> harder than writing JS code without memory errors"?
>
> > I don't understand why you would constrain yourself to using Web APIs 
> > in JavaScript to write a browser.
> 
> Simplicity of implementation?  Sandboxing of the code?  Eating your own 
> dogfood?

I guess that's a design choice.

But fundamentally, the needs of programmers writing Web browsers aren't 
valid use cases for adding features to the Web platform. There's no need 
for internal APIs to be interoperable.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
Received on Wednesday, 7 August 2013 21:21:41 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:23 UTC