Programming Language Features

The designers of computer programming languages have to address a myriad of problems. It can be informative to see the different choices made. The notes below show in tabular form some of the solutions chosen.

Approximate dates are given for the designs and they are presented in chronological order. This helps to illustrate how a given language design changed and how different options were chosen over time.

Comment delimiters

To end of line Within a line Multiple lines
Fortran IV 1962 C in the 1st column
Basic 1964 rem comment
BCPL 1967 //comment
B 1969 /*comment*/ /*comment*/ (not nestable)
Pascal 1970 {comment} {comment} (not nestable)
C 1975 /*comment*/ /*comment*/ (not nestable)
Ada 1983 —comment
C++ 1985 //comment /*comment*/ /*comment*/ (not nestable)
Python 1994 #comment
Java 1995 //comment /*comment*/ /*comment*/ (not nestable)

Identifier names

First character Subsequent characters Max size Significant characters for internal identifiers Significant characters for external identifiers
C 1975 [a-zA-Z_] [a-zA-Z_0-9] arbitrary <= 8 <= 7

Based numeric literals

Binary Octal Decimal Hexadecimal Other
BCPL 1967 #digits #xdigits
B 1969 [[octal-zero-prefix|0digits]]
Macro-11 1970 ^B or .radix 2 ^O or .radix 8 ^D or .radix 10 or trailing dot
C 1975 0digits 0xdigits
Ada 1983 2#digits# 8#digits# 10#digits# 16#digits# base#digits#
Apsul 2012 2'digits 8'digits 10'digits d'digits 16'digits h'digits base'digits

Notes

  • The assembler Macro-11 1970 uses octal as the default base. All the other languages use decimal as the default.
  • In B 1969 the text 010 means 8 but note that, bizarrely, 09 is also accepted and means 9. See [[octal-zero-prefix]] for related information.
  • Ada 1983 allows an exponent after the final #. Base and exponent are always in decimal.

Type of numeric literals

Decimal integer Other-base integer With decimal point
C 1975 int int double

String delimiters

Delimiters
C 1975 "string"
Perl 1977 'string' or "string" or q(string) or qq(string)
Python 1994 'string' (preferred) or "string"

Notes

  • Perl 1977 allows variable substitution in double-quoted strings.

Character delimiters

Delimiters
C 1975 'character'
C++ 1983 'character'

Notes

  • C 1975 and C++ 1983 use single quotes (') to delimit a character constant such as 'a' as they distinguish between a single character and a string of one character. A single character occupies one cell. Conversely, a string of one character has a trailing zero and occupies two cells.

Character IDs

The number after each character name is the ordinal in ASCII.

Bell(7) Backspace(8) Tab(9) LF(10) VTab(11) FF(12) CR(13) Octal Hex Unicode
C 1975 \b \t \n \r \digits
Python 1994 \a \b \t \n \v \f \r \ddd \xdd
Java 1995 \b \t \n \f \r \ddd \uxxxx

Notes

  • C 1975 allows 1 to 3 octal digits to specify a character. The sequence \0 (not followed by a digit) indicates a null character.

Embedded characters

When certain characters are embedded in string literals they require escaping.

Escape sequence Double quote Backslash
C 1975 \character \" \\

Basic arithmetic operations

Add Subtract Multiply Exponentiation Absolute value
Basic 1964 + - * ^
BCPL 1967 + - *
Pascal 1970 + - *
C 1975 + - *
Ada 1983 + - * ** abs
Python 1994 + - *

Notes

  • In Basic 1964 the up arrow (^) takes the absolute value of the left operand before raising it to a power.

Addition operations between

chars ints int and char int/char and float int/char and double float and float float and double
C 1975 int int int double double float double

Subtraction operations between

chars ints int and char int/char and float int/char and double float and float double and double
C 1975 int int int double double float double

Multiplcation operations between

chars ints int and char int/char and float int/char and double float and float float and double
C 1975 int int int double double float double

Division operations

Between integers Mixed integer and float Between floats Forced integer division
BCPL 1967 /
Pascal 1970 div div
C 1975 / / (the integer converted to double) /
C 1989 and C++ 1983 / / (the int converted) /
C 1999 / / (the int converted) /
Ada 1983 /, mod not permitted /
Python 1994 / / (the int converted to float) / //

Integer remainder operations

Operator Sign of Remainder
BCPL 1967 rem Depends on implementation
Pascal 1970 mod Depends on version
C 1975 % See notes
C 1983 % Depends on implementation
Ada 1983 rem Sign of dividend
Ada 1983 mod Sign of divisor
C 1999 % Sign of dividend
Python 1994 % Sign of divisor
Java 1995 % Sign of dividend

Notes

  • The C 1975 manual states the current implementation of % has the same sign as the dividend. This suggests it is not part of the language design.

Division operations between

chars ints int and char int/char and float int/char and double float and float float and double
C 1975 int int int double double float double

Relational operators

Less than Not less than Less than or equal Not less than or equal Equal Not equal Greater than or equal Not greater than or equal Greater than Not greater than
Fortran IV 1962 .LT. .LE. .EQ. .NE. .GE. .GT.
Pascal 1970 < <= = <> >= >
Fortran 1977 .LT. .LE. .EQ. (for numbers), .EQV. (for booleans) .NE. (for numbers), .NEQV. (for booleans) .GE. .GT
C 1975 < <= == != >= >
C++ 1983 < <= == != >= >
Ada 1983 < <= = /= >= >
Python 1994 < <= == <> (obsolete), != >= >

Boolean operators

Logical negation Non-shortcut logical and Shortcut logical and Non-shortcut logical or Shortcut logical or Exclusive or
Pascal 1970 not and and then or or else
C 1975 ! && ||
Ada 1983 not and and then or or else xor
Python 1994 not and or

Bitwise in-place operators

Not (ones complement) And Or Exclusive or
Pascal 1970 ~ & | or !
C 1975 ~ & | ^
Python 1994 ~ & | ^
Fortran 1995 .not. .and. .or. .eor.

Bitwise movement operators

Logical shift left Logical shift right Arithmetic shift right Rotate left without carry Rotate right wihout carry Rotate left with carry Rotate right with carry
C 1975 << >>
Python 1994 << >>
Fortran 1995

Set operations

Union Difference Intersection Test of membership
Pascal 1970 + - * in

Type support

Boolean Numbers Individual characters Strings of characters Record structures Arrays
Fortran IV 1962 result of expression only yes no as output only no yes
Basic 1964 result of expression only yes no as output only no yes
C 1975 implicit - zero or nonzero yes yes yes yes yes

Numeric types

Integers Non-integer fixed point Floating point Complex Rational
Fortran IV 1962 single type no two widths single type no
Basic 1964 no no up to 9 digits no no
C 1972 various widths no two widths no no

References

Sources in date order for the information presented above.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License