We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

JavaScript's Speed

I want to be clear, comparing the "speed" or "efficiency" of programming languages is as far from an exact science as "astrology"... okay, maybe not quite that bad. But there are a lot of variables and moving parts, so benchmarks can be misleading.

I just want to point out a few high-level things to give you some kind of frame of reference:

  1. JavaScript is not as fast as C, Rust or Zig. It's almost always going to be outperformed by non-garbage-collected languages.
  2. Modern JavaScript is typically JIT-compiled (just-in-time compiled) into machine code via the V8 engine at runtime. It's usually not as fast as AOT (ahead-of-time) compiled languages like Go or C, but it's usually much faster than interpreted languages like Python or Ruby.
  3. JavaScript runs on a single thread, but has great support for asynchronous programming. It's typically not as performant for CPU-bound tasks (like heavy math calculations), but it does well for I/O-bound tasks (like contacting a database or making an API call).