title: v8 Engine - Why is calling native code from JS so expensive?
body: <p>Based on multiple answers to other questions, calling native C++ from Javascript is expensive.</p>
  
  <p>I checked myself with the node module "benchmark" and came to the same conclusion.</p>
  
  <p>A simple JS function can get ~90 000 000 calls directly, when calling a C++ function I can get a maximum of about 25 000 000 calls. That in itself is not that bad.</p>
  
  <p>But when adding the creation of an object the JS still is about 70 000 000 calls/sec, but the native version suffers dramatically and goes down to about 2 000 000.</p>
  
  <p>I assume this has todo with the dynamic nature of how the v8 engine works, and that it compiles the JS code to byte code. </p>
  
  <p>But what keeps them from implementing the same optimizations for the C++ code? (or at least calling / insight into what would help there)</p>