编程与软件工程lord.io
文本编辑也让你抓狂
Text editing hates you too (2019)
2021 — 2024,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这篇文章讨论看似简单的文本编辑实际上充满复杂性:光标移动、Unicode 与国际化、换行、字体渲染、输入法、富文本等细节层层叠加。作者用具体例子说明,为什么实现一个“能用”的编辑器远比想象中困难。
为什么经久不衰:它用具体细节揭示“简单功能”背后的隐藏复杂度,是理解软件复杂性和国际化代价的经典案例。
HN 评论精选
文章是反驳“这能有多难”的绝佳例证。
对技术从业者来说,我觉得这是回应“能有多难”的完美材料——不管讨论的是如何保持厕纸库存,还是为什么 cURL 能被五行 shell 脚本替代——它都有力地表明,看似简单的东西一旦深入进去会变得多复杂。
bombcar查看英文原文
For people involved with technology I think this is a perfect response to "how hard can it be" - no matter if they're discussing how to keep toilet paper stocked or why cURL can be replaced with five lines of shell script - it emphatically shows how complicated something apparently simple can be once you start diving into it.
反对用“过去一周写完编辑器”来贬低现代复杂性,指出国际化是包容性代价。
Jonathan Blow 在一次关于软件越来越糟的演讲中,举了 Ken Thompson 的文本编辑器作为例子,说 Ken 一周就写出来了。这种论调让我抓狂。是的,国际化让事情比过去更难更复杂。但当年只有世界一小部分地区的人能用自己的语言有效使用计算机。(仅仅支持 Unicode 字符集是不够的。)对过去简单性的怀旧最终会带来丑陋的文化后果。说“让我们回到事情简单的时代”很容易;说“(比如)以色列人不应能输入自己的母语”就难多了。
pcwalton查看英文原文
> Jonathan Blow, in a talk about how software is getting worse, points to the example of Ken Thompson's text editor, which Ken built in a single week. This kind of sentiment drives me crazy. Yes, internationalization makes things harder and more complex than they were in the old days. But, back then, only people who lived in one small part of the world were able to usefully use computers in their language. (Simply supporting the Unicode character set is not enough.) Nostalgia for the simplicity of the past ends up having ugly cultural implications. It's easy to say "let's go back to the time when things were simple"; it's a lot harder to say "folks in (e.g.) Israel shouldn't be able to type in their native language".
怀念 QBasic 的二维网格光标,指出现代文本编辑是多层混乱。
关于垂直方向的光标移动,过去有一种替代行为,可以在 QuickBASIC/QBasic 中看到:微软把整个屏幕当作网格。我一直觉得这是很好的 UI。它隐藏了行尾(Unix 的 \n 或 DOS 的 \r\n)这一实现细节。现代编辑器里你往往得打出空格/制表符才能把光标移到想输入的位置;在 QBasic 中,你直接用方向键把光标移到屏幕任意位置就能输入。因为与打字机不同,计算机屏幕是 2D 的。Vim 有块模式,但据我所知只能用于选择。当然这不通用,只适用于等宽字体和某些语言。但当年它让制作 ASCII/ANSI 图表和艺术很容易。现代文本编辑是多层混乱:渲染、输入法、可变宽度字体以及特殊代码(markdown 等)。有些网站甚至不自洽,比如 Jira 创建工单和编辑同一工单用的是两个不同编辑器……他们怎么走到这一步真是世界第八大奇迹。
deckard1查看英文原文
Regarding the vertical cursor movement, back in the day there was an alternative behavior. You can see this in QuickBASIC/QBasic[1]. Here, Microsoft treated the entire screen as a grid. I always thought that was a great UI. It hides the fact that there are line endings (\n on Unix or \r\n for DOS). And why shouldn't it? That's an implementation detail. And as evident by DOS using CR+LF it goes back to the days where you had an actual physical carriage on a typewriter. Nearly every modern text editor you have to type out the spaces/tabs you want to reach the area you what to add text. In QBasic, you just move the cursor wherever you want on the screen with arrow keys and start typing. Because, unlike a typewriter, a computer screen is 2D. Vim has block mode but, AFAIK, can only work on selections. Of course, this is not universal and only works with monospace fonts in certain languages. But back in the day it made it easy to create ASCII/ANSI diagrams and art. Modern text editing is a multilayered mess. Rendering, input methods, variable width fonts, and the special codes (markdown, etc.). On some sites it's not even self-consistent. Take Jira. Last I checked, they have one editor for creating a ticket and an entirely different editor for editing that same ticket[2] (one of these editors sucks more than the other, but I can never remember which... but neither one is remotely what I would consider a "good" interface). How they got there is truly the 8th Wonder of the World. [1] https://archive.org/details/msdos_qbasic_megapack [2] https://community.atlassian.com/t5/Jira-Software-questions/How-to-make-the-jira-text-editor-the-same-for-creating-and/qaq-p/1350071
呼吁为 Web 富文本编辑建立共同行为约定和基于真实交互的测试套件。
我也接触过相关技术,始终觉得 Web 上的文本编辑、尤其是所见即所得编辑器,非常需要就“给定某些输入应产生什么输出”形成某种共同理解和约定。正如文章暗示的,这个领域的魔鬼确实在细节里。知道该看什么之后,大多数富文本输入在理解用户意图并替用户做出合理处理方面都远未达标。一个有趣的例子是最近把“选中文本 + 粘贴链接”解释为“用剪贴板里的 URL 把这段文本变成链接”的趋势。这完全合理。我什么时候会想要“删掉选中内容,改成粘贴 URL”呢?大概不常。这只是一个小例子,但文本编辑里这类情况很多。我的直觉是,很多时候这些都留给单个工程师去揣摩用户意图;我猜他们大多要么照抄同行,要么尽力猜。要是能有一套测试套件来跑就好了——基于真实用户交互的大量测试用例。
Oddskar查看英文原文
Having touched adjacent technologies to this as well, I could not shake the feeling that text editing on the web, and WYSIWYG text editors especially, would be very well served by some sort of common understanding and agreement of output given certain inputs. As alluded to in the article, the devil really is in the details in this domain. When one knows what to look for, most rich text inputs really miss the mark in understanding intent and doing something reasonable on behalf of the users. An interesting example is the recent trend to start interpreting selection of text + pasting of a link as "turn this text into a link using the URL in the clipboard". It just makes complete sense. When would I ever want it to be "please delete the selection, and instead paste the URL"? Probably not very often. This is just one tiny example, but there are lots and lots of those in text editing. My gut feeling is a lot of the time this is all left to individual engineers to try to decipher the user intent; I would assume for the most part they either copy their peers or do a best effort guess. What if there was some sort of test suite one could run instead? Like a large number of test cases built upon interactions with actual users.
历次讨论
同类还值得读
开源应用架构
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编辑精选