Comparison of Language Syntax
Feature | C++ | Java | JavaScript | Perl | Python | Swift |
---|---|---|---|---|---|---|
Compiled | Yes | Yes | No | No | No | Yes |
Interpreted | No | Yes | Yes | Yes | Yes | No |
Source Code File Extension | .cpp | .java | .js | .pl | .py | .swift |
End-of-Statement | semi-colon | semi-colon | semi-colon | semi-colon | new line | new line (semi-colon optional) |
Multiple Statements per Line | Yes | Yes | Yes | Yes | Sometimes | Yes |
cout & << | System.out.print() | printf()† | print(String, terminator: "") | |||
print with new line | cout & endl | System.out.println() | console.log() | print & "\n" | print() | |
printf | printf() | System.out.printf() | console.log() | printf | print & % printf()† | print(String(format: String, arg...)) |
output object | cout & << | .toString() | console.dir() | Dumper() | dump() | |
Boolean Type | bool | boolean | Boolean | (scalar) | N/A | Bool |
Boolean Literals | true/false | true/false | true/false | true/false | True/False | true/false |
Truth Value | non-falsy | Boolean only | non-falsy | non-falsy | non-falsy | Boolean only |
Byte Type | char | byte | N/A | N/A | N/A | Int8 |
Char Type | char or wchar_t | char | N/A | N/A | N/A | Character |
Character Literals | single quotes | single quotes | N/A | N/A | N/A | N/A |
Char Set | ASCII | Unicode | Unicode | Unicode | Unicode | Unicode |
Integers (32-bit) | int | int | N/A | (scalar) | int | Int32 |
Long Integers (64-bit) | long | long | N/A | N/A | N/A | Int64 |
Floating Point | double | double | Number | (scalar) | float | Double |
String Type | string or wstring | String | String | (scalar) | str | String |
String Literals | double quotes | double quotes | single or double quotes | single or double quotes | single or double quotes | double quotes |
Variable Interpolation within Strings | No | No | No | Yes (double quotes only) | No | Yes |
Identifiers | ASCII alphabetic, digits, underscore | Unicode alphabetic, digits, underscore, dollar sign | Unicode alphabetic, digits, underscore, dollar sign | ASCII alphabetic, digits, underscore | ASCII alphabetic, digits, underscore | Unicode alphabetic, digits, underscore |
Hexadecimal Escape | \x## or \u#### or \U######## | \u#### | \u#### | \x## or \x{####} | \x## or \u#### | \u{####} |
Constant Declaration Keyword | const (typename) | final static (typename) | const | N/A | N/A | let |
Variable Declaration Keyword | (typename) | (typename) | var | my/our | N/A | var |
Assignment | = | = | = | = | = | = |
String Concatenation | + | + | + | . | + | + |
Equivalence | == | == | == | == (numeric) eq (string) | == | == |
≠ | != | != | != | != (numeric) ne (string) | != | != |
< | < | < | < | < (numeric) lt (string) | < | < |
≤ | <= | <= | <= | <= (numeric) le (string) | <= | <= |
> | > | > | > | > (numeric) gt (string) | > | > |
≥ | >= | >= | >= | >= (numeric) ge (string) | >= | >= |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift | |
cpp | java | js | pl | py | swift |
- † Defined in utils.py