跳到主内容
精选88Hacker News Best(web_list)技巧与观点

停止开发终端界面:TUI的局限与AI辅助原生UI替代方案

停止开发终端界面:TUI的局限与替代方案

原文
推荐理由

这是一篇极具启发性的工程实践复盘,展示了如何用LLM直接生成高质量原生GUI应用,彻底颠覆了传统TUI开发范式,值得所有关注AI编程效能的开发者参考。

Our field has a weird relationship with terminal and command line interfaces. The time has come to re-evaluate it.

我们的领域与终端和命令行界面有着一种奇怪的关系。是时候重新评估它了。

I’m on a kick lately getting my friends to try building native user interfaces. I built my first serious Mac application a few months ago, and since then I’ve built more native UI thingies than in my entire career prior to that. Let’s take a quick tour.

最近我热衷于让朋友们尝试构建原生用户界面。几个月前,我开发了第一款严肃的 Mac 应用程序,从那以后,我构建的原生 UI 组件比之前整个职业生涯加起来还要多。让我们快速浏览一下。

This is MDV.app, the greatest Markdown viewer in the world until someone else writes a serious markdown viewer. I’ve already written a bunch about MDV and won’t wear you down with more advocacy for it. It is great, though.

这是 MDV.app,在有人写出另一款严肃的 Markdown 查看器之前,它是世界上最棒的 Markdown 查看器。我已经写过很多关于 MDV 的内容,不会再继续用更多的宣传来烦扰大家。不过,它确实很棒。

I had almost no hand in writing this UI code. Why would I? Like most user interfaces, MDV doesn’t break any new ground. It’s not a challenging problem. But building good UI is very hard: this kind of code is tedious, repetitive, exacting, and gated by platform conceptual knowledge. It takes years to get good at this kind of work. Which is why I would never hand-write this program. Instead, I summoned it.

我几乎没有参与这段 UI 代码的编写。我为什么要写呢?像大多数用户界面一样,MDV 并没有开辟任何新领域。它不是一个具有挑战性的问题。但是,构建良好的 UI 非常困难:这类代码枯燥、重复、要求精确,并且受限于对平台概念知识的掌握。要擅长这类工作需要数年的时间。这就是为什么我绝不会手动编写这个程序。相反,我是通过召唤(AI)生成的。

Moving along:

接着看:

I spent the last year doing Math Academy, from Foundations I through Machine Learning, which you can shorthand as “I taught myself calculus”. I like Math Academy a lot and have a bunch to say about it, but here it’s just the set-up to another SwiftUI app I willed into being: a native calculator-style frontend for SageMath, which is the default math system for cryptographers.

过去一年我一直在做 Math Academy 的工作,从基础 I 到机器学习,你可以简称为“我自学生微积分”。我非常喜欢 Math Academy,有很多话想说,但在这里它只是为另一个由我意念生成的 SwiftUI 应用所做的铺垫:一个面向 SageMath 的原生计算器风格前端,SageMath 是密码学家的默认数学系统。

Three big things this app does for me: it automatically renders Sage output in LaTeX, which gets handier the deeper you get into multivariable calc, it point-and-click exposes Sage methods on objects like vectors, matrices, and expressions (which is much nicer than typing trig_simplify over and over again), and it provides a “little language” of shorthand inputs that make common operations (like “take the gradient of this expression”) quick to type. [1,2;3,4] is a matrix in this system; you should already be sold on it.

这个应用为我做了三件大事:它自动将 Sage 的输出渲染为 LaTeX,随着你深入多元微积分的学习,这变得越来越方便;它通过点击暴露了向量、矩阵和表达式等对象上的 Sage 方法(这比反复输入 trig_simplify 要好得多);它还提供了一个简写输入的“小语言”,使常见操作(如“求此表达式的梯度”)能够快速输入。[1,2;3,4] 在这个系统中表示一个矩阵;你应该已经对它着迷了。

I’m not packaging this application up. If you want it, just screenshot this section of the post and give it to Claude. It’ll build something useful. You see where I’m going with this.

我不会打包发布这个应用程序。如果你想要它,只需截取这篇文章的这一部分截图,然后交给 Claude。它会为你构建出有用的东西。你知道我要表达的意思。

(it would be more useful if I cleaned up all my genre labels, most of which date back to the first MP3 rips I did back in 1997).This is DJ Roomba, my Apple Music player. The genre map is a dubious feature. What isn’t dubious is the embedded LLM agent, which has tool calls to read my library, my last played list, and my upcoming tracks. “I’m going to the basement shop to build a picture frame; give me a no-skips playlist to fit the mood”. Turns out the mood is “lots of Kurt Vile and Tom Petty”. No notes.

