1. A rule for transforming a message from one symbolic form (the source alphabet) into another (the target alphabet), usually without loss of information. The process of transformation is called encoding and its converse is called decoding. These processes are carried out by an encoder and a decoder respectively; the encoder and decoder may be implemented in hardware or software, the encoding and decoding processes being algorithmic in nature. The term ‘an encoding’ is sometimes used synonymously with ‘a code’.
From a more formal viewpoint, a code is a one-to-one homomorphism h from the set of Σ-words, Σ1*, to the set Σ2*, where Σ1 and Σ2 are alphabets (see word, formal language). Since h is one to one, h(w) may be ‘decoded’ to obtain w for any w in Σ1*.
See also channel coding theorem, cryptography, error-correcting code, error-detecting code, fixed-length code, source coding theorem, variable-length code.
2. Any piece of program text written in a programming language (as opposed to a data structure or algorithm illustrated by a diagram or flowchart, or a program specified or sketched out in natural language prose). The term sometimes implies executable code as opposed to declarations or tables, but this is by no means always the case. See also coding.
3. The particular language in which some code is written, e.g. machine code, source code.