Joseph R. Shinnerl

Basic Terminology for Programming in C++

Most of the following definitions are adapted from The C++ Programming Language (3rd edition) by B. Stroustrup. As phrased below, some of the definitions are circular. The circularity can be replaced by a formal recursion (with base cases), but for clarity, it is left in. Italicized words are defined separately.
bit
Binary Digit. That is, a variable quantity capable of holding exactly one of two possible values. By convention, these values are labeled 0 (zero) and 1 (one). A byte is 8 bits.
A kilobyte (KB) is 210 bytes = 1024 bytes.
A megabyte (MB) is 220 bytes = 1024 KB.
A gigabyte (GB) is 230 bytes = 1024 MB.
A terabyte (TB) is 240 bytes = 1024 GB.
A petabyte (PB) is 250 bytes = 1024 TB.
An exabyte (EB) is 260 bytes = 1024 PB.
type
A rule or set of rules for
  1. the translation of certain symbols or symbol sequences into a specified number of bits
  2. the syntax involving identifiers declared to have that type.
Notes:
object
A contiguous region of memory with a type. First-class objects are endowed with all the "usual" operations, e.g., assignment, and can generally be handled just as the basic built-in types (int, double, char, bool) are handled. Second-class objects (e.g., arrays) have special syntactical restrictions on their usage (e.g., assignment is not defined for arrays).
grammar
The formal definition of the language. The grammar specifies what combinations of symbols are legal and how these combinations are evaluated.
expression
A sequence of symbols that can be reduced to a single value of a specific type.
Notes:
identifier
A programmer-specified name; a sequence of characters associated with and used to access a particular object, class or struct, or function. Every identifier has a scope.
scope
The source code extending from a declaration up until the end of the block which contains the declaration.
lifetime
The interval of run-time during which a particular object is reserved for use by the program.

The lifetime of an object whose memory is reserved at compile time (a statically allocated object) is simply the time required to execute the instructions for all statements in its scope. A statically allocated object "dies" when its identifier goes out of scope. The lifetime of an object whose memory is reserved at run-time (a dynamically allocated object) extends from the time at which the memory is allocated to the time at which is deallocated. For dynamically allocated objects, there is no connection between scope and lifetime.

declaration
The introduction of a name (identifier) into a scope.
definition
The association of an identifier with a specific object (in memory).
Every definition is also a declaration, and most declarations are also definitions. But not every declaration is a definition. For example, extern int i; introduces the identifier i into the current scope, but the extern specifier says that the associated object was already created elsewhere (e.g., another file) in the source code.
statement
Any of the following: Note: Many authors reserve the word block for sequences of statements that contain declarations.
parse
To break a program, statement, or expression into its component parts.
compiler
A program that translates high-level source code, e.g., C++, into low-level machine language. Some compilers output assembly language which is then converted to machine language by a separate assembler. A compiler must first separate the statements of the source code from one another before it can translate them. Each statement must then be translated by evaluating its expressions according to the grammar. Both of these steps use parsing.
variable
An object with an identifier. It follows that a variable has all the following attributes.
  1. A contiguous region of storage
  2. An address
  3. A type
  4. A value
  5. A name
  6. A scope
  7. A lifetime
  8. A storage class (automatic, static, extern, or register).