Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27691

Re: Why does it slow down for bases above 10?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Why does it slow down for bases above 10?
Date Sat, 16 May 2015 17:58:16 +0200
Organization PointedEars Software (PES)
Lines 52
Message-ID <3842368.OIKdPzKKP9@PointedEars.de> (permalink)
References <149684fb-a50c-4a73-ba20-f7f392f1ce5c@googlegroups.com> <bdffa5ba-4192-4112-8a5a-cce6b349aef2@googlegroups.com> <87oall1slp.fsf@bsb.me.uk> <2805604.EO7ul1Ts0Q@PointedEars.de> <f302e2cc-e93c-4901-9f74-3451814bbf45@googlegroups.com> <877fs91ndu.fsf@bsb.me.uk> <b7795ebe-6732-41dc-8cc7-32ef9e9eb779@googlegroups.com> <878ucoon0v.fsf@bsb.me.uk>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1431792057 31011 eJwFwYkBwCAIBLCVau8Bx6Ei+4/QRPDyCVqmRmOIF1XR7CQ75tVRfw9D1xgb1WvnzhOewg8XvhDp (16 May 2015 16:00:57 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Sat, 16 May 2015 16:00:57 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwNy8EBwCAIA8CVQELSjiMi+4/Q3v8y6DwCk8jJITzVW7cvYvtsGSzki7GsprPqhR53zkTZ8YvTsNT6u9o+QYYU7Q==
Cancel-Lock sha1:J6dMilclZBAKtyIoFmpa65+tfCA=
X-NNTP-Posting-Host eJwFwYEBwCAIA7CXZLR1nIOO/n/CEqZCd0MUaPp1oqQnV+Hewiyx2Ee90+oo4LPsVAVnzg8FghC/
Xref csiph.com comp.lang.javascript:27691

Show key headers only | View raw


Ben Bacarisse wrote:

> jonas.thornvall@gmail.com writes:
>> The functions and algorithms are developed as the need for them occur
>> that does not mean i do not want general working code, quite the
>> opposite there is a need for it since many functions work upon the
>> same operand arrays.
> 
> This is why you must avoid globals.  They will mess up the key
> separation you need to have bignums with bignum bases.  If do nothing
> else, do this.  Remove every global variable that you can so that
> all your functions compute results only from their arguments.

He does not even have global variables.  He has deletable properties of the 
ECMAScript global object at best, assuming that each of the assignments is 
successful as the scope chain is considered.  If an object in the scope 
chain has a property with the same name and that cannot be written to, the 
result of the assignment can be throwing an exception or causing an 
unrecoverable runtime error.  (This is different from e.g. Python, where 
symbols are local unless assigned to in the global execution context or 
declared global in a function context.)

For the amateur programmer and the more experienced programmer not 
accustomed to using an ECMAScript implementation, the easiest way to see 
where they went wrong is to test their code in a modern browser that uses
an implementation of ES 5+, and enable strict mode by prepending a line 
containing onlya

"use strict";

to their code.

In this case, the first assignment to an undeclared symbol will throw a 
ReferenceError exception.  One can then determine if the symbol actually 
needs to be globally available.  If not, one should declare it a local 
variable by using the “var” statement in function context; otherwise, “var” 
in global context to declare it a global variable.  One should then 
endeavour to eliminate as many global variables as possible through 
refactoring.

Finally, the script console and code linters such as JSHint can show further 
common mistakes, however the warnings generated by those tools should be 
considered carefully as some of them are bogus or the result of a too strict 
configuration.

This approach can be more efficient than a rewrite.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 11:57 -0700
  Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 12:25 -0700
    Re: Why does it slow down for bases above 10? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-15 21:41 +0100
      Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 14:20 -0700
      Re: Why does it slow down for bases above 10? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-15 23:21 +0200
        Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-15 14:37 -0700
          Re: Why does it slow down for bases above 10? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-15 23:34 +0100
            Re: Why does it slow down for bases above 10? "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-05-16 01:27 +0200
            Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-16 01:53 -0700
              Re: Why does it slow down for bases above 10? jonas.thornvall@gmail.com - 2015-05-16 02:18 -0700
              Re: Why does it slow down for bases above 10? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-05-16 11:05 +0100
                Re: Why does it slow down for bases above 10? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-05-16 17:58 +0200

csiph-web