There are several solutions to this problem. One approach that has worked well with scripting languages in the past is JIT (Just-in-Time) compilation. Here, code is compiled to native machine code as needed. This approach only works well with routines that are called over and over. If you're calling a routine just once-one that doesn't have many for loops-it's often faster to just interpret it rather than first compile it and then run it. The compilation can take longer than just running the interpreted form. But if you have a routine that's called over and over, compiling it the first time and then running the compiled form can make a big difference.