Here is a list of features common to most programming languages, but implemented in a different way by each language. Some of the differences are rather trivial, but some make a large difference in a language's potential.
REM A comment in DOS and BASIC
' A comment in Visual Basic
<!-- A comment in HTML and XML -->
C A comment in FORTRAN
(* A comment in PASCAL *)
NOTE A comment in COBOL
COMMENT A comment in ALGOL-60
# A comment in tcl, PERL, and PHP
/* A multi-line comment in PL/I and the C family */
// A single line comment in PL/I and the C family
This includes the general syntax of most of the lines of code in the program. This is usually very language specific.
Hello is not the same as hello.if (x <= 3) {
run(y);
}
If (x <= 3) Then
run(y)
End If
if x <= 3:
run(y)
(defun helloworld () (format t "hello, world") )
All programs deal with data. Mouse movements, sound, pictures, and video are all nothing but 0s and 1s on computers. This data is often presented in basic data types. This include various kinds of numeric, Boolean, array, and text data types.
See also my article on Data Types.
All the variables and modular chunks of code have to be distinguished by an identifier, i.e. they should be named. If the programming language is OOP, then instance of objects have to be named too.
Operators are the symbols that denote basic functions performed. Operators have zero or more expressions (parameter or arguments) that they work upon.
Math. Here are some common ones:
| Operator | Symbol |
Input 9 and 4 |
Note |
|---|---|---|---|
| Addition | + | 13 | |
| Subtraction | - | 5 | |
| Division | / | 2.25 | |
| Multiplication | * | 36 | |
|
Modulus aka Modulo |
% mod |
1 | The remainder after division. |
|
Integer Division |
\ | 2 | The integer after division. |
Assignment. These usually assigns values to identifiers. This syntax is usually like variable = 1 .
Boolean (a.k.a. Logical). These usually perform compare two expressions (each of which is either true, false, or null) and returns TRUE and FALSE values. The NOT operator only needs one expression. Here are some common ones:
| NOT | |
|---|---|
| True | False |
| False | True |
| Null | Null |
| AND | True | False | Null |
|---|---|---|---|
| True | True | False | Null |
| False | False | False | False |
| Null | Null | False | False |
| OR | True | False | Null |
|---|---|---|---|
| True | True | True | True |
| False | True | False | Null |
| Null | True | Null | Null |
| XOR | True | False | Null |
|---|---|---|---|
| True | False | True | Null |
| False | True | False | Null |
| Null | Null | Null | Null |
| EQV | True | False | Null |
|---|---|---|---|
| True | True | False | Null |
| False | False | True | Null |
| Null | Null | Null | Null |
| IMP | True | False | Null |
|---|---|---|---|
| True | True | False | Null |
| False | True | True | True |
| Null | True | Null | Null |
Bitwise. These perform bit manipulations, i.e. they take the binary representation of numbers and perform Boolean math upon them. EG:
9 & 4 is just like
9 = 1001
4 = 0100 &
-----
0000 = 0
Here are some common ones:
| Operator | Symbol |
Input 9 and 4 |
|---|---|---|
| Bitwise AND |
& AND |
0 |
| Bitwise OR |
| OR |
13 |
| Bitwise XOR |
^ XOR |
13 |
Comparison. A variation on Boolean operators, these usually compare two expressions and return a true or false value. Here are some common ones.
| Operator | Symbol |
Input 9 and 4 |
|---|---|---|
| Equal to |
= == |
FALSE |
| Greater than | > | TRUE |
| Less than | < | FALSE |
| Greater than or equal to | >= | TRUE |
| Less than or equal to | <= | FALSE |
| Not equal to | <> | TRUE |
| Not equal to | != | TRUE |
| Not less than | !< | TRUE |
| Not greater than | !> | FALSE |
String. There usually manipulate strings of characters. String concatenation is the most common and often has syntax like this: 'hel' & 'lo' or 'hel' + 'lo'.
Unary. These perform a function on a single expression. Here are some common ones:
| Operator | Symbol |
Input 9 |
|---|---|---|
| Numeric value is positive. | + | 9 |
| Numeric value is negative. | - | -9 |
|
Returns the ones complement of the number. NOT the significant binary number for the "negative" value. |
~ | -10 |
Operators usually usually have an order of precedence. Operators of higher precedence are performed before those of lower precedence. When operators have the same precedence, they are evaluated left to right. Parentheses are often used to clarify precedence. EG:
x = 2 + 3 * 5
'x is 17 because multiplication has precedence
x = 2 + (3 * 5)
'x is 17
x = (2 + 3) * 5
'x is 30
Flow Control (aka Control Flow; control of flow) is how a programming deals with options.
IF condition THEN do this
IF condition1 THEN do this ELSE IF condition2 THEN do this ELSE do this
SELECT CASE expression CASE expression value list 1 do this CASE expression value list 2 do this CASE ELSE do this END SELECT
GO TO this part of the program
DO this code UNTIL this condition is met LOOP
FOR counter values x TO y do this NEXT increment the counter
Note that in an OOP (Object Oriented Programming) language, objects can be intrinsic and user-defined as well!
Functions are either deterministic or non-deterministic. A deterministic function always returns the same results when fed the same arguments. A non-deterministic function may return different results for the same set of arguments.
Functions are sometimes grouped according to the numbers of arguments they accept:
| No. of Arguments | Group |
|---|---|
| 0 | nullary or nilladic |
| 1 | unary |
| 2 | binary |
| 3 | ternary |
Functions and subroutines both do work, but whereas a function usually returns a value with its identifier, a subroutine does not. EG:
x = ThisFunctionReturnsAValue(ArgumentPassed)
ThisSubroutineDoesNotReturnAValue(ArgumentPassed)
The different ways that data goes into and out of the program, including the following:
Various methods of stopping, pausing, or otherwise interrupting a program. This is also used in debugging programs. Some programming languages have no stops until the program ends.
Page Modified: (Hand noted: 2007-09-14 20:33:54Z) (Auto noted: 2007-11-17 06:38:19Z)