[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Typed Arrays & Strings



On Tue, Jun 29, 2010 at 5:34 PM, Joshua Bell <josh@lindenlab.com> wrote:
> On Tue, Jun 29, 2010 at 4:35 PM, <ry@tinyclouds.org> wrote:
>>
>> I like the Typed Array proposal -- it seems like one of the more sane
>> binary javascript proposals. One important thing it's missing is the
>> ability to decode a chunk of UTF8 data. Is there a reason that is not
>> part of the spec?
>
> This is possible to do within JavaScript, and at least IMHO doesn't need to
> be enshrined in the TypedArray spec's host objects.
> The CommonJS crew (http://commonjs.org/) has a handful of proposals (see the
> Binary modules), most of which include support for encodings. Many of these
> could be implemented on top of a Uint8Array in JavaScript; although the
> performance of some of the array methods (slice, etc) would be poor, it's
> also questionable if those are actually desirable. Rooting around in the
> CommonJS discussion groups is instructive; the conversation has also jumped
> over to es-discuss a few times.
> I recently needed similar functionality for binary data parsing, so I ended
> up with an ES3 "best effort" impl. of TypedArrays and also a Binary type
> with various encodings although to avoid dependencies, my Binary type was
> actually based on an "octet array" so it's not terribly efficient). I
> intentionally mirrored the CommonJS API ideas, since they're reasonable.
> Code is MIT licensed and
> at http://hg.secondlife.com/llsd/src/tip/js/llsd.js if you want to dig
> around.

Yes, it's possible to do in JS but I think there is a large
performance hit. My implementation of binary-in-javascript is similar
to the Typed Arrays except that it lacks the ability to view the
object as arrays of integers other than 8bit ones. It does however
have "slices" which do not copy, but reference the underlying data;
and it does have string decoding and encoding.

http://nodejs.org/api.html#buffers-3

I'm not married to my API (from which CommonJS Binary/F was derived)
but for my use case (servers) being able to read and write strings
from and to the buffer is important and quite sensitive to
performance. I would like to offer up a non-browser implementation to
Typed Arrays but I need a native API to deal with strings.


Ryan

-----------------------------------------------------------
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: