Subscribe to PHP Freaks RSS

Why Is a String Called a String?

syndicated from www.sitepoint.com on July 25, 2017

Why is a string called a string? Have you ever given this some thought? We never use such a word in contexts other than programming for a set of letters sticking together, and yet - in programming it's as pervasive as the word "variable". Why is that, and where does it come from?

To find out, we have to tackle some related terms first. History lesson time!

Abstract old calendar illustration

The word font is derived from the French fonte - something that has been melted; a casting. Given that letters for printing presses were literally made of metal and smelted at type foundries, that makes sense.

The metal letters of a font

The terms uppercase and lowercase refer to the literal part of the case in which the font was transported. So the printer (person) had a heavy case he lugged around or had set up at a printing press, and in this case were two "levels" - an upper case, and a lower case. The upper case contained only - you guessed it - UPPERCASE letters, while the lower case only contained lowercase ones.

Printing press case

You'll notice that there were more lowercase letters than uppercase ones. This was to be expected - a letter could only be used once on a single page and after all, a written body of text will have many more lowercase letters than uppercase ones, as there was no such thing as Youtube comments and CAPS LOCK yet.

So how does all this relate to strings?

Well, as printing became more mainstream and printing presses began offering their services to individuals, not just newspapers and publishers, it is said they decided to charge based on the length of the printed material - length in feet. Granted, a lot of this is speculative, but if they strung together the produced, printed material, they could easily estimate the costs and bill customers. So we can conclude with a reasonable degree of certainty that they used the word string in this context as a sequence of characters.

Still, how does this relate to the programming field? I mean, you could say a string of anything in regards to anything at all and it would make a degree of sense in the non-programming world. It's just a word that can be applied generally quite easily to things, even though it generally isn't.

What if we look across academia for first references?

A vector illustration of a person looking through binoculars

In 1944's Recursively enumerable sets of positive integers and their decision problems we have a mention that could vaguely resemble the modern definition:

For working purposes, we introduce the letter 6, and consider "strings" of 1's and b's such as 11b1bb1.

In this paper, the term refers to a sequence of identical symbols, so a string of 1's or a string of b's. Not exactly our definition but it's a start.

Continue reading %Why Is a String Called a String?%