Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Chris M. Thomasson" Newsgroups: comp.lang.javascript Subject: Re: Impact of implicit arrays... Date: Tue, 21 Jun 2016 15:28:09 -0700 Organization: n/a Lines: 41 Message-ID: References: <4a1c28ea-447b-4e9b-9c75-68ef85c379e7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 21 Jun 2016 22:28:18 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="98084a227c6f2f039ecddd7950c40a31"; logging-data="3466"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+nZB0c99kH6gkrQBmmUfrnKCj2txAVJM0=" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 In-Reply-To: Cancel-Lock: sha1:J9loijOy/AuvoDvn0SqNoBaRcLU= Xref: csiph.com comp.lang.javascript:30703 On 6/21/2016 3:10 PM, Christoph M. Becker wrote: > On 21.06.2016 at 23:43, Chris M. Thomasson wrote: > >> Humm... FWIW, for some reason I also really like the simple array based >> method I am using now. >> >> Yours is easier to read, but for me using foo[0] for x, foo[1] for y, >> ect looks more matrix like wrt indexing into an array; its not all that >> bad to my eyes. Also, it makes iterating over the elements really >> intuitive. > > Then you might be interested in typed arrays, see, for instance, > . Yes, thank you. FWIW, I use these when I am working with WebGL. However, the fact that I need to use (new) for each member converting the following struct: ____________________________ struct someStruct { unsigned long id; char username[16]; float amountDue; }; ____________________________ to the following typed array representation: ____________________________ var buffer = new ArrayBuffer(24); // ... read the data into the buffer ... var idView = new Uint32Array(buffer, 0, 1); var usernameView = new Uint8Array(buffer, 4, 16); var amountDueView = new Float32Array(buffer, 20, 1); ____________________________ Is still troublesome. I will do some benchmarks wrt looping through functional ops, and their intrusive equivalents. AFAICT, the intrusive technique basically has to win. :^o