JSON parser grammar

Brendan Eich brendan at mozilla.com
Wed Jun 23 12:11:01 PDT 2010


On Jun 23, 2010, at 8:17 AM, Mark S. Miller wrote:

> On Tue, Jun 22, 2010 at 8:17 PM, Dean Landolt <dean at deanlandolt.com> wrote:
> I know many of us in the ES community tend to prefer a Postel's Law approach -- and as long as tabs are always properly stringified it's not a huge interop problem. Still, an argument could be made that with browsers accepting known-bad input (per the JSON spec) it could encourage fragmentation (albeit it minor) of the one format that's really delivered on the promise of true interoperability.
> 
> Yes. On the web, as the sorry history of browsers shows too clearly, Eich's law may be the more relevant one:
> 
> From Dave Herman's blog at <http://calculist.blogspot.com/2010/02/eichs-law.html>:
> 
> Found this gem in a C++ comment while digging in the SpiderMonkey codebase:
> After much testing, it's clear that Postel's advice to protocol designers ("be liberal in what you accept, and conservative in what you send") invites a natural-law repercussion for JS as "protocol":
> "If you are liberal in what you accept, others will utterly fail to be conservative in what they send."
> The comment is unsigned, but it sounds like Brendan. 

I still think the Robustness Principle in full [1] is worth upholding. Validation, especially in developer facing modes or tools (error consoles, debuggers), is important.

But tardy validation that annoys users by trying in vain to repeal a de-facto standard is worse than pointless. You don't get a second chance (dherman's blog post cites a comment I wrote about how <!-- comments, treated by JS in browsers as single-line comments, leak from inline script content into out-of-line .js files). And browser vendors will not risk losing market share on quixotic quests.

Nevertheless, if we can ban TAB per the ES5 JSON spec, let's do it. SpiderMonkey currently allows it as noted, but someone will file a bug (if it's not already on file).

I don't know whether TABs are an issue in the field that could make browsers playing the Prisoner's Dilemma defect from that spec. It is possible, since as Ollie notes so many extant JSON implementations allow them. OTOH TABs are rare in my experience. Worth discussing and (what would be much more useful) field testing. IE9 is head on that front.

But I hate tab characters, so I'm rooting for the home team here ;-).

/be

[1] http://en.wikipedia.org/wiki/Robustness_principle
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100623/72c058d0/attachment.html>


More information about the es-discuss mailing list