title: Implementing operator overloading in Javascript via a transpiler
body: <p>One of the problems, for some of us, with Javascript is the lack of operator overloading. This makes writing numeric libraries awkward.  For instance, we might want to write something like:</p>
  
  <pre><code>var a = new BigInteger(5);
  var b = new BigInteger(10);
  var c = a + b;
  </code></pre>
  
  <p>A possible solution is to transpile a language with operator overloading to Javascript. While feasible -- by replacing operators by function calls and type checks -- the consensus seems to be that this is impossible without killing performance.  CoffeeScript has rejected the idea for this reason:</p>
  
  <p><a href="https://github.com/jashkenas/coffee-script/issues/846">https://github.com/jashkenas/coffee-script/issues/846</a></p>
  
  <p>But are there really no clever solutions?</p>
  
  <p>For instance, it might be possible hoist type checks out of tight loops or to use some other pipeline where modern JS compilers can optimize away added cruft when the types are numeric.</p>
  
  <p>Ideas?</p>