W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2009

Re: Binary Data - possible topic for joint session

From: Brendan Eich <brendan@mozilla.com>
Date: Fri, 6 Nov 2009 08:26:45 -0800
Cc: public-script-coord@w3.org, es-discuss Steen <es-discuss@mozilla.org>
Message-Id: <B0D5EBDA-9498-4899-9E87-AA33E5AA940A@mozilla.com>
To: Maciej Stachowiak <mjs@apple.com>
On Nov 6, 2009, at 1:34 AM, Maciej Stachowiak wrote:

> = Issues for the binary data API:
>
>    Name (potential bikeshed):
>        ByteArray
>        ByteVector
>        BinaryData
>        Data

This isn't just rank bikeshedding:

1. Data is so common a name that we can't confidently inject it into  
the global object without fear of breaking something. JSON, in spite  
of json2.js precedent, was implemented incompatibly and object- 
detected insufficiently, although this was corrected by the  
implementors (Facebook folks, much appreciated). Google codesearch  
results:

http://www.google.com/codesearch?as_q=%22function+Data%28%22&btnG=Search+Code&hl=en&as_lang=javascript&as_case=y
http://www.google.com/codesearch?as_q=%22var+Data;%22&btnG=Search+Code&hl=en&as_lang=javascript&as_case=y
http://www.google.com/codesearch?as_q=%22var+Data%20=%22&btnG=Search+Code&hl=en&as_lang=javascript&as_case=y

2. Data is annoyingly close to Date.

3. Data is technically plural, and usage sometimes treats it as plural  
(ok, this is almost bikeshedding, I admit). For a String analogue this  
is awkward.


> I like "Data" and similar names. Objective-C has NSData as a  
> distinct type for chunks of binary data - it's not treated as a type  
> of array. I think this makes sense. Often the fact that a chunk of  
> binary data can be treated as an octet sequence is incidental.

It's not incidental unless you provide wider-than-byte element access  
and address byte order. Let's not, in the interest of serving API  
simplicity and common octet-sequence use-cases first and only (if we  
can hold this line).

Therefore I think a concrete name such as ByteVector or ByteArray is  
better, all else equal.

Moreover a name such as ByteVector is much easier to inject as a  
global property. No hits for the obvious function and var forms of it,  
one hit for ByteArray:

http://www.google.com/codesearch?hl=en&lr=&q=%22function+ByteArray%28%22+lang%3Ajavascript&sbtn=Search

/be
Received on Friday, 6 November 2009 16:27:43 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:02 UTC