Core points
- The origin of the programming term "string" is believed to be related to the era of typography, when printers charged based on the length of the printed material (in feet). They string together printed materials and use the word "string" to represent the character sequence.
- In papers published in the 1940s and 1950s, the earliest academic references to use "string" to express similar meanings to modern programming were found. These early usages refer to sequences of the same symbols or continuous strings of letters between punctuation marks or spaces.
- The term "string" (string) we know today in programming seems to have been established in the 1960s and appears in various academic papers and resources. It is used to represent a set of characters with meaning and bring some cost, similar to its usage in the age of typography.
- Although the term "string" (string) does not have an equivalent word in the real world (we will not call the text on the page "strings"), it has become a commonly understood term in computer science, Represents a popular data type. The authors believe that there may be no other term that is more suitable for this data type than this term.
This is the editorial for the July 25 edition of the SitePoint PHP newsletter.
Why is a string called a string? Have you ever thought about this question? Apart from programming, we have never used such a word in other contexts to represent a set of letters glued together, however—in programming, it is as common as the word “variable.” Why is this, where does it come from?
To figure it out, we must first solve some related terms. History class time!
Wordfont (font) comes from French font——the melted thing; casting. Given that the letters of the press are indeed made of metal and melted at the Lead Foundry, this makes sense.
The terms uppercase (uppercase) and lowercase (lowercase) refer to the literal part of the font box used for font transportation. Therefore, the printer (man) has a heavy font box that he carries with him or sets on a press, in which there are two "levels" - one uppercase letter box and one lowercase letter box. The capital letter box only contains — you guessed it right — capital letters, while the lowercase letter box only contains lowercase letters.
You will notice that there are more lowercase letters than uppercase letters. This is expected – a letter can only be used once on a page, after all, there are much more lowercase letters in written text than uppercase letters, as there were no Youtube comments and case locks at that time.
So what does all this have to do with strings?
Well, as printing becomes more mainstream, presses are starting to provide services to individuals, not just newspapers and publishers, who are said to decide to charge based on the length of the printed material (in feet). Of course, many are speculative, but if they string the printed materials produced together, they can easily estimate the cost and charge the customer. Therefore, we can conclude with fair certainty that they use the word string (string) to represent a sequence of characters in this case. July 26, 2017 Edit: As pointed out in the comments below, it does seem that there is an actual rope for bundling the character blocks together, as they are shipped to the press after assembly! A Twitter fan even sent me the following video demonstrating the process!
Nevertheless, what does this have to do with the field of programming? I mean, you can say a string about anything
anything What if we look at the academic community’s records of the first reference? In the 1944 "Recursive Enumerable Positive Integer Sets and Its Decision Problems", we mentioned something that might be roughly similar to modern definitions:
For the purpose of working, we introduce letter 6 and consider "strings" 1 and b, such as 11b1bb1.
Then, 14 years later, in 1958's "A Programming Language for Mechanical Translation", the word was used in this way, and only once:
Each continuation string between punctuation marks or spaces is looked up in the dictionary.
Okay, a little bit like our concept of strings, but it looks like he's just describing, um,
word
. Obviously, this doesn't apply – it's too general. However, for some reason, it seems to have become popular.(String) is used exactly the same way we are today, although there is noIn 1958's "A Command Language for Handling Symbol Strings", the word
string
definition 🎜>For this. We found another reference in the 1959 "COMIT System for Mechanical Translation": If we want to replace D SIN(F) with COS(F) D (F), where F is not limited and can be any arbitrary component sequence, we use the symbol $ to represent this string. Funny! This is the dollar sign we all know from PHP, it is actually a string sign in BASIC. Also in 1959, we obtained a more direct definition in "Share 709 System: Machine Implementation of Symbol Programming": Text is a linearly sorted bit string that represents other information needed during loading and listing. In fact, it was through the April 1960 ALGOL that strings seem to take their modern abbreviation form "string" (before this, people said string of [something]). See the abstract of this paper. Then, in May 1960, the Report on Algorithm Language ALGOL 60 mentioned it in a form that touches the core content. Since then, it has spread as quickly as modern memes. 1963's METEOR: A LISP Interpreter for String Conversion uses a rather unspecific "[...] But the simple conversion of some linear lists (strings) is very good in this symbol Difficult to define." The 1964 "On Declaration of the Arbitrary Encoding Alphabet" mentioned "character string". Search ACM shows many other resources from the 1960s and beyond, all of which now use the term regularly, so the 1960s seem to be the catalyst for the evolution of this term and make it what it is today, slowly, through Its system needs. Interestingly, it ultimately represents a similar concept to the typography era—a set of characters with meaning and brings some cost (just this time in memory). As a side note - consider all these papers from more than 60 years ago. Sixty years ago, they used perforated cards to solve computer science problems and wrote about them in their academic papers. And we are now 2017, with the 2017 JavaScript framework, arguing about who can have sex with whom in Drupal's community and trying to redefine the word Facade over and over again. When we argue about the rocket science of modern web-developed “things go into boxes, things come out of boxes”, those people shape the entire world by transforming the analog environment they are in to digital, by essentially cheating on a small squeezing of sand Remember the numbers. Conclusion So now we know—or at least think we know—string (string) comes from. Computer science has always been a dark space full of mystery and slow evolution, just as we now know that the human eye has half-stage and half-eye in its past, and terms in computer science have also transcended and evolved around its original meaning until they gave What we have today. The same concept of the same name was born in various places at the same time in the 1960s until it evolved into a unified term that we all understood and used, and most importantly, we all agreed. When you think about it carefully, can we use a better word? While strings (strings) almost feel unnatural due to a complete disconnect from similar terms in the "real world" (we won't call the text on the page "strings"), I can't think of anything more suitable for this popular data Type of terms. Can you? tell me. FAQ for Strings in Computer Programming The word "string" in computer science is believed to originate from the phrase "character string". It was first used in programming when data was often represented as a sequence or "string" of alphanumeric characters. This term is used to describe the data types as character sequences in programming languages, and it has been used to this day. Stands are sequences of characters that can include letters, numbers, and special characters. Unlike other data types such as integers or booleans (representing numerical or true/false values, respectively), strings are used to represent and manipulate text. They are basic data types in almost all programming languages, and they come with a variety of built-in methods for operation and analysis. In some programming languages such as Java and Python, strings are immutable. This means that once a string is created, it cannot be changed. This design choice is mainly for efficiency and safety reasons. Since strings are often used in large quantities in programs, making them immutable can enable the system to optimize memory usage and processing speed. It also prevents potential security risks associated with mutable strings. Stands are usually stored in memory, as a character sequence, each character takes up a certain number of bytes, depending on the character encoding used. For example, in ASCII encoding, each character occupies one byte of memory, while in Unicode encoding, a character can occupy two or more bytes. The end of a string is usually marked with special empty characters. Many operations can be performed on strings, including concatenation (concatenation of two strings together), substring extraction (get part of a string), string comparison (checking whether two strings are equal), and characters String search (find a specific character or substring in a string). These operations are usually provided as built-in methods in programming languages. Most programming languages provide functions or methods to convert strings to other data types. For example, in Python, you can use the int() function to convert a numeric string to an integer, or use the float() function to convert it to a floating point number. However, if the string does not represent a valid number, these conversions will fail. String interpolation is a programming technique in which variables or expressions are inserted directly into strings. This is often used to format strings in a more readable and convenient way. The syntax of string interpolation varies by programming language. Strings are sequences of characters, and character arrays are arrays where each element is a character. In some programming languages such as C, strings are represented as characters ending with null characters. However, in many high-level languages, strings are a separate data type with their own methods and properties. Stand literals are strings written directly to the program source code. It is usually enclosed in quotes, and whether it is single or double quotes depends on the programming language. String literals are treated as constant values, and in some languages, they are immutable. Special characters in strings, such as line breaks, tabs, or quote characters, are usually represented by escape sequences. An escape sequence is a backslash () followed by a character or character sequence. The exact syntax and available escape sequences vary by programming language.
What is the historical origin of the word "string" in computer science?
How is strings different from other data types in programming?
Why are strings immutable in some programming languages?
How are strings stored in memory?
What common operations can be performed on strings?
How to convert a string to another data type?
What is string interpolation?
What is the difference between a string and a character array?
What are string literals?
How to represent special characters in strings?
The above is the detailed content of Why Is a String Called a String?. For more information, please follow other related articles on the PHP Chinese website!

Reasons for PHPSession failure include configuration errors, cookie issues, and session expiration. 1. Configuration error: Check and set the correct session.save_path. 2.Cookie problem: Make sure the cookie is set correctly. 3.Session expires: Adjust session.gc_maxlifetime value to extend session time.

Methods to debug session problems in PHP include: 1. Check whether the session is started correctly; 2. Verify the delivery of the session ID; 3. Check the storage and reading of session data; 4. Check the server configuration. By outputting session ID and data, viewing session file content, etc., you can effectively diagnose and solve session-related problems.

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

Configuring the session lifecycle in PHP can be achieved by setting session.gc_maxlifetime and session.cookie_lifetime. 1) session.gc_maxlifetime controls the survival time of server-side session data, 2) session.cookie_lifetime controls the life cycle of client cookies. When set to 0, the cookie expires when the browser is closed.

