i heard that these(say for example Groovy) languages have the capability of changing the variable name or call methods dynamically in runtime! What you meant by dynamic languages? And what is the real need for changing any values during runtime? Is that doen't lead to confusion, because at runtime if you change any value(or your programm开发者_如何学Going constriants change anything), then whats the need for compilation(because it decides and confirms these values will be used, then there is no meaning of changing it in dynamically)? And i know there should be something useful, so only people have introduced these concepts!
I guess i'm clear about my question! And i need some brief explanation :)
Three points:
1) Yes, that is what is meant by 'dynamic languages' -- that you can add methods to a class at runtime is a common feature of dynamic languages (for example).
2) You bring up a good point that this ability could lead to confusing runtime issues. Proponents of dynamic languages would say the benefits of the feature outway the downsides. Being able to meta program can be very powerful.
3) compile time checks can still help in development with dynamic languages, if nothing more than for syntax checks. However, with dynamic languages, you do lose some of the compile time safety of non-dynamic languages. Note that some dynamic languages are interpreted (e.g. javascript) so its kind of a moot point.
精彩评论