Uses for Dynamic Languages

前端 未结 13 1974
刺人心
刺人心 2021-01-02 11:14

My primary language right now is D, and I\'m in the process of learning Python because it\'s required for a course I\'m taking. While I understand why dynamic languages wou

相关标签:
13条回答
  • 2021-01-02 11:41

    In dynamic languages you can use values in ways that you know are correct. In a statically typed language you can only use values in ways the compiler knows are correct. You need all of the things you mentioned to regain flexibility that's taken away by the type system (I'm not bashing static type systems, the flexibility is often taken away for good reasons). This is a lot of complexity that you don't have to deal with in a dynamic language if you want to use values in ways the language designer didn't anticipate (for example, putting values of different types in a hash table).

    So it's not that you can't do these things in a statically typed language (if you have runtime reflection), it's just more complicated.

    0 讨论(0)
提交回复
热议问题