Programming Glossary - Programming Interactivity

by Joshua Noble

This programming glossary defines some of the most commonly used programming terms throughout this book. It doesn’t include operators and symbols.

Programming Interactivity book cover

This excerpt is from Programming Interactivity . With Programming Interactivity, you'll explore cutting-edge techniques for interaction design, and get the background and technical information you need to design, program, build, and troubleshoot your own projects. This book explains programming and electrical engineering basics, and introduces three freely available tools created specifically for artists and designers: Processing, Arduino, and OpenFrameworks.

buy button

The #define operator defines a value that persists throughout an entire application. For instance:

#define NUMBER 4

Now the constant NUMBER will represent the value 4 throughout the application.


The #ifdef operator checks whether something has been defined using the #define keyword. It must be followed by #endif.


The #ifndef operator checks whether something has not been defined using the #define keyword. It must be followed by #endif.


This is short for ampere and is a electrical measurement of how much electrical current is flowing in a circuit. It is equal to the voltage divided by the resistance.

analog pin

On the Arduino, the analog pins enable reading of voltage. The voltage on the pin is interpreted as an integer value in the range of 0 to 1,023.


An array is a collection of variables that are accessed with an index number. An array is declared with a length or with initializers that determine the length. The following code declares an array of six elements with the first element at arr[0] and the last at arr[5]:

int arr[6];

Processing arrays are created like so:

int arr = new int[6];

In C++, declaring the array initializes each element in the array when the object is created only if the array is declared in the class:

