Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30701
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | "Chris M. Thomasson" <invalid@invalid.invalid> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Impact of implicit arrays... |
| Date | Tue, 21 Jun 2016 14:43:16 -0700 |
| Organization | n/a |
| Lines | 63 |
| Message-ID | <nkccds$mm6$1@dont-email.me> (permalink) |
| References | <njhj52$hl3$1@gioia.aioe.org> <4a1c28ea-447b-4e9b-9c75-68ef85c379e7@googlegroups.com> <njq6qn$qc3$1@gioia.aioe.org> <a1db3c29-049f-44a0-ae2d-e6c38776ddd7@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 21:43:25 -0000 (UTC) |
| Injection-Info | mx02.eternal-september.org; posting-host="98084a227c6f2f039ecddd7950c40a31"; logging-data="23238"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/M600w9EkHL6ia2vtfVALO7S8HywEcGqw=" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
| In-Reply-To | <a1db3c29-049f-44a0-ae2d-e6c38776ddd7@googlegroups.com> |
| Cancel-Lock | sha1:/ySynWVfhUlyuqbqPGAmt3cxJMA= |
| Xref | csiph.com comp.lang.javascript:30701 |
Show key headers only | View raw
On 6/18/2016 12:47 PM, Michael Haufe (TNO) wrote:
> On Tuesday, June 14, 2016 at 7:17:37 PM UTC-5, Chris M. Thomasson wrote:
>
>> Notice that both approaches have caveats, but both of them
>> will not have a chance to create a shi% load of objects!
>> Do you have some better ideas here?
> This still feels like premature optimization.
> I'd say start with implementing this in a naive way and
> optimize from there (after you benchmark). It won't help
> if on step 1 you have a potentially efficient but cryptic
> implementation and later on at step N you want/need to refactor
> but can't because you've built upon a non-obvious implementation.
> Something Naive (ES6):
>
> class Complex{}
>
> class ComplexRect extends Complex{
> conj(){
> return new ComplexRext(this.re,-this.im)
> }
> constructor(re,im){
> this.re = re
> this.im = im
> }
> equals(cr){
> return this.re == cr.re && this.im == cr.im
> }
> magnitude(){
> return Math.hypot(this.re,this.im)
> }
> plus(cr){
> return new ComplexRect(this.re + cr.re, this.im + cr.im)
> }
> times(cr){
> return new ComplexRect(
> this.re*cr.re - this.im*cr.im,
> this.re*cr.im + cr.re*this.im
> )
> }
> //TODO: etc
> }
>
> class ComplexPolar extends Complex {
> constructor(r, theta){
> this.r = r
> this.theta = theta
> }
> // TODO
> }
So nice! I have not used ES6 and the (class x extends y) technique. I am
wondering about browser support for this. How good is it?
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.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-11 10:52 -0700
Re: Impact of implicit arrays... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-12 12:16 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-13 12:23 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-13 22:00 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.com> - 2016-06-14 17:17 -0700
Re: Impact of implicit arrays... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-06-15 06:55 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <nospam@nospam.invalid> - 2016-06-14 22:19 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-18 12:47 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 14:43 -0700
Re: Impact of implicit arrays... "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-22 00:10 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 15:28 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 15:31 -0700
Re: Impact of implicit arrays... "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-06-22 11:55 +0200
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 12:23 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:14 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:16 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 18:14 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 18:46 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-21 17:35 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-21 21:08 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-21 23:09 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-23 14:38 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-24 07:16 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-06-25 18:03 -0700
Re: Impact of implicit arrays... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-06-25 18:24 -0700
Re: Impact of implicit arrays... "Chris M. Thomasson" <invalid@invalid.invalid> - 2016-07-01 13:52 -0700
csiph-web