(如果我把所有的流派标签都清理一下会更有用,其中大多数可以追溯到我在 1997 年进行的第一批 MP3 翻录)。这是 DJ Roomba,我的 Apple Music 播放器。流派地图是一个可疑的功能。但内嵌的 LLM agent 并不可疑,它具备工具调用能力,可以读取我的音乐库、最近播放列表以及即将播放的曲目。“我要去地下室商店做一个相框;给我一份符合心情的无跳过播放列表”。结果发现心情是“大量 Kurt Vile 和 Tom Petty 的歌曲”。无需多言。”

It’s backended by a SQLite database, a sane one with a reasonable schema, which was also a surprisingly useful feature.

它的后端由一个 SQLite 数据库驱动,这是一个结构合理的数据库,拥有合理的模式,这同样是一个令人惊讶的有用功能。

I don’t really know what to think about programs like this. It’s an AI-assisted music player that includes 90% of the interface of Music.app. Music.app. My ever-present personal computing nemesis. This is the personal computing equivalent of slaying a dragon. But I didn’t write a single line of code in it. Am I developing software, or just configuring my computer?

我真的不知道该如何看待这类程序。它是一个 AI 辅助的音乐播放器,包含了 Music.app 界面 90% 的功能。Music.app。我如影随形的个人计算宿敌。这相当于在个人计算领域屠龙。但我并没有在其中编写一行代码。我是在开发软件,还是在仅仅配置我的电脑?

Hold that thought.

先保留这个想法。

This is my LLMwiki. Somebody should write a popular, widely-shared piece on how valuable a self-driving wiki is, where you feed it source material and ask it questions and it writes the wiki for you. Wildly useful idea, I’m glad I thought of it.

这是我的 LLMwiki。有人应该写一篇广为流传的文章,讲述自动驾驶 wiki 的价值所在:你向它提供素材并提出问题,它就会为你撰写 wiki。这是一个极其有用的想法,我很高兴我想到了它。

Self Driving Wiki.app was fun to write. Unlike DJ Roomba, which directly embeds a Responses API client, this app drives claude -p under the hood. Because I assume that agents work better with a filesystem to grovel, I summoned a macOS virtual filesystem extension, which reflects a read-only view of the backing SQLite database as a mounted filesystem inside the app’s sandbox.

Self Driving Wiki.app 写起来很有趣。与直接嵌入 Responses API 客户端的 DJ Roomba 不同,这个应用在后端驱动 claude -p。因为我假设代理在与文件系统交互时表现更好,所以我召唤了一个 macOS 虚拟文件系统扩展,它将底层 SQLite 数据库的只读视图反映为应用沙箱内挂载的文件系统。

Was this probably unnecessary? Does it make the app more annoying to install, for instance by requiring it for some reason to run out of /Applications/? Yes, and also yes. But these kinds of yak-shaving excursions were the joy of software development in the pre-LLM era and I’m glad to discover that I can still experience them today.

这大概是不必要的吗?例如,它是否让安装该应用变得更麻烦,比如因为某些原因要求从 /Applications/ 运行?是的,而且确实如此。但这种类型的‘剃羊毛’式折腾正是 LLM 时代之前软件开发中的乐趣所在,我很高兴今天仍能体验到它们。

