Computer program

Also known as: program

On this page 7

A computer program, often simply called a program, is a finite, ordered set of instructions that a computer can execute to carry out a specific task or solve a defined problem. In software, the program is the basic unit of executable logic: it exists first as human-readable source code and is then translated or interpreted into operations that a processor can perform.

Every piece of software, from a command-line utility to an operating system kernel, consists of one or more programs together with supporting data, libraries and configuration. Understanding what a program is, and how it moves from text to running process, is a foundation for the rest of software fundamentals.

How a computer program is built and executed

A program passes through a lifecycle from source to execution. A developer writes source code in a programming language, a toolchain converts it into a runnable form, the operating system loads that form into memory, and the processor executes its instructions one after another, branching and looping as the logic requires.

The translation step differs by language. Compiled languages such as C, C++, Rust and Go are converted ahead of time into machine code packaged in an executable file. Interpreted languages such as Python and shell scripts are read and executed by an interpreter at run time. Many modern languages, including Java and C#, use a hybrid model: source is compiled to bytecode, which a virtual machine runs and often optimizes with just-in-time compilation.

The table below summarizes the main stages a program typically passes through.

StageWhat happensTypical tools
WritingDeveloper expresses logic as source codeText editor, IDE
TranslationSource becomes machine code or bytecodeCompiler, assembler, bytecode compiler
LinkingSeparate modules and libraries are combinedLinker, package manager
LoadingOperating system maps the program into memoryLoader, dynamic linker
ExecutionProcessor runs instructions as a processCPU, runtime, interpreter
Stages in the life of a computer program

Core components inside a program

Most programs share a common internal structure regardless of language. They contain instructions that perform operations, data that those instructions act on, and control flow that decides which instructions run and in what order. The three fundamental control structures are sequence, selection and iteration, a principle established by structured programming theory.

When a program runs, the operating system gives it an address space divided into regions. The code segment holds executable instructions, the data segment holds global variables, the stack holds function calls and local variables, and the heap holds memory allocated dynamically while the program runs.

  • Entry point: the first instruction executed, such as a main function in C or Java.
  • Functions or procedures: named, reusable blocks of logic that accept inputs and return results.
  • Variables and data structures: named storage for values, from simple integers to complex objects.
  • Input and output: interaction with users, files, networks and devices, usually through operating system calls.
  • Exit status: a numeric code returned on completion, where zero conventionally signals success.

A program is a static artifact, while a process is a program in execution. The same program file can produce many simultaneous processes, each with its own memory and state, which is why opening two browser windows may start several independent processes from one installed program.

The following table distinguishes the program from neighboring concepts that are often used interchangeably.

ConceptDefinitionKey difference from a program
Computer programSet of executable instructions for a taskThe reference concept
ProcessRunning instance of a programDynamic, has memory and state
SoftwarePrograms plus data, libraries and documentationBroader collection
Application softwarePrograms that serve end-user tasksA category defined by purpose
AlgorithmAbstract step-by-step methodNot tied to any language or machine
ScriptProgram usually run by an interpreterA delivery style, not a separate kind
Computer program compared with related concepts

An algorithm describes how to solve a problem in principle; a program is a concrete implementation of one or more algorithms in a specific language for a specific environment. A shared library also contains executable code, but it has no entry point of its own and runs only when another program calls it.

Types of computer programs

Programs are commonly classified by the role they play in a computing system. The categories overlap, and a single product may contain programs of several types.

CategoryPurposeExamples
System softwareManage hardware and provide servicesKernels, device drivers, boot loaders
Application softwarePerform tasks for end usersWord processors, browsers, games
Utility softwareMaintain and optimize a systemBackup tools, disk cleaners, archivers
Embedded softwareControl dedicated devicesFirmware in routers, appliances, cars
Development toolsCreate and test other programsCompilers, debuggers, build systems
Main categories of computer programs

Programs also differ by interface style. A command-line program reads typed commands and text input, a graphical program presents windows and controls, and a background service or daemon runs without direct user interaction, responding to events, schedules or network requests.

Correctness, limits and common misconceptions

A program does exactly what its instructions specify, not what its author intended, which is why defects arise. A software bug is a mismatch between specified and intended behavior, and fixing it usually requires changing the source code and producing a new version, often distributed as a software patch.

Programs also have theoretical limits. The halting problem, proved undecidable by Alan Turing in 1936, shows that no general procedure can decide for every program whether it will eventually stop. In practice, this is why fully automatic verification of arbitrary programs is impossible and why testing, code review and formal methods are combined.

The table below lists frequent misunderstandings and the accurate view.

MisconceptionAccurate view
A program and an app are different thingsAn app is a program, typically for end users
Source code runs directly on the processorIt must first be compiled or interpreted
One program equals one processA program can run as many processes
A tested program is bug-freeTesting reveals defects but cannot prove absence
Executables run on any computerThey depend on processor architecture and operating system
Common misconceptions about computer programs

In everyday language

A computer program is like a recipe for a machine. A recipe lists ingredients and steps in a fixed order, and a cook follows them to produce a dish. A program lists precise steps that a computer follows to produce a result, such as showing a web page or saving a document.

The big difference is that a computer follows the steps exactly as written. A human cook can guess what a vague recipe means, but a computer cannot. If one step is wrong, the computer will repeat the same mistake every time until someone corrects the instructions.

Seen in the real world

A small accounting office receives about 300 supplier invoices each month as PDF files and spends roughly two working days copying their totals into a spreadsheet. An in-house analyst writes a short Python program of about 150 lines that opens each file, extracts the invoice number, date and amount, and writes them into a single table.

The program runs from the command line once a week. It reports any invoice it cannot read, so a person checks only those few cases by hand. After a month of testing against manually entered data, the office adopts it, and the monthly data entry drops from two days to under an hour. When a supplier changes its invoice layout, the analyst updates one function, which shows how a program keeps working only as long as its instructions match reality.