← All posts
6 min read

What Is a Program? Precise Instructions for a Computing System

#technology#computer-science#programming#software
📑 On this page

A computer can perform millions of different tasks without physically rebuilding its circuits each time. What changes is the program.

A program is an organized set of instructions and data that directs a computing system to perform a task.

The instructions must be precise enough for software and hardware to execute, but they can be expressed through layers that are convenient for humans.

Instructions and data

A program contains operations such as:

  • Read input
  • Store a value
  • Calculate a result
  • Compare values
  • Repeat work
  • Request a file
  • Draw output

It also works with data:

  • Numbers
  • Text
  • Images
  • Configuration
  • User records
  • Program state

Instructions describe transformations. Data supplies the values being transformed.

The distinction can blur because code itself is stored as data and programs can generate or load additional code.

Source code

Developers write source code in programming languages.

Example:

const total = price * quantity;
console.log(total);

This expresses intent at a level higher than processor instructions.

The language defines:

  • Valid syntax
  • Value types
  • Operations
  • Control structures
  • Function behavior

Tools translate or execute source code through compilers, interpreters, and runtimes.

From program file to process

A program stored on disk is not currently running.

When launched:

  1. The operating system creates a process.
  2. Program code and required libraries are mapped into memory.
  3. Runtime initialization occurs.
  4. An initial thread begins at a defined entry point.
  5. The program requests input, computation, and OS services.

The same stored program can have several running processes with separate state.

The program is the recipe; the process is one active execution.

Input, processing, and output

A useful first model is:

input → processing → output

A calculator:

  1. Reads two numbers and an operation.
  2. Performs the calculation.
  3. Displays the result.

Real programs also maintain state and interact over time:

input → update state → produce output → wait for next input

An email app remains active, responding to clicks, timers, network messages, and notifications.

Control flow

The computer needs to know which instruction executes next.

Programs use:

  • Sequence
  • Conditions
  • Loops
  • Function calls
  • Events
  • Exceptions

Sequence alone would run every instruction once in fixed order.

Conditions select behavior. Loops repeat it. Functions transfer control to reusable operations. Events allow programs to react when something happens.

Together, these structures express complex procedures.

State

State is information the program remembers at a particular moment.

Examples:

  • Current score
  • Signed-in user
  • Shopping-cart contents
  • Open document
  • Selected tab
  • Network connection status

State can live in:

  • Variables
  • Memory
  • Files
  • Databases
  • Remote services

A program's output often depends on current input plus prior state.

State makes applications useful but introduces complexity: it must remain valid, synchronized, persisted, and protected.

A concrete calculator program

function calculate(left, operator, right) {
  if (operator === "+") return left + right;
  if (operator === "-") return left - right;
  if (operator === "*") return left * right;
  if (operator === "/") {
    if (right === 0) throw new Error("Cannot divide by zero");
    return left / right;
  }
  throw new Error("Unknown operator");
}

This small program:

  • Accepts input through parameters
  • Uses conditions
  • Performs arithmetic
  • Returns output
  • Handles invalid cases

The user interface, parsing, display, and history would add more components, but the core task remains a precise procedure.

Programs rely on environments

A program rarely controls raw hardware directly.

It relies on:

  • Operating system
  • Runtime
  • Libraries
  • Configuration
  • Files
  • Network services
  • Hardware capabilities

A browser program expects browser APIs. A mobile app expects its platform framework. A command-line utility expects terminal and OS services.

The same source can behave differently when environment versions, permissions, locale, time zone, or dependencies differ.

Correctness includes assumptions about that environment.

Deterministic and nondeterministic behavior

A deterministic program produces the same output from the same initial state and input.

Behavior can vary when it uses:

  • Time
  • Randomness
  • Network responses
  • Concurrent scheduling
  • User interaction
  • External files

Random-number generators are usually deterministic algorithms initialized with a seed, although systems can obtain entropy from physical sources.

Testing becomes easier when variable inputs such as time and randomness can be controlled.

Correctness

A program is correct relative to a specification.

Possible requirements include:

  • Produces expected results
  • Rejects invalid input safely
  • Protects data
  • Meets performance limits
  • Handles failure
  • Remains accessible

A program can compile and run while still being wrong.

Correctness is not only absence of crashes. A payroll program that calculates an incorrect tax is defective even if it never stops.

Programs at different scales

Programs range from:

  • Tiny scripts
  • Embedded-device firmware
  • Desktop applications
  • Mobile apps
  • Web services
  • Distributed systems

A large application is usually many programs and services communicating.

The word "app" describes a user-facing product. The implementation may include browser code, mobile code, APIs, background workers, databases, and operational tools.

Common misunderstandings

"A program is only source code"

Source code is the developer representation. A complete running program also depends on translated code, data, runtime, and environment.

"The computer understands the program's purpose"

It executes defined operations. Human meaning comes from design, data, and interpretation.

"If a program runs, it is correct"

It can produce wrong results, expose data, or fail under untested inputs.

"Every application is one process"

Applications can use many processes, services, and remote systems.

Knowledge check

1. What are the two broad ingredients of a program?

Instructions and data.

2. What is the difference between a program and process?

A program is stored instructions and data; a process is one running instance with memory and resources.

3. What is program state?

It is information the program remembers at a particular moment and uses in later behavior.

4. Why can a program run but still be incorrect?

Execution only proves it followed instructions; the instructions or assumptions may not satisfy requirements.

The one idea to remember

A program is a precise, executable procedure operating on data and state within an environment.

Programming languages let humans express that procedure; tools and runtimes bridge it to the machine.

Next, we will examine the bridge from readable source code to processor-level machine instructions.