(hyper-responder at 2.5 with zero side effects, this shit is choice)Here’s something I use constantly: a semiautomated food macro tracker. I’m glipping balls like everybody else. The app is another simple agent fronting GPT5, taking very short meal descriptions like spitball a guess on the calories ingested tasting cake batter and cream cheese frosting (but I didn't eat any cake) and translating them to intake estimates.

(超响应器,评分 2.5,零副作用,这东西太棒了)这是我经常使用的东西:一种半自动的食物宏量营养素追踪器。我和其他人一样不停地输入数据。该应用是另一个简单的代理前端,对接 GPT5,接收非常简短的餐食描述,比如瞎猜摄入蛋糕面糊和奶油芝士糖霜的热量(但我没吃蛋糕),并将其转化为摄入量估算。

Here’s a menu-bar application that tracks temperatures around my house using these cheap little TP-Link temperature sensors that are giving the Chinese Communist Party access to my Apple TV. Normally after putting something like this together I’d be able to tell you a lot more about the protocols and HTTP APIs these things use to communicate, but I did none of the work to figure that out, so all I can tell you is that there are two different sign-in paths to get information from their cloud and directly from the little sensor pods.

这是一个菜单栏应用程序,使用这些廉价的 TP-Link 温度传感器来追踪我家周围的温度,而这些传感器正让中国共产党得以访问我的 Apple TV。通常,在组装好类似的东西之后,我本可以告诉你更多关于这些设备用于通信的协议和 HTTP API 的信息,但我并没有做这方面的研究,所以我只能告诉你,从它们的云端和直接从那些小传感器模块获取信息有两种不同的登录路径。

Finally, and speaking of my Apple TV, I present the holy grail of macOS native desktop software development: a working menu-bar Apple TV remote control. A couple years ago, I would have paid very good money for this, because I am exactly the kind of dork that tends to have an open MacBook on their lap while watching House Of Ninjas with his spouse.

最后,说到我的 Apple TV,我展示的是 macOS 原生桌面软件开发的圣杯:一个可用的菜单栏 Apple TV 遥控器。几年前,我会非常乐意花大价钱买这个,因为我正是那种喜欢在膝盖上放着打开的 MacBook,一边和配偶一起看《忍者之家》一边看电视的书呆子。

(and to my Roku TV and my Denon receiver, since this is a universal remote)Talking directly to an Apple TV is a pain in the ass. But it turns out people already figured this out and wrote Python libraries to do it. I don’t “use” those libraries, because this is a native Swift app, but that doesn’t matter: whatever has been written in Python might as well have been implemented in Swift, C#, and Brainfuck as well. It’s all the same to a frontier model.

(以及对我的 Roku TV 和 Denon 接收器,因为这是一个通用遥控器)直接与 Apple TV 通信是一件非常麻烦的事。但事实证明,人们已经解决了这个问题并编写了 Python 库来实现它。我并没有“使用”那些库,因为这是一个原生的 Swift 应用,但这并不重要:无论用 Python 写了什么,都可以同样用 Swift、C# 甚至 Brainfuck 来实现。对于前沿模型来说,这些都一样。

I am somewhat self-aware. Preening about a bunch of SwiftUI interfaces I generated clearly invites clinical and unsparing critique of their visual design. Bring it on. But: as a longtime patron of the App Store, I’ll claim these designs are all a step ahead of replacement-level. Five years ago, if I’d had a macOS UI person on my team, I’d have been over the moon to get output of this quality.

我有一定的自知之明。炫耀一堆由我生成的 SwiftUI 界面显然会招致对其视觉设计的临床式且毫不留情的批评。尽管这样吧。但是:作为一名长期的 App Store 用户,我要说这些设计都领先于平均水平。五年前,如果我的团队里有一位 macOS UI 设计师,我会对得到这种质量的作品感到欣喜若狂。

The truth is, I barely think about these things as “apps” (I have no intention to distribute them). They’re artifacts of me making my computer do stuff for me, the way I want it to. As a Unix nerd, I’ve always been able to do this, in the language of the command line. Now, it’s just as easy to do that kind of work with graphical interfaces.

事实上,我几乎不把这些东西当作“应用”来看待(我没有打算分发它们)。它们是我让电脑按照我想要的方式为我做事的产物。作为一名 Unix 极客,我一直能够通过命令行语言做到这一点。现在,用图形界面来做这类工作也同样容易。

We build terminal interfaces because we have to, not because we should.

我们构建终端界面是因为我们必须这样做,而不是因为我们应该这样做。

But First, A Word About CLIs and TUIs: command-line interfaces and terminal user interfaces are both products of the 1970s, shrink-wrapped around the constraints of teletype interfaces and dumb video terminals. Both tend to be outmoded, hostile, and constrained relative to graphical interfaces. But these tendencies are intrinsic to TUIs, and not to CLIs. CLIs have purposes for which they’re irreplaceable. Building a CLI is almost always a good idea. Building a TUI almost never is.

但首先,谈谈命令行界面(CLI)和终端用户界面(TUI):命令行界面和终端用户界面都是20世纪70年代的产物,它们被电传打字机接口和哑视频终端的限制所束缚。与图形界面相比,两者往往显得过时、不友好且受限。但这些倾向是 TUI 固有的,而非 CLI 的固有属性。CLI 有其不可替代的用武之地。构建 CLI 几乎总是个好主意,而构建 TUI 则几乎从来都不是。

Back in 1999, Neal Stephenson wrote an essay about command line interfaces that set the field of human-computer interaction back about 20 years. In it, he depicts the priesthood of Unix nerds wielding CLIs as powerful Morlocks, holding the entire computing industry on their shoulders. The Eloi use GUIs like Microsoft Word. Because this is high-test fan-service, “In The Beginning Was The Command Line” has become one of our field’s sacred texts, despite very little of it holding up 25 years later.

早在1999年,尼尔·斯蒂芬森(Neal Stephenson)写了一篇关于命令行界面的文章,让人类计算机交互领域倒退了大约20年。在文中,他将 Unix 极客描绘成手持 CLI 的强大莫洛克(Morlocks),将整个计算行业扛在肩上。而埃洛伊人(Eloi)则使用像 Microsoft Word 这样的 GUI。由于这迎合了高浓度的粉丝服务,“起初是命令行”(In The Beginning Was The Command Line)已成为我们领域的经典文献之一,尽管25年后的今天,其中大部分观点已不再站得住脚。

In reality, terminal interfaces don’t exist because of any special machine sympathy they create between computers and their operators. Rather, TUIs exist for just two reasons: modems, and because Unix nerds didn’t want to learn Motif.

事实上,终端接口的存在并非因为它们能在计算机和操作者之间产生某种特殊的机器亲和力。相反,TUI 的存在只有两个原因:调制解调器,以及 Unix 极客们不想学习 Motif。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

关联讨论

同一事件的更多信源

相似阅读

另一事件,读法相近