这里我其实指的是「在没有清楚定义“静态语言”的前提下,“Java是一门静态语言”这一句话本身无意义」。这里是一个小误会。
不过既然都提到了,那就顺便展开一下这个话题:
其实我们真的需要对每一种设计赋予一个名词吗?或者说,这些指代不是很明确的名词,是实现了词汇使交流更高效的作用,还是使得交流更低效了?
“Java是一门静态语言”这句话,在没有额外解释的前提下,也许带来的confusion比带来的信息量多?
不过,单纯回到对“怎样的语言设计算得上「动态」”的讨论,也就是对语言设计思想的讨论的话,其实是个有意思的话题。也就是你说的,“动态”的特征表现。
说到底其实“动态语言”不存在一个严谨的定义,不过 Wikipedia 上的总结挺到位的。
In computer science, a dynamic programming language is a class of high-level programming languages, which at runtime execute many common programming behaviours that static programming languages perform during compilation. These behaviors could include an extension of the program, by adding new code, by extending objects and definitions, or by modifying the type system. Although similar behaviors can be emulated in nearly any language, with varying degrees of difficulty, complexity and performance costs, dynamic languages provide direct tools to make use of them......
Most dynamic languages are also dynamically typed, but not all are. Dynamic languages are frequently (but not always) referred to as scripting languages, although that term in its narrowest sense refers to languages specific to a given run-time environment.
https://en.wikipedia.org/wiki/Dynamic_programming_language
像Java可能能使用反射实现动态的类型逻辑,甚至可以使用mixin动态改变执行的代码。但是相比于python的type()
和eval()
而言,不够直接,所以还是归类偏向于非动态语言。
不过依然,其实动态语言和静态语言之间分界点在哪里,到底多动态就开始算动态语言,也是很难有个准确的界定标准。
对现实有用的定义的话,也许把支持eval
和typeof
的语言界定为“动态语言”就足够了?