Possible Duplicate:
Etymology of “String”

I was talking to my non-technical wife about my workday and she was confused as to why I was talking about strings. In her mind, a string is a piece of yarn or thread (I didn't tell her what I thought a thread was).

So it got me wondering...why do we use the vernacular "String" to mean "a character array"?


4 Answers 4


We inherited from Mathematics (like a lot of things).

From my days as a student doing Maths (I remember it being though my memory is fuzzy).

  • It means an ordered sequence of elements. Where each element belongs to a finite set.

A string is not an array of characters.

It is an array of codepoints. Codepoints are not characters. This is quite a complex topic, but the unfortunate fact is that "Array of characters" only works for Western Latin based scripts, and falls apart horrendously once you start dealing with more complex languages. If you're curious for more details, you can look into Unicode.

I believe that strings originated because a linked-list implementation would resemble pieces of string tied together to make the final product.

  • 6
    Context is pretty important here. A "string" can certainly mean an array of characters -- there are countless programs and libraries out there that represent strings precisely that way. That said, Unicode adoption and need for localization have steadily increased over the last two decades, and every programmer should now understand that a string may be more than just a char[].
    – Caleb
    Nov 6, 2011 at 7:03
  • 3
    "Why do some people walk on an escalator when it only saves them a few seconds?" Your answer: "It doesn't save them a few seconds. If the speed of the escalator is close to the speed of light and if your speed is also close to the speed of light, you won't save almost anything." It's great that you know the difference between characters and codepoints.
    – Jan Soltis
    Nov 6, 2011 at 9:50

From this definition (one of many) of string: a necklace consisting of a number of beads, pearls, or the like threaded or strung on a cord.

Or possibly from the verb to string: to connect in or as in a line; arrange in a series or succession: "She knows how to string words together."

Which is probably where Loki's mathematical use of the word arises, and both perfectly match DeadMG's clarification of what a text string really is.

  • 1
    +1 for pointing out where mathematics etc. got their idea to use the word string... Nov 6, 2011 at 8:56
  • Yeah, and it's sad how many mathematics freaks are trying to make it look like everything originated in mathematics. I'm a mathematics enthusiast too, but this is the worst way of doing it :P Jul 1, 2018 at 3:38


Generally, string is a flexible piece of rope or twine which is used to tie, bind, or hang other objects.

My guess is that the term was simply derived from this, because a sequential array of text just resembles it, including its typical uses. As others said, there are many more meanings to the term in regard to computer science:


In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and/or the length changed, or it may be fixed (after creation). A string is generally understood as a data type and is often implemented as a byte (or word) array that stores a sequence of elements, typically characters, using some character encoding. A string may also denote more general array data types and/or other sequential data types and structures; terms such as byte string, or more general, string of datatype, or datatype-string, are sometimes used to denote strings in which the stored data does not (necessarily) represent text.

Not the answer you're looking for? Browse other questions tagged or ask your own question.