title: Nodejs vs C++ performance for simple mathematic
body: <p>I made the same program to test performance on Nodejs and C++ on Mac OS X.</p>
  
  <p>First in C++:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;time.h&gt;
  
  using namespace std;
  
  int main() {
      clock_t t1, t2;
  
      cout &lt;&lt; "Initializing\n";
  
      t1 = clock();
  
      double m = 0;
      for (double i = 0; i != 10000000000; ++i) {
          m = i * -1 + i;
      }
  
      t2 = clock();
      float diff = (((float) t2 - (float) t1) / 1000000.0F) * 1000;
  
      cout &lt;&lt; "Finalizing with " &lt;&lt; diff &lt;&lt; "ms\n";
  }
  </code></pre>
  
  <p>Second in Nodejs:</p>
  
  <pre><code>console.log("Initializing");
  
  t1 = Date.now();
  
  var m = 0;
  
  for (var i = 0; i != 10000000000; i++) {
      m = i * -1 + i;
  }
  
  t2 = Date.now();
  var diff = t2 - t1;
  console.log("Finalizing with %dms", diff);
  </code></pre>
  
  <p>The result was 50000ms for C++ and 22000 for Nodejs.</p>
  
  <p>Why Nodejs is faster for that kind of operation?</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Switching double and using long int, it gave me 22000ms, like Nodejs.</p>