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:
- JavaScript is not as fast as C, Rust or Zig. It's almost always going to be outperformed by non-garbage-collected languages.
- 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 Java, but it's usually much faster than interpreted languages like Python or Ruby.
- 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).