Why are dynamically typed languages slow?

前端 未结 6 731
南笙
南笙 2020-12-23 22:49

What makes it hard to speed up dynamically typed languages when compared to statically typed languages . In other words what is inherent property of statically typed languag

6条回答
  •  滥情空心
    2020-12-23 23:12

    Dynamically typed languages must make all of their checks at runtime because the type might change during the course of the execution.

    Static typed languages resolve all types during compile time so the cost is consumed up front, one time.

    This is the main reason why dynamic typed languages are typically slower. But there are other things to think about. A lot depends on the compiler or interpreter, the GC implementation, the dispatch table layout and lookup algorithms along with other optimizations.

    It all depends on the implementation: A dynamic typed language can be faster than a compiled language it just takes more work to accomplish this.

提交回复
热议问题