“字符串”定义背后的历史

发布于 2024-07-21 02:19:30 字数 327 浏览 8 评论 0原文

直到最近我才思考过,但我不确定为什么我们称字符串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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

々眼睛长脚气 2024-07-28 02:19:31

该词最初用于区分一组与元素的特定顺序无关的值(例如,一组随机测量样本)和另一组值,只有当顺序也被保留时才能保留其含义。 最初,字符串可以是任何类型值的集合,但由于在后大型机时代,字符串是迄今为止最常见的类型,因此值是字符的事实成为“默认值”。

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".

苄①跕圉湢 2024-07-28 02:19:31

字符串是离散对象的序列(通常是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.

蘑菇王子 2024-07-28 02:19:31

它被称为字符串,因为它实际上是一个 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".

最舍不得你 2024-07-28 02:19:30

我一直认为编程术语源自“字符串”一词的以下定义(来自韦氏词典):

(1):排列成一条线或好像排列成一条线的一系列事物<一串汽车> <一串名字>

(2):相似项的序列(如位、字符或单词)

由于编程中的字符串只是字符的有序序列,因此将其称为“字符串”(或简称为“字符串”)似乎是最可能的起源。

My assumption has always been that the programming term originated from the following definition of the word "string" (from Merriam-Webster):

(1): a series of things arranged in or as if in a line <a string of cars> <a string of names>

(2): a sequence of like items (as bits, characters, or words)

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.

咆哮 2024-07-28 02:19:30

来自参考:

1971 年的《牛津英语词典》(第 3097 页)引用了 1891 年的
世纪词典的来源
1898 年 1 月 11 日密尔沃基哨兵报
(第 3 节,第 1 页)大意是
这是合成者的术语。 打印机
会粘贴他们拥有的文字
生成在一条长条中
人物。 (据推测,他们是
按脚付费,而不是按字付费!)
引用说这并不罕见
让合成者创造出更多
每小时 1500 个(字符?)。

From this reference:

The 1971 OED (p. 3097) quotes an 1891
Century Dictionary on a source in the
Milwaukee Sentinel of 11 Jan. 1898
(section 3, p. 1) to the effect that
this is a compositor's term. Printers
would paste up the text that they had
generated in a long strip of
characters. (Presumably, they were
paid by the foot, not by the word!)
The quote says that it was not unusual
for compositors to create more than
1500 (characters?) per hour.

旧时浪漫 2024-07-28 02:19:30

通过搜索 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.

烂人 2024-07-28 02:19:30

我猜测“字符串”早在编程语言中被采用之前就已经被数学家使用了。 图灵机有效地在弦上运行。 图灵可能没有使用过这个术语,但它在自动机教科书中随处可见,可以追溯到几十年前。

我能找到的最早的参考资料是 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."

耳钉梦 2024-07-28 02:19:30

怀疑这是因为字符串最初意味着一系列数据值:“我只是将它们串在一起”等。这些值不必是字符。 这个一般概念的一个非常常见的用途恰好是一系列字符,并且这成为了该词的一般含义。

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.

紧拥背影 2024-07-28 02:19:30

我在计算领域能找到的最早的参考资料来自 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:

Computing A linear sequence of records or data.

... and with a first quotation from a 1956 Journal of the Association for Computing Machinery:

Areas are set aside for shuttling strings of control fields back and forth until a completely sorted sequence is obtained.

This use naturally follows on from definition 15c.:

Math., etc. A sequence of symbols or linguistic elements in a definite order.

... and first used in Clarence Irving Lewis and Cooper Harold Langford's Symbolic Logic (1932):

Propositions are not strings of marks, or series of sounds, except incidentally.

This in turn follows on from many other, much earlier definitions for things in a line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文