W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2010

RE: Adoption of the Typed Array Specification

From: Allen Wirfs-Brock <Allen.Wirfs-Brock@microsoft.com>
Date: Fri, 14 May 2010 17:06:02 +0000
To: Alex Russell <alex@dojotoolkit.org>, Chris Marrin <cmarrin@apple.com>
CC: "arun@mozilla.com" <arun@mozilla.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>, Erik Arvidsson <erik.arvidsson@gmail.com>, "es-discuss@mozilla.org" <es-discuss@mozilla.org>
Message-ID: <90EDC335A511F2479C63F7337D3CE7DB41DFF8C2@TK5EX14MBXC116.redmond.corp.microsoft.com>
> -----Original Message-----
> From: es-discuss-bounces@mozilla.org [mailto:es-discuss-
> bounces@mozilla.org] On Behalf Of Alex Russell
> Yes, yes, I get that everyone with a C buffer they want to expose to JS wants a
> variant of ArrayBuffer that's fixed. But what I'm arguing for is that we can keep
> everything rational (instead of adding a "host object", committee speak for
> "alien weirdo") by making one type of ArrayBuffer (FixedArrayBuffer?) have a
> fixed length but *also* support a mutable length ArrayBuffer. Not exclusive, but
> in parallel and in a way that allows all of this to have a rational class hierarchy.

What's your use case for a variable length ArrayBuffer?  ArrayBuffer seems like a low level building block that is going to be uses as a basis for constructing other higher level abstractions.  As such it should be as simple and efficient as possible.  The more complex we make the primitive entity the more likely it is to have implementation inefficiencies induced by features that are unlikely to be needed for some of the higher level uses. Consider growable buffers.   At an implementation level, growth is either going to require copying or use of segmented buffers. The copying alterative probably requires an extra level of indirection on each access.  The multi-segment approach complicates (and hence probably slows down) all accesses and certainly iterative operations.  In either case, there is a penalty that accrues for the most common use case of a non-growable  buffer. 

These are the sorts of trade-offs that library writers should be making.  They can decided if it is more appropriate to build an abstraction that that grows by copying (probably best for infrequent growth and lots of iterative operations) or grows by segmentation (probably better for frequent growth with minimal iteration).  They can even include both in a library.

The core language should be providing the primitive that enable this sort of library design while minimizing low level overhead.  From that perspective I think a fixed size ArrayBuffer is exactly what is needed.  However, it is also important that efficient copying is supported, possibly via a ArrayBuffer constructer alternative.

Received on Friday, 14 May 2010 17:09:48 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:02 UTC