The main advantages of using database storage sessions include persistence, scalability, and security. 1. Persistence: Even if the server restarts, the session data can remain unchanged. 2. Scalability: Applicable to distributed systems, ensuring that session data is synchronized between multiple servers. 3. Security: The database provides encrypted storage to protect sensitive information.

Implementing custom session processing in PHP can be done by implementing the SessionHandlerInterface interface. The specific steps include: 1) Creating a class that implements SessionHandlerInterface, such as CustomSessionHandler; 2) Rewriting methods in the interface (such as open, close, read, write, destroy, gc) to define the life cycle and storage method of session data; 3) Register a custom session processor in a PHP script and start the session. This allows data to be stored in media such as MySQL and Redis to improve performance, security and scalability.

SessionID is a mechanism used in web applications to track user session status. 1. It is a randomly generated string used to maintain user's identity information during multiple interactions between the user and the server. 2. The server generates and sends it to the client through cookies or URL parameters to help identify and associate these requests in multiple requests of the user. 3. Generation usually uses random algorithms to ensure uniqueness and unpredictability. 4. In actual development, in-memory databases such as Redis can be used to store session data to improve performance and security.

Managing sessions in stateless environments such as APIs can be achieved by using JWT or cookies. 1. JWT is suitable for statelessness and scalability, but it is large in size when it comes to big data. 2.Cookies are more traditional and easy to implement, but they need to be configured with caution to ensure security.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6
Visual web development tools
