编程与软件工程journal.dedasys.com
Tcl 与 Tk 错在哪里(2010)
Where Tcl and Tk Went Wrong (2010)
2010 — 2017,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这篇文章回顾了 Tcl 和 Tk 在历史发展中的失误,从公司战略、营销到语言设计层面分析它们为何未能成为主流。作者探讨了 Tcl 的“一切皆字符串”哲学、与 Lisp 的异同,以及 Tk 作为 GUI 工具包的定位问题。
为什么经久不衰:Tcl/Tk 曾是脚本语言和 GUI 开发的重要角色,其设计得失至今仍是编程语言演进和嵌入脚本选型的经典案例。
HN 评论精选
Tcl 的字符串模型使其易解析但也受限,曾经优秀的 C 集成和元编程优势已被其他语言超越。
我在 Tcl 上花了很多时间,先是在 90 年代末和朋友创办的公司,后来在 Arbor Networks 把它引入服务提供商产品。在 Lisp 中,代码很容易解析,因为一切都是 cons 树,语言从中获得巨大力量。在 Tcl 中,代码也很容易解析,因为一切都是字符串,但语言也因此被束缚;有点像用 Bourne shell 编写大型项目。有一段时间,Tcl 在脚本语言中拥有最好的 C 集成方案,扩展接口设计周到且易用。但现在每种主流脚本语言都有这样的能力。Tcl 通过 upvar、uplevel 和 [incr tcl] 较早进入主流元编程(显然 Lisp 更早),但 Ruby——与 Tcl 有很多相似之处——把这些做得更好、更干净。
tptacek查看英文原文
I spent a lot of time with Tcl, first at company some friends and I started in the late '90s, and then at Arbor Networks, where I dragged it into their service provider product. In a Lisp, code is trivially parsed because everything is a tree of conses, and the language derives tremendous power from that. In Tcl, code is trivially parsed because everything is a string, and the language is hamstrung by it; it's a little like trying to code a major project in Bourne shell. For a time, Tcl had the best C integration story of the scripting languages, with a thoughtfully designed extension interface that was easy to use. But every major scripting language has that now. Tcl was early to what I guess I'll call mainstream metaprogramming (obviously, Lisp got there first) with "upvar" and "uplevel" and [incr tcl]. But Ruby --- which bears a lot of similarities to Tcl --- did all that stuff much better and more cleanly.
Sun 在 1994 年对 Tcl 浏览器脚本地位的反复无常是 Tcl 错失历史机遇的关键节点。
我认为 Tcl 出问题是在 1994 年,当时 Sun 单方面宣布 Tcl 将成为万维网浏览器的官方脚本语言,促使 RMS 撰写《Why You Should Not Use TCL》发起 Tcl 战争。然后 Sun 改变主意,决定 Java 才是浏览器的官方脚本语言。我们都知道结果如何。
DonHopkins查看英文原文
I thought the time TCL went wrong was back in 1994, when Sun unilaterally announced that TCL was going to be the official scripting language of World Wide Web browsers, prompting RMS to kick off the TCL War by writing "Why You Should Not Use TCL". [1] And then Sun changed their mind and decided that Java was going to be the official scripting language of World Wide Web browsers. And we all know how that turned out. [1] http://vanderburg.org/old_pages/Tcl/war/0000.html
“一切皆字符串”的批评被夸大,Tcl 后来增加了 OOP、协程等现代特性,仍具灵活性和生产力。
作为长期 Tcl/Tk 用户,我认为有些人觉得 Tcl 走“错”的地方,是把类似 Lisp 的语义和 C 风格的语法结合。这种“混合”让许多程序员困惑,尤其是来自 C 等工具的人。文章主要考察 Tcl 历史中的公司和营销方面,而非语言的技术优点。确实,Tcl 在这方面输给了 Java 等语言,但正如文章承认的,Tcl 仍有相当大的社区在维持。技术方面,“一切皆字符串”的评论已被广泛讨论,我认为多半是转移注意力的幌子。无论如何,2010 年明显的许多“缺陷”至少已部分解决。特别是近年来 Tcl 获得了许多类似 Scheme 的特性、官方 OOP 设施和协程等“现代”功能。Tcl 仍然极其灵活,适应多样的问题领域。我不会用 Tcl 写硬件驱动,但对许多问题它是最有生产力的工具。
jrapdx3查看英文原文
As a long-time Tcl/Tk user it seems where some might think Tcl went "wrong" was combining its Lisp-like semantics with C-style syntax. The "hybrid" was confusing to many programmers, especially those coming from C and similar tools. The article mainly examines the corporate and marketing aspects of Tcl's history, and not so much the technical merits of the language. True enough, Tcl lost out to Java and other languages on that account but as the article acknowledges Tcl still has quite a large community keeping it going. On the technical side, the commentary about "everything is a string" has been extensive discussed and IMO has been shown to be more than not a red herring. In any case many of the "warts" that were prominent in 2010 have been at least partially addressed. Notably in recent years Tcl as acquired many Scheme-like features, an official OOP facility, and coroutines among other "modern" features. Tcl remains incredibly flexible and adaptable to diverse problem domains. I wouldn't try to write a hardware driver in Tcl, but for many problems it's the most productive tool in the toolbox.
Tcl 缺少闭包是根本设计缺陷,导致回调和高阶函数使用困难,依赖在调用者上下文中 eval 代码块。
从语言设计角度看,Tcl 简单而美丽。你可以在相当短的手册页中读到它的全部语义。它像 Lisp 一样具有同像性(用字符串代替列表),从而实现非常灵活的语法扩展。它的简单性也使它容易嵌入。不幸的是,它在某一个根本方面太简单,导致语言存在严重缺陷:没有闭包。回调(对 I/O 或 GUI 工作至关重要)从只能访问全局变量的作用域执行。结果,用户要么把所有东西塞进全局变量,要么进行笨拙的显式变量替换,小心区分在当前上下文求值的变量和在回调上下文求值的变量并适当转义(就像写 Lisp 宏,但每个回调都要这样)。如果你想实现任何高阶函数,比如按谓词过滤,就有问题:你想给谓词传参,但也希望谓词能访问定义它的作用域中的变量。谓词不是一等函数,而是一块可以 eval 的代码。事实上,你可以在调用栈的任何地方 eval 它。没错:Tcl 用在其调用者上下文中求值代码块的函数来完成任务。如果这听起来吓人,那就对了,确实吓人。
quatrevingts查看英文原文
From a language design standpoint, Tcl is simple and beautiful. You can read its entire semantics in its rather short man page. It's got the homoiconicity of Lisp (with strings instead of lists) which enables very flexible syntax extension. Its simplicity also allows it to be embedded rather easily. Unfortunately, it's too simple, in one fundamental way which makes the language very flawed: it does not have closures. Callbacks (which are fundamental to I/O or GUI work) are executed from a scope which has access to nothing but global variables. As a result, users of the language must either stash everything in globals, or else perform awkward explicit variable substitution, taking care to distinguish between variables to be evaluated in the present context and variables to be evaluated in the callback context and escape them appropriately (like writing a Lisp macro, but this is in every callback.) And if you want to implement any higher-order functions, say filter by predicate, you have a problem because you want to pass an argument to the predicate, but you also want the predicate to have access to variables in the scope where it was defined. The predicate is not a first-class function: it's a block of code that you can eval. In fact, you can eval it anywhere on the call stack. That's right: Tcl gets the job done using functions which evaluate blocks of code in their caller's context. If that sounds scary, good, it is.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选