简体   繁体   English

哪些语言支持“动态”元编程?

[英]What languages support “dynamic” metaprogramming?

In Metaprogramming Ruby , the author states that only a few languages, including Ruby, can manipulate themselves at runtime. 元编程Ruby中 ,作者指出,只有少数几种语言(包括Ruby)可以在运行时进行自我操作。 What other languages besides Ruby can support this type of metaprogramming? 除了Ruby之外,还有哪些其他语言可以支持这种元编程?

The specific quote I'm referring to is in the introduction on page xix: 我要引用的具体报价在第xix页的简介中:

In this book, I'll stick to a different meaning of metaprogramming, focusing on code that manipulates itself at runtime. 在本书中,我将坚持元编程的另一种含义,重点是在运行时进行自我操作的代码。 Only a few languages can do that effectively, and Ruby is one of them. 只有少数几种语言可以有效地做到这一点,而Ruby是其中之一。 You can think of this as dynamic metaprogramming to distinguish it from the static metaprogramming of code generators and compilers. 您可以将其视为动态元编程,以将其与代码生成器和编译器的静态元编程区分开。

Most languages now days are moving towards providing that kind of functionality, but it's generally not as "clean" as it's in ruby. 如今,大多数语言都在朝着提供这种功能的方向发展,但是它通常不像在ruby中那样“干净”。 All these languages have a lot of those capabilities ( reference ): 所有这些语言都具有很多这些功能( 参考 ):

  • ActionScript 动作脚本
  • BASIC BASIC
  • BeanShell[3] BeanShell的[3]
  • Clojure Clojure的
  • ColdFusion ColdFusion的
  • Common Lisp and most other Lisps 普通Lisp和大多数其他Lips
  • Groovy[4] Groovy的[4]
  • E programming language 电子编程语言
  • JavaScript JavaScript的
  • VBScript VBScript中
  • MATLAB / Octave MATLAB /八度
  • Lua LUA
  • Objective-C Objective-C的
  • Perl Perl的
  • PHP PHP
  • Powershell 电源外壳
  • Python 蟒蛇
  • Ruby 红宝石
  • Smalltalk 短暂聊天
  • Tcl TCL

Other languages such as Java and C# ( reference ) have ways of inspecting and creating code at run time, but it's not so "natural" as in those languages, and it feels a lot like a hack. 其他语言(例如Java和C#( 参考 ))具有在运行时检查和创建代码的方法,但是它不像这些语言那么“自然”,并且感觉很像黑客。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM