The History Behind the Definition of a 'String

2019-01-10 19:43发布

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?

10条回答
疯言疯语
2楼-- · 2019-01-10 20:27

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.

查看更多
在下西门庆
3楼-- · 2019-01-10 20:29

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.

查看更多
闹够了就滚
4楼-- · 2019-01-10 20:29

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

查看更多
劳资没心,怎么记你
5楼-- · 2019-01-10 20:33

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.

查看更多
叼着烟拽天下
6楼-- · 2019-01-10 20:39

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

查看更多
smile是对你的礼貌
7楼-- · 2019-01-10 20:42

In a talk about Javascript history Douglas Crockford says "Nobody knows" and gives a few alternatives: http://www.youtube.com/watch?v=RO1Wnu-xKoY#t=2989

I found the report which in it, allegedly, there is the first reference ever in computer history to a series of characters as a "string". I think it's at the top right column of page 4 of the pdf, which is numbered 47:

http://web.eecs.umich.edu/~bchandra/courses/papers/Naure_Algol60.pdf

查看更多
登录 后发表回答