“字符串”定义背后的历史
直到最近我才思考过,但我不确定为什么我们称字符串string
。 我是一名 .NET 程序员,但我相信字符串的概念几乎存在于每种编程语言中。
在编程之外,我不认为我听说过用于描述单词或字母的“字符串”这个词。 快速谷歌一下“定义:字符串”会产生一堆与字母、单词或任何与编程相关的性质的概念无关的定义。
我的猜测是,在过去,字符串实际上只是特定长度的字符数组,通常在末尾有一个分隔字符。 但是,我没有看到从“字符数组”到字符串
的自然过渡。
有人可以提供一些关于为什么我们称字符串字符串
的见解吗?
I have never thought about until recently, but I'm not sure why we call strings strings
. I am a .NET programmer, but I believe the concept of strings exist in virtually every programming language.
Outside of programming, I don't believe I've heard the word string
used to describe words or letters. A quick Google of, 'Define: string' yields a bunch of definitions that have nothing to do with the concept of letters, words, or anything of the nature associated to programming.
My guess of it, is that, back in the day, strings were really just arrays of characters of a particular length, often with a delimiting character at the end. But, I don't see a natural transition from 'character array' to string
.
Can someone offer up some insight to why we call strings strings
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
该词最初用于区分一组与元素的特定顺序无关的值(例如,一组随机测量样本)和另一组值,只有当顺序也被保留时才能保留其含义。 最初,字符串可以是任何类型值的集合,但由于在后大型机时代,字符串是迄今为止最常见的类型,因此值是字符的事实成为“默认值”。
The word was originally used to differentiate between a set of values to which the particular order of elements doesn't matter (for instance, a set of random samples of measurements) and another that could only have its meaning preserved when the order is also preserved. Originally a string could be a set of any kind of values, but since in the post-mainframe era a string of characters is by far the most common kind, the fact that the values are characters became a "default".
字符串是离散对象的序列(通常是
char
)。鉴于此,我可能会大胆猜测,这可能与“珍珠链”相关的隐喻有关。 绳子上的每个珠子都是一个字符。
A string is a sequence of discrete objects (usually
char
).Given that, I would probably venture a guess that it may have to do with a metaphor related to "string of pearls". Each bead on the string is a single character.
它被称为字符串,因为它实际上是一个 char 类型元素的数组。
也就是说,它们通过这个数组“串在一起”(或者说串在一起),这将它们变成一个“字符串”。
It's called a strings, because it's actually an array of char type elements.
That being said, they are "stringing together" (or is it strung together) via this array, which turns them into a "string".
我一直认为编程术语源自“字符串”一词的以下定义(来自韦氏词典):
由于编程中的字符串只是字符的有序序列,因此将其称为“字符串”(或简称为“字符串”)似乎是最可能的起源。
My assumption has always been that the programming term originated from the following definition of the word "string" (from Merriam-Webster):
Since a string in programming is simply an ordered sequence of characters, referring to this as a "string of characters" (or simply "string") seems like the most probable origin.
来自此参考:
From this reference:
通过搜索 ACM 参考书目,这个词似乎在 20 世纪 60 年代在计算机科学中获得了它的含义。 首先,字符串是一般类型的序列或列表,例如 用于处理符号字符串的命令语言 从 1958 年开始。
这篇文章 明确提到了 1964 年的“字符串”。
不幸的是我不能全文位于收费站后面。
From searching through the ACM bibliography it seems the word string acquired its meaning in computer science during the 1960s. At the beginning a string is a general kind of sequence or list, e.g. A command language for handling strings of symbols from 1958.
This article explicitly mentions "character strings" in 1964.
Unfortunately I can't access the full texts, which are behind a toll booth.
我猜测“字符串”早在编程语言中被采用之前就已经被数学家使用了。 图灵机有效地在弦上运行。 图灵可能没有使用过这个术语,但它在自动机教科书中随处可见,可以追溯到几十年前。
我能找到的最早的参考资料是 1944 年逻辑学家 Emil Post 在 AMS 公告中发表的一篇文章“递归可枚举正整数集及其决策问题”的 Google 图书片段。 幸运的是,AMS 提供完整文章的在线档案可供免费下载。 这是一个链接:http://www.ams.org/journals/bull/1944-50-05/S0002-9904-1944-08111-1/S0002-9904-1944-08111-1.pdf< /a>
我认为毫无疑问他使用的是计算机科学中传统意义上的“字符串”。 第 286 页“出于工作目的,我们-
引入字母 b,并考虑 1 和 b 的“字符串”,例如
11b1bb1。 对诸如“b1bP 产生 P1bb1”之类的字符串的操作
我们称之为正常操作。 这种特殊的正常操作是 ap-
仅适用于以 b1b 开头的字符串,派生字符串为
然后通过首先删除初始 b1b 从给定字符串中获得,
然后最后加上 1bb1。 因此 b1bb 变成 b1bb1。”
I had guessed that "string" was in use by mathematicians long before its adoption in programming languages. Turing machines effectively operate on strings. Turing may not have used the term, but it is used everywhere in automata textbooks, going back decades.
The earliest reference I could find was a fragment in Google books of a 1944 article "Recursively enumerable sets of positive integers and their decision problems" by logician Emil Post in Bulletin of the AMS. Fortunately, AMS provides online archives of complete articles free for download. Here is a link: http://www.ams.org/journals/bull/1944-50-05/S0002-9904-1944-08111-1/S0002-9904-1944-08111-1.pdf
I think there is little doubt that he is using "string" in the conventional sense used in computer science. P. 286 "For working purposes, we in-
troduce the letter b, and consider "strings" of 1's and b's such as
11b1bb1. An operation on such strings such as "b1bP produces P1bb1"
we term a normal operation. This particular normal operation is ap-
plicable only to strings starting with b1b, and the derived string is
then obtained from the given string by first removing the initial b1b,
and then tacking on 1bb1 at the end. Thus b1bb becomes b1bb1."
我怀疑这是因为
字符串
最初意味着一系列数据值:“我只是将它们串在一起”等。这些值不必是字符。 这个一般概念的一个非常常见的用途恰好是一系列字符,并且这成为了该词的一般含义。I suspect it's because
string
originally meant just a sequence of data values: "I'll just string these together" etc. These values didn't have to be characters. One very common use for this general concept happened to be a sequence of characters, and this took over as the general meaning of the word.我在计算领域能找到的最早的参考资料来自 1963 年 3 月的 METEOR: A LISP Interpreter for String Transformations 作者:麻省理工学院人工智能实验室的 Daniel G. Bobrow。
然而,定义15d。 《牛津英语词典》中的内容是:
...并首次引用 1956 年计算机协会期刊:
这种用法自然遵循定义 15c::
...并首次用于Clarence Irving Lewis 和 Cooper Harold Langford 的符号逻辑(1932 年):
这又是从许多其他更早的对一行中的事物的定义而来的。
The earliest reference I could find in computing is from March 1963's METEOR: A LISP Interpreter for String Transformations by Daniel G. Bobrow at MIT's AI Labs.
However, definition 15d. in the Oxford English Dictionary is:
... and with a first quotation from a 1956 Journal of the Association for Computing Machinery:
This use naturally follows on from definition 15c.:
... and first used in Clarence Irving Lewis and Cooper Harold Langford's Symbolic Logic (1932):
This in turn follows on from many other, much earlier definitions for things in a line.