This comparison of programming languages (strings) compares the features of string data structures or text-string processing for over 52 various computer programming languages.
Different languages use different symbols for the concatenation operator. Many languages use the "+" symbol, though several deviate from this.
strcat
STRING
[x y]
+
&
=CONCATENATE(X,Y)
concat!
format!
This section compares styles for declaring a string literal.
An expression is "interpolated" into a string when the compiler/interpreter evaluates it and inserts the result in its place.
$"hello, {name}"
"Hello, $name!"
qq(Hello, $name!)
"Hello, {$name}!"
"Hello, #{name}!"
%Q(Hello, #{name}!)
(format nil "Hello, ~A" name)
`Hello, ${name}!`
"Hello, \(name)!"
f'Hello, {name}!'
"Escaped" quotes means that a 'flag' symbol is used to warn that the character after the flag is used in the string rather than ending the string.
"I said \"Hello, world!\""
'I said \'Hello, world!\''
"I said `"Hello, world!`""
"I said ^"Hello, world!^""
{I said "Hello, world!"}
"I said, %"Hello, World!%""
!"I said \"Hello, world!\""
r#"I said "Hello, world!""#
R"("I said "Hello, world!")"
"Dual quoting" means that whenever a quote is used in a string, it is used twice, and one of them is discarded and the single quote is then used within the string.
"I said ""Hello, world!"""
'I said ''Hello, world!'''
"Raw" means the compiler treats every character within the literal exactly as written, without processing any escapes or interpolations.
'Hello, world!'
q(Hello, world!)
%q(Hello, world!)
R"(Hello, world!)"
@"Hello, world!"
r"Hello, world!"
r'Hello, world!'
"Hello, world!"
`Hello, world!`
raw"Hello, world!"
String.raw`Hello, World!`
Many languages have a syntax specifically intended for strings with multiple lines. In some of these languages, this syntax is a here document or "heredoc": A token representing the string is put in the middle of a line of code, but the code continues after the starting token and the string's content doesn't appear until the next line. In other languages, the string's content starts immediately after the starting token and the code continues after the string literal's terminator.
<<EOF I have a lot of things to say and so little time to say them EOF
<<<EOF I have a lot of things to say and so little time to say them EOF
@" I have a lot of things to say and so little time to say them "@
"[ I have a lot of things to say and so little time to say them ]"
""" I have a lot of things to say and so little time to say them """
" I have a lot of things to say and so little time to say them "
R"( I have a lot of things to say and so little time to say them )"
r" I have a lot of things to say and so little time to say them "
[[ I have a lot of things to say and so little time to say them ]]
` I have a lot of things to say and so little time to say them `
13HHello, world!
String.raw``