编程语言与软件工程2022arxiv.org
论文本编辑器的设计
On the design of text editors (2020)
入门 · 约 40 分钟读完前置知识:文本编辑器基础、字符编码、排版与折行概念
导读
这篇论文围绕文本编辑器的设计展开,讨论文本表示、换行与折行、光标模型等常被默认的设计选择及其影响。核心并非推荐某一种实现,而是揭示编辑器设计中隐含假设与替代方案的空间。
HN 关注点:文本编辑器和文本格式中那些不易察觉却影响深远的默认设计选择,以及是否还存在分页、层级断点等替代方案。
HN 评论精选
这几条评论里:补充 1
补充指出编辑器/文本格式把换行与空白当作唯一原生断点只是一种隐含设计选择,分页、层级断点、TeX 式格式等替代方案值得考虑。
文本编辑器和文本格式中有许多隐含的选择。例如,文本被当作 1.5 维来处理:换行被尊重并用于划分大部分纵向空间,但自动折行也是标准功能;光标通常能感知二维表示,并会跳过一个折行行的中间,更复杂的编辑器还包含二维光标模式。 这些都是选择。文本也可以像 Forth blocks 那样分页为固定宽度,于是行尾会作为另一种空白字符出现,从而把源数据与结果输出分离。 或者,我们可以把任意数量的断层级定义为字符,超越行、制表符和列——为段落和页面等较大结构、下标和上标等较小结构,以及可能的用户自定义结构提供丰富的断点集合——把文本格式的特性推向类似 TeX 的方向,只是倾向于每个断点用字节编码。我在一种自定义格式中追求过这个想法。有了断点嵌套,你就增加了各种列表的机会。仔细观察英文标点会发现,它以这种方式使用层级断点:句号、逗号、分号、长破折号等。然而不知何故,文本编辑收敛到只原生识别换行和空白作为唯一相关的断点形式,其余都委托给单独的解析阶段(以及编程……)。
syntheweave查看英文原文
There are many implied choices in text editors and formats. For example, text is treated as 1.5 dimensional. Line breaks are respected and used to delimit the majority of the y axis span, but line wrapping(if not word wrapping) is also a standard feature. The cursor is often aware of the 2D representation and jumps through the middle of a wrapped line; more sophisticated editors include a notion of a 2D cursor mode. These are choices. Text could be paginated to a fixed width instead, as in Forth blocks, and line endings therefore appear as another form of whitespace character, in a separation of source data from resulting output. Alternately, we could have any number of break levels defined as characters, beyond lines, tabs, and columns - a rich set of breaks for larger constructs like paragraphs and pages, smaller ones like subscripts and superscripts, and possibly user defined ones - pushing our text format's features in the direction of something like TeX, just with a preference towards a byte encoding of each break. I've pursued that idea in a custom format. With break nesting you add opportunities for various types of lists. A careful observation of English punctuation reveals that it uses a hierarchy of break levels in this manner, with period, comma, semicolon, em-dash, etc. Yet somehow text editing has converged on line breaks and whitespace as the only relevant forms of break to natively recognize, the rest being delegated to a separate parsing stage(and programming languages themselves gravitating towards quotes and braces to nest, rather than employing more breaking characters). Looking at Scratch, to name one well-known example, there is a genuine possibility of breaking away from text-editor tradition. It just hasn't been the focus when the tradition is being serviced so well by so many tools.
相关资源
从这篇论文所有 HN 讨论帖的全部评论里整理出来的链接。
历次讨论
- 2022Hacker News 讨论帖33 分 · 1 评
- 2024Hacker News 讨论帖179 分 · 86 评
同领域还值得读
Google 的软件工程(2017)
Software Engineering at Google (2017)
介绍了 Google 的软件工程实践,包括其单一代码库(monorepo)、几乎全部开发在主干进行而非分支、代码审查、构建系统 Blaze、协议缓冲区等工具与流程,并讨论了频繁重…
编程语言与软件工程2017 · 1,127 分 · 465 评 · 引用 15入门 · 约 45 分钟编辑精选Peter Naur:编程作为理论构建 (1985)
Peter Naur – Programming as Theory Building (1985)
Peter Naur 1985 年的经典论文《Programming as Theory Building》提出:编程的本质不是写代码或文档,而是在程序员头脑中构建对程序及其运行…
编程语言与软件工程2016 · 629 分 · 74 评入门 · 约 45 分钟编辑精选SciPy 1.0:Python 科学计算的基础算法
SciPy 1.0: fundamental algorithms for scientific computing in Python
这篇发表于 Nature Methods 的论文介绍了 SciPy 1.0——Python 科学计算生态的基石库,涵盖其核心算法模块(优化、积分、插值、线性代数等)、软件架构与社…
编程语言与软件工程2020 · 387 分 · 98 评入门 · 约 45 分钟编辑精选Lisp 的历史(1979)
History of Lisp (1979)
这是 Lisp 发明者 John McCarthy 于 1979 年为 HOPL(编程语言史)会议撰写的回顾文章,讲述 Lisp 的起源、设计动机与早期演进,文中也涉及 if 表…
编程语言与软件工程2018 · 352 分 · 44 评入门 · 约 45 分钟编辑精选使用 NumPy 进行数组编程
Array Programming with NumPy
这篇 Nature 文章介绍 NumPy 的数组编程模型及其在科学计算中的核心作用:以 ndarray 为中心,通过向量化操作让 Python 高效处理多维数组。
编程语言与软件工程2020 · 318 分 · 134 评入门 · 约 40 分钟编辑精选