Comparison of programming languages (strings)
From Wikipedia, the free encyclopedia
This article is part of the Programming Language Comparison series. |
General Comparison |
Basic Syntax |
String Operations |
String Functions |
List of "hello world" programs |
|
Compatibility of C and C++ |
Comparison of C# and Java |
Comparison of C# and Visual Basic .NET |
Comparison of Pascal and C |
Comparison of SQL variants |
Contents |
[edit] Concatenation
Common variants:
- BASIC, Pascal, Delphi, Javascript, Java, Python, C++ and Ruby ;; "+".
- Perl, PHP, Maple ;; "." sign.
- Perl 6 ;; "~" sign.
- Standard SQL, PL/I, Rexx, and Maple (from version 6) ;; double pipe signs ("||").
- Mathematica ;; "<>".
- Lua ;; "..".
- The J programming language ;; ",".
- AppleScript and VHDL ;; "&".
- OCaml ;; "^".
Unique variants:
- Visual Basic uses the "&" sign. Versions 1 to 6 can also use the "+" sign but this leads to ambiguity if a string representing a number and a number is added together.
- MATLAB uses the syntax "[x y]" to concatenate x and y.
- C allows juxtaposition for string literals, however, for strings stored as character arrays, the strcat function must be used.
- Octave uses the syntax "[x, y]" to concatenate x and y.
- Awk uses the empty string: You just have to write two expressions adjacent to each other to concatenate them. This is called Juxtaposition. Unix shells have a similar syntax. Rexx uses this syntax for concatenation including an intervening space.
[edit] String literals
This section compares styles for declaring a string literal.
[edit] Quoted raw
<![CDATA[ TheQuickBrownFox ]]> ;; CDATA section ;; XML
[edit] Quoted interpolated
todo
[edit] Dual quoting
todo
[edit] Multiple quoting
todo
[edit] Unique quoting variants
16HTheQuickBrownFox ;; Hollerith notation ;; Fortran (indented with whitespace) ;; Indented with whiteapce and newlines ;; YAML