Lisp (Clojure) 和 Tcl 在抽象和元编程能力方面如何比较?
两者似乎都适合构建可扩展的 API 和代码生成。
它们之间的主要区别是什么?
您认为他们的优点、缺点是什么......
Both seem to be good for building extensible API's and code generation.
What are the main differences between them?
What do you see as their strengths, weaknesses, ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
免责声明:我对 Clojure 比对 Tcl 更熟悉,所以如果我歪曲任何内容,请向所有 Tclers 表示歉意。然而,这里有一些我普遍知道的点:
平均而言,两种语言都非常适合元编程,但如果我在两者之间进行选择:
Disclaimer: I'm more familiar with Clojure than Tcl so apoligies to any Tclers if I misrepresent anything. However here are some points I'm generally aware of:
On average both languages are great for metaprogramming, but if I was choosing between the two:
我认为米凯拉的回答非常好。
我只想补充一点,在 clojure 元编程倾向于关注宏(一个没有同行的大统一元编程解决方案)的地方,tcl 有几个可用于元编程的小工具,其中包括“未知”命令,可用于执行各种操作俏皮的技巧。同样有趣的是,尽管 clojure 只有少量关键字或“特殊形式”,但 tcl 实际上没有,这使得 tcl 成为自己的 dsl,并且可以更改(或扩展)任何命令的行为。
我不同意 mikera 的答案的一件事是 clojure 的语法更适合元编程的部分。当我接触 clojure 时,令我感到不愉快的惊喜之一实际上是 clojure 中存在如此多的语法变化,包括 () [] {} "" ^{} #' :key ... 的各种用法等等。我完全理解这种语法糖的合理性,但实际上我发现 tcl 的语法更容易处理“笨手笨脚”的元编程和代码生成。而 tcl 的“一切都是字符串”的性质又增加了简单性。
至于多处理能力、不可变的数据结构、纯函数性质以及 clojure 的许多其他独特之处,tcl 确实没有什么可比的。
我非常同意米凯拉的结论。
I think mikera's answer is excellent.
I would add only that where in clojure metaprogramming tends to focus on macros, a grand unified metaprogramming solution without peer, tcl has several small sharp tools available for metaprogramming, among them the "unknown" command, which can be used to do all sorts of nifty tricks. Also interesting is that even though clojure has only a small number of keywords or "special forms", tcl actually has none, which sort of makes tcl it's own dsl, and changing (or extending) the behavior of any command is possible.
One thing i have to disagree with from mikera's answer is the part about clojure's syntax being more amenable to metaprogramming. One of the unpleasant surprises for me when coming to clojure is actually how much syntactic variation there is in clojure, with the various uses of () [] {} "" ^{} #' :key ... and on and on. I totally grok the justification of this type of syntactic sugar, but i actually find tcl's syntax easier to deal with for "ham-handed" metaprogramming and code generation. And tcl's "everything is a string" nature adds to the simplicity.
As for mulit-processing capabilities, immutable data structures, purely functional nature and many other instances of clojure's distinctives, there really is nothing comparable in tcl.
I couldn't agree more with mikera's conclusion.