Path: csiph.com!1.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Impact of implicit arrays... Date: Sun, 12 Jun 2016 12:16:02 +0200 Organization: PointedEars Software (PES) Lines: 50 Message-ID: <86226397.ynjsKikP0V@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1465726564 2250 eJwFwQkBwDAIA0BLZRAeOYMG/xJ6B3XxCXO4YbE1ha8zbqdRsKnSybgbCRzTtMJKDcl/KecBFrsRJA== (12 Jun 2016 10:16:04 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Sun, 12 Jun 2016 10:16:04 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYEBwCAIA7CXQGjRcwTX/09YgqBzKgkmBNlt+lky8y3THT3jiNS2kOXEQ+iePECBwNuYrv6mo3zND1UDFZE= Cancel-Lock: sha1:+wdL/Yt7Cm9MityhL0VOQmbItHA= X-NNTP-Posting-Host: eJwNydsBADEEBMCWiOUoxyP6LyE3v6NibP3B1KCrG3WglwYpm00jA9/l9lvhQal0KIt7UP91PiveEgg= Xref: csiph.com comp.lang.javascript:30653 Chris M. Thomasson wrote: > […] > function ct_complex_add(c0, c1) > { > return [c0[0] + c1[0], c0[1] + c1[1]]; > } > […] > function ct_complex_sub(c0, c1) { > return [c0[0] - c1[0], c0[1] - c1[1]]; > } > […] > ______________________________ > > > If I call any of the functions above in a large > iteration, will memory start to explode and stress > out the garbage collector? I mean will there be > millions of arrays that are allocated during heavy > load? The only good answer to such questions is “try and see”. You can start with a small example and see how the approach scales in various runtime environments. You might see a pattern emerging if the same ECMAScript implementation is used. > This is purely functional implementation. Can > an intrusive technique give better performance? Mu. I referred to my JSX:math/complex.js before, so you are reinventing the wheel (but you might do it better), but the only real difference to your approach is that mine is *more* object-oriented: there are Complex instances (arrays *are* objects too, so your approach is _not_ “purely functional”) because new Complex instances are created as the result of operations. Creating new objects when operating on complex values (literally and figuratively) can only be avoided if an operation function modifies the object and returns a reference to the modified object. Or one can, with loss of precision and performance, operate only on string representations, hoping that the script engine does not create objects from them unless necessary, i.e. unless String methods are called. Is one of those what you mean by “an intrusive technique”? -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.