Comparison of programming languages (strings)

Comparison of programming languages (strings)
Programming language comparisons
General comparison
Basic syntax
Basic instructions
Arrays
Associative arrays
String operations
String functions
List comprehension
Object-oriented programming
Object-oriented constructors
Database access
Database RDBMS

Evaluation strategy
List of "hello world" programs

ALGOL 58's influence on ALGOL 60
ALGOL 60: Comparisons with other languages
Comparison of ALGOL 68 and C++
ALGOL 68: Comparisons with other languages
Compatibility of C and C++
Comparison of Pascal and Borland Delphi
Comparison of Object Pascal and C
Comparison of Pascal and C
Comparison of Java and C++
Comparison of C# and Java
Comparison of C# and Visual Basic .NET
This box: view · talk · edit


Contents

Concatenation

Different languages use different symbols for the concatenation operator. Most languages use the "+" symbol, though several deviate from this norm.

Common variants

Operator Languages
+ ALGOL 68, BASIC, C++, C#, Pascal, Object Pascal, Eiffel, Go, JavaScript, Java, Python, Turing, Ruby, Windows PowerShell, Objective-C, F#
++ Haskell
$+ mIRC Scripting Language
& Ada, AppleScript, Curl, VHDL, Visual Basic, Excel
. Perl (before version 6), PHP, and Maple (up to version 5), Autohotkey
~ Perl 6 and D
|| Icon, Standard SQL, PL/I, Rexx, and Maple (from version 6)
<> Mathematica
.. Lua
, J programming language, Smalltalk
^ OCaml, Standard ML, F#, rc
// Fortran

Unique variants

  • Awk uses the empty string: two expressions adjacent to each other are concatenated. This is called juxtaposition. Unix shells have a similar syntax. Rexx uses this syntax for concatenation including an intervening space.
  • C allows juxtaposition for string literals, however, for strings stored as character arrays, the strcat function must be used.
  • MATLAB and Octave use the syntax "[x y]" to concatenate x and y.
  • Visual Basic 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.
  • Microsoft Excel allows both "&" and the function "=CONCATENATE(X,Y)".

String literals

This section compares styles for declaring a string literal.

Quoted raw

Syntax Language(s)
@"Hello, world!" C#, F#
"Hello, world!" Java
r"Hello, world!" Python
'Hello, world!' Pascal, Object Pascal, PHP, Perl, Windows PowerShell
<![CDATA[Hello, world!]]> XML (CDATA section)
`Hello, world!` Go, Smalltalk

Quoted interpolated

Syntax Language(s)
"Hello, $name!" PHP, Perl, Windows PowerShell
"Hello, #{name}!" Ruby

Escaped quotes

Syntax Language(s)
"I said \"Hello, world!\"" C, C++, C#, F#, Java, Ocaml, Python
"I said `"Hello, world!`"" Windows Powershell
"I said ^"Hello, world!^"" REBOL
"I said, %"Hello, World!%"" Eiffel

Dual quoting

Syntax Language(s)
"I said ""Hello, world!""" ALGOL 68, Excel, Visual Basic, COBOL
'I said ''Hello, world!''' rc

Multiple quoting

Syntax Language(s)
qq(I said "Hello, world!") Perl
 %Q(I said "Hello, world!")
 %(I said "Hello, world!")
Ruby
{I said "Hello, world!"} REBOL

Here document

Syntax Language(s)
<<EOF
I have a lot of things to say
and so little time to say them
EOF
Perl, PHP, Ruby
@"
I have a lot of things to say
and so little time to say them
"@
Windows Powershell
"[
I have a lot of things to say
and so little time to say them
]"
Eiffel

Unique quoting variants

Syntax Variant name Language(s)
′I said ′′Hello, world!′′.′ Double quoting Smalltalk
'I said ''Hello, world!''.'
Double quoting Pascal, Object Pascal
"""Hello, world!""" Triple quoting Python
13HHello, world! Hollerith notation Fortran 77
(indented with whitespace) Indented with whitespace and newlines YAML

Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Comparison of programming languages (basic instructions) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison of programming languages (mapping) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison of programming languages (syntax) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison of programming languages (string functions) — String functions redirects here. For string functions in formal language theory, see String operations. Programming language comparisons General comparison Basic syntax Basic instructions Arrays …   Wikipedia

  • Comparison of programming languages (array) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison (computer programming) — Ifeq redirects here. For the MediaWiki feature, see Wikipedia:Ifeq In computer programming, comparison of two data items is effected by the comparison operators typically written as: > (greater than) < (less than) >= (greater than or… …   Wikipedia

  • Programming language — lists Alphabetical Categorical Chronological Generational A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that… …   Wikipedia

  • Comparison of Pascal and C — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison of Java and C++ — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison of Object Pascal and C — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”