From: anton@mips.complang.tuwien.ac.at   
      
   Paul Rubin writes:   
   >#1 on TIOBE is   
   >Python, which uses arbitrary precision as the native integer type. That   
   >slows arithmetic down but it mostly eliminates the overflow problem.   
      
   If implemented well, the slowdown is small in the common case (small   
   integers): E.g., on AMD64 an add, sub, or imul instruction just needs   
   to be followed by a jo which in the usual case is not taken and very   
   predictable.   
      
   Python (particularly CPython), however, does not seem to have gone for   
   efficient implementation; I don't know what they do for arbitrarily   
   large integers, but the inner interpreter was pretty monstrous last I   
   looked.   
      
   I have looked at the implementation of arbitrarily large integers in   
   OpenJDK (could be better) and in the BC engine of Racket (could also   
   be better, but the BC engine is on the back burner, and they have a   
   JIT compiler as the main engine, but I did not find out how it   
   implements arbitrarily large integers.   
      
   But integer overflow is orthogonal to memory safety.   
      
   There are many people who claim that wrapping behaviour for integer   
   overflow is a problem. Java defines the basic types int and long to   
   perform wraparound on overflow, and while Java has its own share of   
   vulnerabilities (most prominently Log4Shell), I am not aware of one   
   where the wraparound behaviour was involved (but then, I have not   
   looked).   
      
   - anton   
   --   
   M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html   
   comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html   
    New standard: https://forth-standard.org/   
    EuroForth 2023: https://euro.theforth.net/2023   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|