Run-time optimizations ...
It's interesting that you think that run-time optimizations are much better than compile time optimizations.
Please consider that there is a keyword in C++ "inline" that would optimize simple getters and setters (and many other functions) during compile time.
Larry Wall also added optional types to Perl6 for that same reason. In a dynamic language where ints can spill over to bigint, you might want to tell the interpreter that a variable will never spill over into a bigint so that the interpreter can simply use a static type (without checking all the time if the variable needs to evolve into a bigint all the time there is an assignment statement to it) to speed things up.
Please keep in mind that run-time optimizations are much like virtual functions, there is a speed penalty.
Also, would it pay to optimize the following if statement away during run-time?
if (x == someval) { print "blah"; }
a comparison on the low level (in terms of microcode) is a subtraction and a conditional jump based on the flags set by the subtraction (but you know this already). In order to optimize something during run-time, you have to stop(pause) the program which might then force you to flush the cache (since you might be looking up some optimization techniques in the memory) and when you resume it, it might even slow down the program ...
Then there are languages that optimize things by not evaluating anything unless they have to, a good case of this is Haskell. In a language like Python or Perl when you do something like "x = 5", the exact type of x is known right after that statement, but in Haskell, the only thing it knows is that x has to hold and Integer. Only after you try to output the value of x (forcing Haskell to actually evaluation "x = 5"), it will then tell you that x is an Integer holding 5.
Code:
slavik@slavik-desktop:~$ ghci
GHCi, version 6.8.2: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
Prelude> let x = 5
Prelude> :show bindings
x :: Integer = _
Prelude> print x
5
Prelude> :show bindings
it :: () = ()
x :: Integer = 5
Prelude>
Bookmarks