An instance of a program is a copy of an executable version of the program that has been written to the computer's memory.
A program is a sequence of instructions that indicates which operations the computer should perform on a set of data. An executable version of a program, also called an executable program, is a version of a program that is understandable by a computer's central processing unit (CPU) and that is ready to run as soon as it is copied from storage (usually a hard disk drive) into memory. (This contrasts with the source code version of a program, which is the version as originally written by humans using a programming language, and before it has been translated by a specialized program called a compiler into object code.) The CPU is the main logic unit of a computer.
An instance of a program is typically created by a user clicking on an icon (i.e., small image) on a GUI (graphical user interface) or by entering a command at the command line and then pressing the ENTER key. Instances of programs can also be created by other programs.
Multitasking, which allows multiple programs to run seemingly simultaneously on the same computer, also allows multiple instances of a single program to run simultaneously, if the program allows it. However, sometimes it is desired that there be only a single instance of a program on a computer, and programming languages provide techniques that can be used to enforce this.
An example of a situation in which it can be useful to run multiple instances of a single program is having several multiple Nautilus (i.e., the official file manager for the Gnome desktop in Linux) windows open simultaneously in order to compare the contents of different directories. Another example is a remote server from which multiple users are accessing a single program.
The number of instances of a program existing on a computer at the current time can be easily confirmed with commands such as ps and pstree, which show processes and their PIDs. Finding all of the instances of a program can be useful in some situations, particularly when the program crashes (i.e., freezes or stops operating as expected) and thus needs to be terminated.
The word instance also has other meanings in a computer context, and these are likewise consistent with its broader definition as one particular incarnation of an object or situation. For example, in object-oriented programming (e.g., Java and C++) every object is an instance of some class and it is created by instantiating a class. In Java programs, an instance of a class is created using the new operator followed by the class name. For example, an object called my cat or felix could be created as an instance of the class cat.
Perhaps the best way to summarize the difference between programs and instances of them is the statement that programs reside on disk and instances reside in memory.
Created December 10, 2005.