Search code examples
c++performancecompilationrustcompiler-construction

Why Rust is faster than Ocaml in Performance, Even though first Rust compiler was implemented in Ocaml


I found that the initial compiler for Rust language was written in Ocaml. So what i thought was that Rust would be similar to Ocaml performance wise. But when I look at benchmarks Ocaml vs C++ and Rust vs C++ and compare Ocaml with Rust. It gives me what...?, but how...?

How can Rust be more faster in performance compared to Ocaml even though it derived from Ocaml?

and then it gives rise to an another question ???

Can a compiler based language derived from C be faster than C itself performance wise?


Solution

  • The compiler simply generates the (machine) code that is going to be run. The resulting program doesn't run on top of the language its compiler was written in. Hence, there is no correlation between performance of a particular implementation and the language it was implemented in.