class myClass {int arr[6]; 
// will be created when an instance of 
// myClass is created

The elements would be accessed as follows:

int first = arr[0];
int last = arr[5];

American Standard Code for Information Interchange (ASCII) is a set of definitions for 128 characters: 33 are nonprinting control characters that affect how text is processed, 94 are printable characters, and the space is considered an invisible graphic. Each character is represented as a number; for instance, A is represented as 65, and a is represented as 97.


Assignment is when a value is given to a variable, like so:

int j;
j = 5; // now j is assigned a value
bitwise operations

Bitwise operations work at the bit level of variables. These are the AND (&) operator (not to be confused with the reference operator, which looks the same but is used differently), the OR (|) operator, the XOR (^) operator, and the two bitwise shift operations (<< and >>).


boolean variables or bool hold one of two values: true and false represented as 1 and 0, respectively. They are the same in C++, Arduino, and Processing.


In both Processing and Arduino, the byte stores an 8-bit number, from 0 to 255. byte is an unsigned datatype, so it does not store negative numbers.


Capacitors are another element used to control the flow of charge in a circuit. The name derives from their capacity to store a charge. Capacitors consist of two conducting surfaces separated by an insulator; a wire lead is connected to each surface.


A cast translates one variable type into another and forces calculations to be performed in the cast type. It uses the () operator and looks like this: (type)variable. For instance:

int i;
float fl;
fl = 5.5;
i = (int) f; // i is the integer value of f, 
             // so it will be equal to 5

Casts can also be done like so:

i = int(f);

A char takes up 1 byte of memory and stores a character value written in single quotes, like 'A'. The char stores the characters in ASCII as numbers, which means a char can be used for arithmetic. The char datatype is a signed type, meaning that it encodes numbers from –128 to 127. The unsigned char can store numbers from 0 to 255 (and is exactly the same as the byte type).


A class is a prototype for an object in Processing or C++. It can be used to create an instance of that class that will have its constructor called when it is created. In C++, for instance, class declarations look like this:

class Circle {
    int radius;
    int x;
    int y;

In Processing, class definitions look the same but do not require the semicolon (;) at the end of the class.


Comments help you understand (or remember) how your program works or inform others how your program works. There are two different ways of marking a line as a comment:

// this is a single-line comment
/* this is a multiline comment
that ends with a */

Comparison operators are operators that compare two values, like != (not equal to) or == (equal to), for instance. 3 == 4 returns false (because 3 is not equal to 4), while 7.8 != 9 returns true (because the values are not equal).


A constant is a value that does not change within a program. It cannot be reassociated with a different value like a variable can. You declare a constant like this:

const int constInt = 5; // Arduino and C++

public static final int constInt  = 5; 
// Processing

The constructor of a class is the method that will be called when an instance of that class is created. In both C++ and Processing, the constructor has the same name as the class:

class Circle {
    Circle() {
       // do something on creation
cpp file

In an oF or other kind of C++ class, the .cpp file is where all the definitions for a class are stored.


Dereferencing a pointer returns the value of the variable that the pointer points to. For instance:

int* p;
int j = 5;
p = &I;
int k = *p; // k is now 5

In the Arduino controller, the digital pins accept or send digital signals. The signal values are either HIGH or LOW.


The diode acts like a one-way valve for current, and this is a very useful characteristic. One application is to convert alternating current (AC), which changes polarity periodically, into direct current (DC), which always has the same polarity.


A double is a very large floating-point number consisting of 8 bytes (64 bits) that can represent numbers as large as 18,446,744,073,709,551,615. In Arduino, a double is the same size as a float (4 bytes).

event handler

An event handler is called when a certain event happens. In Processing applications, the mouseMoved() method is an example of an event handler. In an oF application, the receivedSound() method is an event handler that indicates that the system has received data from the sound card.


A float is a number that has a decimal point. Floating-point numbers can be as large as 3.4028235E+38 and as low as –3.4028235E+38. They are stored as 32 bits (4 bytes) of information.


The for loop repeats a block of statements enclosed in curly braces until the condition is met. An increment counter is usually used to increment the loop counter and terminate the loop, though there are other ways of working with for loops. There are three parts to the for loop header:

for (initialization; condition; increment) {}

For example:

for (int i = 0; i < 10; i++) {
    //call doSomething with values 
    //from 0 to 9

A function is a subroutine with a name that optionally takes parameters and returns a value. For instance:

int square(int val) {
    return val*val;

Functions that are defined within a class are called methods.

function call

A function call is another way to refer to calling a method that has been declared and defined elsewhere. For instance:

header file or .h file

In an openFrameworks class or Arduino library, the .h or header file is where the declarations of a method and a class are stored.


An if is used with a comparison operator and tests whether a certain condition is true or false:

if (x > 50) {
    // do something here
} else {
    // do something if x isn't > than 50

Inheritance is the process of having one class extend another class. When a class extends another class, it inherits all the methods and properties of its parent class. In C++, this is done by writing the following:

class Circle : public Shape {

In Processing, it’s done by writing the following:

class Circle extends Shape {

An integer is a numerical value that does not have a decimal point. It represents either of the following:

  • A 2-byte (16-bit) number, with a value between 0 and 65535 for an unsigned Integer and –32,768 and 32,677 for a signed integer. This is the size of an int in Arduino.

  • A 4-byte (32-bit) number, with a value between 0 and 4,294,967,295 for an unsigned Integer and –2,147,483,647 and 2,147,483,647 for a signed integer. This is the size of an int in Processing and oF.

In other platforms not covered in this book, an int can be an 8-byte (64-bit) number.


Long variables are extended-size variables for number storage, and on Arduino and oF they can store 32 bits (4 bytes) from –2,147,483,648 to 2,147,483,647 or for an unsigned long from 0 to 4,294,967,295. In Processing, a long stores values up to 18,446,744,073,709,551,615.


A method is a function that is declared within a class.

method declaration

This is the declaration of a function within a class, where its signature is defined. In C++, this is often done in the .h header file:

int charToInt(char ch);

In Arduino this is also sometimes done in an .h file, though it doesn’t always need to be. In Processing, method declarations and definitions are done at the same time.

method definition

In C++, this is done in the .cpp file and looks like this:

void className::methodName() {

Methods that are included in the .cpp file of a class have to defined in the classes definition in the .h file. In Processing and Arduino, the declaration and definition are done at the same time, though sometimes .h files with declarations are used as well.

object-oriented programming

Object-oriented programming, or OOP, is the process of using multiple classes to represent different areas of functionality or data objects within your application.


An Ohm is an electrical measurement that indicates the amount of resistance that current will encounter as it travels through a circuit. It is equal to the voltage divided by the current.


An opamp, or operational amplifier, is a DC device that amplifies signals.


An operator is a function that operates on or modifies a value or function. +, =, and / are mathematical operators, while & and ? in C and C++ are nonmathematical operators.


On the Arduino, the pins are the ports that connect into the microprocessor. There are analog, digital, and PWM-enabled pins.


A pointer is a type in C++ and C that points to a section in memory. They are most often used to pass to a method to ensure that the particular variable being pointed to is modified by the method, rather than any other variable.


A potentiometer is a resistor that is usually controlled directly by the user, allowing the amount of voltage that it resists to be set by a dial or other physical control. This is commonly used in knobs and dials.


Pulse Width Modulation (PWM) is a way of simulating an analog output by varying HIGH and LOW signals at intervals proportional to the value.


Recursion is a process by which a method calls itself over again until some process is complete or some condition is met.


A reference is the location in memory that a variable points to. You can use references to set the value of a pointer. For instance:

int* p;
int j = 5;
p = &j; // p is now pointing at the location  // in memory where j is stored

Resistors are electrical components that resist the flow of charge. The value of a resistor is measured in Ohms and represented by the Greek letter capital omega.


This statement sets what a function returns. In C++ and Java, the return type is indicated in the signature of the method like this:

int addNumbers()

Scope defines the area of an application or method in which a variable is accessible. Most variables are accessible only within the brackets within which they are declared.


Serial is a library in the Arduino core software that enables serial communication using the RS232 protocol over a port opened between another serial device. You’ll most often hear the serial port discussed in setting up communication between the Arduino controller and another host computer.


A short is a datatype that represent a small int, using 2 bytes instead of 4 like a C++ or Java int. Shorts are useful for calculations that need to be extremely fast where you know that your data value will never exceed the range of two bytes. Short is signed by default, but can also be declared as unsigned.


Signed numerical values can have negative numbers assigned to them. This usually means that the first bit of the number states whether the number is negative or positive. This means that signed variables represent ranges that start at the lowest possible number, for instance –32,768 for a signed int (in Arduino), and go to the highest number, which for a signed int is 32,677.


Marking a method as static means that it is available from a class whether or not an instance of that class has been created. For instance, in C++ you can call a static method like this:


In Processing or Java, static methods are called like so:


Declaring a variable as static means that the variable name refers to the same value throughout the application whether an instance has been created or not.


A string is construct available in Processing and C++, which represents a series of characters that can be split, looped through, or accessed using methods that make working with a string easier than working with an array of characters.


A struct is a collection of variables, somewhat like a simplified class. It cannot have methods, but it can have properties. For instance:

struct {
    int radius;
    int x;
    int y;
} Circle;

The struct can be used only in C++ and Arduino.


switch/case statements control the flow of programs by checking a list of “cases” inside a set of bracket. The program checks each case for a match with the test variable and runs the code if a match is found.

switch (var) {
    case 1:
        //do something when var == 1
        // break is optional
    case 2:
        //do something when var == 2
        // if nothing else matches, 
        // do the default
        // default is optional

Type refers to what datatype a variable represents. For instance, int, string, or char are all datatypes. All variables and methods must have a type even if that type is void, unless they are the constructor method of a class.


Declaring a variable as unsigned means that it will store values only between 0 and their maximum value. For instance, in Arduino, an unsigned int stores 0 to 65,535. The first bit of an unsigned datatype is not used to determine whether the number is positive or negative.

variable assignment

Variable assignment is the assignment of a value to a variable. For instance:

int val;
val = 5; // assign to val the value 5

Before a value is assigned, the variable is null, which means it has no value and may cause errors if you try to read from it.

variable declaration

Variable declaration is where a variable is first given a type and a variable name. For instance:

int j;
char name[20];

In C++, the methods and variables that the class will contain are declared in the .h file.


A vector is an object in C++ that behaves somewhat like an array in that it contains multiple elements that can be accessed with the [] operators, but unlike arrays in C++ it can be of a variable size.


This is the rate at which energy is drawn from a source that produces a flow of electricity in a circuit. It is measured and expressed in volts. The higher the voltage, the more current is flowing around a circuit. It is equal to the current times the resistance.


The while loop constructs a loop that executes until the statement in the condition of the loop is true. For example, the following will execute 10 times, as long as I is less than 10:

int I = 0;
While(i<10) { i++;}

If you enjoyed this excerpt, buy a copy of Programming Interactivity.