Comparison of programming languages (strings): Difference between revisions

Content deleted Content added
m spelling (WP:Typo Team)
m v2.05 - Fix errors for CW project (Reference list missing / disambiguation page with disallowed <ref>)
 
(19 intermediate revisions by 12 users not shown)
Line 1:
{{Unreferenced|date=February 2009}}
{{ProgLangCompare}}
 
Line 8 ⟶ 7:
 
===Common variants===
 
{| class="wikitable"
|-
Line 15 ⟶ 13:
|-
| +
| [[ALGOL 68]], [[BASIC programming language|BASIC]], [[C++]], [[C Sharp (programming language)|C#]], [[Cobra (programming language)|Cobra]], [[PascalDart (programming language)|PascalDart]], [[ObjectEiffel Pascal(programming language)|Eiffel]], [[EiffelF Sharp (programming language)|EiffelF#]], [[Go (programming language)|Go]], [[JavaScript]], [[Java (programming language)|Java]], [[PythonJavaScript]], [[Object Pascal]], [[Objective-C]], [[Pascal (programming language)|PythonPascal]], [[TuringPython (programming language)|TuringPython]], [[Ruby (programming language)|Ruby]], [[Rust (programming language)|Rust]], [[WindowsScala PowerShell]],(programming [[Objective-Clanguage)|Scala]], [[Swift (programming language)|Swift]], [[F SharpTuring (programming language)|F#Turing]], [[ScalaWindows (programming language)|ScalaPowerShell]], Ya
|-
| ++
| [[HaskellErlang (programming language)|HaskellErlang]], [[Erlang (programming language)|ErlangHaskell]]
|-
| $+
| [[MIRCmIRC scripting language|mIRC Scripting Language]]
|-
| &
| [[Ada (programming language)|Ada]], [[AppleScript]], [[COBOL]] (for literals only), [[Curl (programming language)|Curl]], [[Seed7Microsoft Excel|Excel]], [[VHDLFreeBASIC]], [[Visual BasicHyperTalk]], [[VisualNim Basic(programming .NETlanguage)|Nim]], [[MicrosoftSeed7]], Excel|Excel[[VHDL]], [[FreeBASICVisual Basic]], [[NimVisual (programmingBasic language)|Nim.NET]]
|-
| concatenate
| nconc
| [[Common Lisp]]
|-
| .
| [[Perl]]Autohotkey, [[PHP]], and [[Maple computer algebra system(software)|Maple]] (up to version 5), Autohotkey[[Perl]], [[PHP]]
|-
| ~
| [[RakuD (programming language)|RakuD]] and, [[DRaku (programming language)|DRaku]], [[Symfony]] (Expression Language component)
|-
| <nowiki>||</nowiki>
| [[Icon (programming language)|Icon]], Standard [[SQLMaple (software)|Maple]] (from version 6), [[PL/I]], [[Rexx]], andStandard [[Maple computer algebra system|MapleSQL]] (from version 6)
|-
| <>
| [[Mathematica]], [[Wolfram Language]], [[Elixir (programming language)|Elixir]]
|-
| ..
| [[Lua (programming language)|Lua]]
|-
| :
| [[Pick Basic]]
|-
| ,
| [[JAPL (programming language)|APL]], [[Smalltalk]], [[APLJ (programming language)|APLJ]], [[Smalltalk]]
|-
| ^
| [[OCamlF Sharp (programming language)|F#]], [[Standard MLOCaml]], [[F SharpRc (programmingUnix languageshell)|F#rc]], [[rcStandard ML]]
|-
| //
Line 62 ⟶ 60:
===Unique variants===
 
* [[AwkAWK]] uses the empty string: two expressions adjacent to each other are concatenated. This is called [[Juxtaposition (literary)|juxtaposition]]. [[Unix shell]]s have a similar syntax. [[Rexx]] uses this syntax for concatenation including an intervening space.
* [[C (programming language)|C]] (along with [[Python (programming language)|Python]] and [[Dart (programming language)|Dart]]<ref>{{Cite web |title=Built-in types |url=https://dart.dev/language/built-in-types/ |access-date=2025-07-22 |website=dart.dev |language=en}}</ref>) allows juxtaposition for string literals, however, for strings stored as [[Character (computing)|character]] [[Array data structure|arrays]], the <code>[[strcat]]</code> function must be used.
* [[COBOL]] uses the <code>STRING</code> statement to concatenate string variables.
* [[MATLAB]] and [[GNU Octave programming language|Octave]] use the syntax "<code>[x y]</code>" to concatenate x and y.
* [[Visual Basic]] and [[Visual Basic .NET]] can also use the "<code>+</code>" sign but at the risk of ambiguity if a string representing a number and a number are together.
* [[Microsoft Excel]] allows both "<code>&</code>" and the function "<code>=CONCATENATE(X,Y)</code>".
Line 85 ⟶ 83:
|-
| <code>"Hello, $name!"</code>
| [[Bourne shell]], Dart, Perl, PHP, Windows PowerShell
|-
| <code>qq(Hello, $name!)</code>
Line 94 ⟶ 92:
|-
| <code>"Hello, #{name}!"</code>
| CoffeeScript, Ruby, [[Elixir (programming language)|Elixir]]
|-
| <code>%Q(Hello, #{name}!)</code>
| Ruby (alternate)
|-
| <code>(format tnil "Hello, ~A" name)</code>
|[[Common Lisp]]
|-
| <code>`Hello, ${name}!`</code>
Line 121 ⟶ 119:
|-
| <code>"I said \"Hello, world!\""</code>
| C, C++, C#, D, Dart, F#, Java, JavaScript, Mathematica, Ocaml, Perl, PHP, Python, Rust, Swift, Wolfram Language, Ya
|-
| {{nowrap|<code><nowiki>'I said \'Hello, world!\''</nowiki></code>}}
| CoffeeScript, Dart (alternate), JavaScript (alternate), Python (alternate)
|-
| <code>"I said `"Hello, world!`""</code>
Line 141 ⟶ 139:
| FreeBASIC
|-
| {{nowrap|<code>r#"I said "Hello, world!""#</code>}}
|Rust (alternate)
|-
| {{nowrap|<code>R"("I said "Hello, world!")"</code>}}
|C++ (alternate)
|}
 
Line 154 ⟶ 155:
|-
| <code>"I said ""Hello, world!"""</code>
| Ada, ALGOL 68, COBOL, Excel, Fortran, FreeBASIC, Visual Basic (.NET), FreeBASIC, COBOL
|-
| <code><nowiki>'I said ''Hello, world!'''</nowiki></code>
| Fortran, rcAPL, COBOL, SQLFortran, Object Pascal, Object Pascal, APLrc, Smalltalk, SQL
|}
 
Line 169 ⟶ 170:
|-
| <code>'Hello, world!'</code>
| APL, Bourne shell, Fortran, Object Pascal, Pascal, Perl, PHP, Pick Basic, Ruby, Smalltalk, Windows PowerShell, Smalltalk
|-
| <code>q(Hello, world!)</code>
Line 184 ⟶ 185:
|-
| <code>r"Hello, world!"</code>
| Cobra, D, Dart, Python, Rust
|-
| <code>r'Hello, world!'</code>
| Dart (alternate)
|-
| <code>"Hello, world!"</code>
Line 205 ⟶ 209:
|-
! Syntax
! Here <br/>document
! Language(s)
|-
Line 212 ⟶ 216:
and so little time to say them
EOF</pre>
| {{Yes}}
| Bourne shell, Perl, PHP, Ruby
|-
| <pre><<<EOF
Line 219 ⟶ 223:
and so little time to say them
EOF</pre>
| {{Yes}}
| PHP
|-
Line 226 ⟶ 230:
and so little time to say them
"@</pre>
| {{No}}
| Windows Powershell
|-
Line 233 ⟶ 237:
and so little time to say them
]"</pre>
| {{No}}
| Eiffel
|-
Line 240 ⟶ 244:
and so little time to say them
"""</pre>
| {{No}}
| CoffeeScript, PythonDart, Groovy, SwiftKotlin, KotlinPython, Swift
|-
|<pre>"
Line 247 ⟶ 251:
and so little time to say them
"</pre>
| {{No}}
|Visual[[Common Basic .NETLisp]] (all strings are multiline), Rust (all strings are multiline), Visual Basic .NET (all strings are multiline)
|-
| <pre>R"(
I have a lot of things to say
and so little time to say them
)"
</pre>
| {{No}}
| C++
|-
| <pre>r"
Line 254 ⟶ 266:
and so little time to say them
"</pre>
| {{No}}
| Rust
|-
Line 261 ⟶ 273:
and so little time to say them
]]</pre>
| {{No}}
| Lua
|-
Line 268 ⟶ 280:
and so little time to say them
`</pre>
| {{No}}
| JavaScript (ECMAScript 6)
|}
Line 292 ⟶ 304:
:1. {{note|es6rawstr}} <code>String.raw``</code> still processes string interpolation.
 
== References ==
{{Reflist}}
:1. {{note|es6rawstr}} https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/raw