Speed, Speed, Speed: Javascript vs C++ vs WebAssembly
summary
Compares actual runtimes: computes 1,000,000 primes in JavaScript, C++ and WebAssembly and reports JavaScript within a small constant factor of C++ thanks to JIT feedback and baseline and optimizing compilers that use per-call-site caches and deoptimization. Disabling optimization yields 80s vs 10s (JS vs C++) so the optimizer matters. WebAssembly sits between C++ and JS with slight overhead; native C++ is still fastest but JS often reaches near-native speed.
AI-written summary · about
chapters (15)
- 0:00JavaScript performance intro
- 1:50Premature optimization
- 3:59JS vs C++ typing
- 7:11Prime number speed
- 8:14JS engine performance
- 10:28Just-in-time compilation explained
- 13:19Baseline and optimizing compilers in JavaScript
- 14:25Optimizing property lookups
- 18:45Machine code comparison
- 20:51JS compiler impact
- 22:41Small vs large speed
- 23:43When to use C++ or JavaScript for performance
- 24:46WebAssembly discussion
- 25:50WebAssembly vs C++ vs JavaScript performance
- 26:11Summary
related talks
27mSpeed, Speed, Speed: JavaScript vs C++ vs WebAssembly
39mHow much performance can you get out of Javascript?
32mWebAssembly vs JavaScript: Which Is Faster?
30mNative Speed on the Web: JavaScript and asm.js
46mHow much performance can you get out of JavaScript?
35mBoost your JavaScript app
04mA Quick Recap on WebAssembly
20mNot So Fast: Analyzing the Performance of WebAssembly vs. Native Code
