Virtual machines do not need to be slow. They do not even need to be slower than running native code.
Look at how Java uses it's JVM middleman to optimize your code and make it faster—way faster.
Learn about code hoisting, dead-code elimination, loop unrolling, hierarchy flattening, call location caching, escape analysis, array bounds check elimination, and many other JVM tricks that can make
your code more efficient and offer peak performance.