Glossary of Terms

Here are some computing and programming terms that you may come across in this class, and may not be familiar with. Suggestions for additions are welcome.

Source code

The (human-readable) text of a program.

Executable

Refers to the runnable program output by the compiler on input of your source code. It contains the instructions of your program translated into the computer’s native language (“machine code”).1

Shell

A program that helps you run other programs. For example, bash which is what runs in your terminal windows.

Variable

A named memory location. See examples below.

Identifier

Sequence of characters that could be the name of a variable. In C/C++, identifiers can only begin with a letter or underscore, followed by other alphanumeric or underscore characters. They are also case-sensitive (so abc, Abc and ABC are all different).

Datatype

An annotation of a variable, which determines how much space is needed to store the variable and how to interpret the data. Examples:

int x; /* x is of type 'int'. On most computers, it will require 4 bytes
          and can hold integer values from -2^31 to 2^31-1 */
unsigned int y; /* type of y is 'unsigned int'. Range: 0 <= y < 2^32 */
char c; /* type is 'char', which holds values from 0 to 255.
           note that they are *interpreted* differently than integers: */
c = 65;
x = 65;
cout << c << "\n";  /* prints 'A' */
cout << x << "\n";  /* prints 65 */

Expression

A unit of a program which has a value (and thus a datatype). Examples:

72        /* type: integer */
72.0      /* type: double */
(x < 99)  /* type: boolean */
'A'       /* type: char */
"abcdefg" /* type: array of char */
(34 + 99.7)*132 /* type: double (thanks to the 99.7) */

Literal

An expression that somehow “represents itself”. E.g., 72, or "abc".

Statement

A unit of a program that describes an action to be performed. Think of it kind of like a sentence in a spoken language (each sentence has to have a verb somewhere). Examples:

cout << x;  /* print x's contents to stdout */
y = 99;     /* place the constant 99 into the memory labeled by y */
;           /* the empty statement ("do nothing") also counts */

Namespace

An organizational tool for symbols (like variable names). Think of it like a family name. For example, cout is the variable’s first name, while its full name is really std::cout.

Function

A grouped, named sequence of statements, optionally with parameters (see below for details). Somewhat models the mathematical notion of “function”, but there are many important differences in languages like C++. Example:

int max(int a, int b)
{
    if (a < b) return b;
    return a;
}

Formal parameter

The symbol used for a function input in the function’s description. In the example above, a and b are the formal parameters of max.

Actual parameter

A variable (or more generally, an expression) upon which a function acts during a call. For example, y and 82 are the actual parameters in the following call:

x = max(y,82);

Function body

The sequence of statements inside the {...} that will be executed upon calling said function. For the max function above:

{
    if (a < b) return b;
    return a;
}

Function header

The beginning of the function definition which prescribes the return type and the parameter list. For max:

int max(int a, int b)

Function prototype

A declaration of a function which does not include the body.2 For max:

int max(int a, int b); /* note the semicolon at the end. */
/* Note: you don't even have to name the parameters.  This also works: */
int max(int, int);

Scope (of a variable)

The context of a program where a variable is defined, or “makes sense”. For example, in the max function above, the scope of a is limited to the body of the max function. Any reference to a outside of that function will either (1) fail to compile, or (2) will refer to a different variable named a. Variables which are confined to some (non-trivial) scope are called local variables. Variables defined outside of all functions are called global variables. In addition to functions, other constructs (loops, conditionals) also create new scopes. In fact, you can artificially introduce a new scope simply by adding surrounding braces {}. Example:

int main() {
    int x = 100;
    cout << x << "\n";  /* works fine; x declared in this scope */
    {   /* these braces create a new scope!  any variables declared within
         * the braces will be *local* to this new scope: */
        int y = x*x;
        cout << y << "\n";  /* works fine; y is in scope. */
    }
    cout << y << "\n";  /* won't compile! y is now out of scope */
    return 0;
}

Overloaded function

You can make more than one function with the same name, as long as the compiler would be able to distinguish them from a function call. Examples:

int max(int a, int b);
int max(int a, int b, int c); /* OK; different # params */
int max(double a, double b);  /* OK; different types of params */
double max(double a, double b);  /* NOT OK!  Clashes with the above */

Note that valid overloads do not exclude the possibility of making ambiguous calls. For example, if given the above overloaded functions, it would not be clear if a call to max(2,3.0) refers to the first or the third, and hence it will not compile.

L-value

An expression that could appear on the left hand side of an assignment. For more in-depth reading, perhaps check this.

Runtime error

An error in your program that manifests upon actually running it (so, it has managed to compile). This could happen by dividing by 0, or by accessing memory addresses out of bounds for your program, e.g.:

int A[10];
A[100000000] = 99;

I would also consider logical errors as runtime errors. (A logical error is when your program runs, but fails to do what you intend.)

Compile-time error

Any error that is caught by the compiler (e.g., referencing a variable that you have not declared, or forgetting a ; at the end of a statement). Note: since many gcc or g++ commands will attempt linking in addition to compiling, it is easy to conflate compile-time errors with linker errors.

Linker error

An error during linking of course! See the compiling tutorial if you need a reminder about the separate phases of compiling and linking. For an easy example, just make a program without a main function:

// file "stuff.cpp"
int notmain()
{
    return 0;
}

And then attempt to compile+link with g++:

$ g++ stuff.cpp
/bin/ld: /usr/lib64/gcc/x86_64-unknown-linux-gnu/10.2.1/../../../../lib64/Scrt1.o: in function `_start':
/builddir/glibc-2.32/csu/../sysdeps/x86_64/start.S:104: undefined reference to `main'
collect2: error: ld returned 1 exit status

Note that /bin/ld is the linker program which has been invoked by g++ on your behalf.


  1. Note that source code for some programming languages (like python) is never compiled to machine code – such programs can only execute with the help of another program called an interpreter.↩︎

  2. This is useful for forward declarations, and for separating the interface from the implementation. More about that later.↩︎