简体   繁体   English

忽略静态类型时,dart VM的生产模式如何更快? 它不需要在运行时进行类型推断吗?

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

Was just watching this introductory video - http://www.dartlang.org/dart-tips/dart-tips-ep-2.html and the presenter memtioned: 只是看这个介绍视频- http://www.dartlang.org/dart-tips/dart-tips-ep-2.html和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. 在Actionscript 3.0中引入静态类型时,鼓励使用静态类型来提高执行速度。 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. 显然,动态类型导致VM在执行期间推断类型,这会减慢它的速度;而对于静态类型,VM可以在不进行额外工作的情况下进行浏览。 Why is it the opposite in Dart VM? 为什么在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). 我不确定ActionScript,但我猜想在Dart中,类型是程序员有用的工具,可以帮助程序员更好地理解程序,尤其是在与其他程序员共享时(Dart编辑器使用它们提供了大量的信息反馈)。 In checked mode (Dart's other runtime) the compiler is slower because it is going to check the static types. 在检查模式下(Dart的其他运行时),编译器速度较慢,因为它会检查静态类型。 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. 然后,当您要使用生产运行时时,它将跳过此步骤,因为涉及类型的任何打cup应该已经在检查模式下(由程序员)处理了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在静态方法中使用C#枚举类型时无需将其声明为静态? - Why do C# enum types not need to be declared static when used in a static method? 当我们在类之外定义静态变量时,为什么还需要再次指定数据类型 - Why do we need to specify the data type again when we define a static variable outside of the class 为什么接口中的静态方法不需要默认的访问修饰符? - Why doesn't the static method in an interface not need a default access modifier? 为什么C# public static变量不需要实例化? - Why C# public static variable doesn't need instantiation? 如何在运行时(动态)创建PHP静态类属性? - How do I create a PHP static class property at runtime (dynamically)? 为什么需要在初始化时指定extern / static变量的类型? - Why do you need to specify type of extern/ static variable at initialization? 将所有组件实例添加到JFrame时是否需要将其静态化? - Do all component instances need to be static when adding it to a JFrame 使用 generics 时,如何定义泛型类型的 static 实例化器? - When using generics, how do I define a static instantiator of the generic type? 为什么 static 局部变量在这种情况下不保留它的值? - why static local variable doesn't preserve it's value in this case? 派生。 <static variable from Base> 不调用派生的静态构造函数 - Derived.<static variable from Base> doesn't invoke derived's static constructor
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM