How is dart VM's production mode faster when ignoring static types? Doesn't it need to do type inference at runtime?

StackOverflow https://stackoverflow.com/questions/16625318

Вопрос

Was just watching this introductory video - http://www.dartlang.org/dart-tips/dart-tips-ep-2.html and the presenter memtioned:

Production mode actually gets a speed boost by ignoring static types, because it can avoid many type checks.

When static types were introduced in Actionscript 3.0, static types were encouraged as a means to increase execution speed. Apparently dynamic types caused the VM to infer types during execution which would slow it down, and with static types, the VM could cruise through without that additional work. Why is it the opposite in Dart VM?

Thanks!

Это было полезно?

Решение

I'm not sure about ActionScript but I'm guessing that in Dart, the types are a helpful tool for programmers to better understand the program especially when shared with other programmers (and the Dart Editor provides lots of informative feedback using them). In checked mode (Dart's other runtime) the compiler is slower because it is going to check the static types. Then, when you want to use the production runtime, it will skip this step as any hiccup involving types should already have been handled (by the programmer) in checked mode.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top