- From: Robin Berjon <robin@robineko.com>
- Date: Thu, 14 Jan 2010 15:39:39 +0100
- To: Ilkka Oksanen <Ilkka.Oksanen@nokia.com>
- Cc: "Mark S. Miller" <erights@google.com>, "public-device-apis@w3.org" <public-device-apis@w3.org>
On Jan 14, 2010, at 10:56 , Ilkka Oksanen wrote: > Robin Berjon wrote: >> Beyond that, a (secondary) worry is the maturity of paraphernalia >> such as JSON Schema and JSONpath that we could want to use here. But >> that's a bridge we can cross any number of ways. > > Date objects in parameters or return values can be especially tricky to serialize in virtual web server approach. I'm not sure if for example JSON has yet proper support for Dates. Dates will be part of the API at least in Calendar. Right, that's part of my reluctance. > In general I'm bit worried how much overhead XHR processing can cause to developers. Assuming I write a simple script that needs Device APIs just to read system's temperature. Are the options to either write a parser myself to remove the transport encoding or to rely on some convenience library that does the decoding? Both options potentially increase script size considerably. That is certainly a consideration: // sync alert("Temp: " + navigator.service.system.temperature); or // async navigator.service.system.getTemperature(function (t) { alert("Temp: " + t); }); versus // sync var req = new XMLHttpRequest(); req.open("GET", "service://w3c/dap/system/temperature", false); req.send(); alert("Temp: " + JSON.parse(req.responseText).temperature); or // async var req = new XMLHttpRequest(); req.open("GET", "service://w3c/dap/system/temperature"); req.onreadystatechange = function () { if (req.readyState == 4) alert("Temp: " + JSON.parse(req.responseText).temperature); } req.send(); is pretty much a hands-down win for the first. Of course, there are counter-arguments: - more complex examples will be less different, meaning that related advantages can compensate - bare-metal XHR is rare: // sync $.ajax({ dataType: "json", src: "service://w3c/dap/system/temperature", success: function (data) { alert("Temp: " + data.temperature); } }); // async $.getJSON("service://w3c/dap/system/temperature", function (data) { alert("Temp: " + data.temperature); }); I'm working on more complex examples to investigate. -- Robin Berjon robineko — hired gun, higher standards http://robineko.com/
Received on Thursday, 14 January 2010 14:40:07 UTC