A computer program is a set of instructions that tells your computer what to do

A computer program is a list of commands written in a language the computer understands. When you run a program, the computer reads those commands one by one and carries them out. Every piece of software on your device — your web browser, email client, word processor, or game — is a program. The program tells the computer which keys to listen for, what to display on your screen, where to store information, and when to send data to other computers.

Programs are written by people called programmers or developers. They use programming languages like Python, Java, C++, or JavaScript to write the instructions. These languages have rules and grammar, much like English does, but they are strict — a single typo or misplaced symbol can break the entire program. Once written, the code is translated into a form the computer's processor can actually execute.

Key Takeaways

  • A program is a sequence of instructions that tells a computer to perform specific tasks, written in a language programmers create.
  • Programs run on your device's operating system, which manages the hardware and allows programs to use your screen, keyboard, storage, and internet connection.
  • Some programs are installed on your computer; others run in your web browser or on a company's server and you access them online.
  • Programs are built from smaller pieces called functions or modules, each handling one job, so programmers can reuse and fix code more easily.
  • When a program crashes or behaves oddly, it usually means the code has a bug — an error the programmer did not catch during testing.

How programs interact with your operating system

Your computer's operating system — Windows, macOS, or Linux on a desktop; iOS or Android on a phone — is itself a program. It acts as a manager between your programs and your hardware. When you open a web browser, the browser program asks the operating system for permission to use your screen, keyboard, and internet connection. The operating system grants that permission and keeps track of what each program is allowed to do.

This arrangement protects you. A program cannot straightforward read your hard drive without the operating system's permission. It cannot send data to the internet without your system knowing about it. The operating system enforces these boundaries so that a malicious or poorly written program cannot damage your files or spy on you unchecked.

The difference between installed programs and web-based programs

An installed program lives on your computer's hard drive or solid-state drive. When you click its icon, the operating system loads it into your device's memory and runs it. Microsoft Word, Photoshop, and Spotify are installed programs. They run on your machine, which means they can work even if your internet goes down — though some features may require a connection.

A web-based program runs on a company's server, and you access it through your web browser. Gmail, Google Docs, and Canva are web-based programs. The browser is the installed program; the actual process lives elsewhere. Web-based programs are easier to update — the company changes the code on their server, and you see the new version the next time you log in. You do not have to read or install anything.

Hybrid programs exist too. Spotify is installed on your device but constantly talks to Spotify's servers to stream music and sync your playlists. Microsoft Word can work offline but syncs your documents to OneDrive when you are connected.

How programs are built from smaller pieces

Large programs are not written as one giant block of code. Instead, programmers break them into smaller chunks called functions or modules. A function is a set of instructions that does one specific job. In a photo editing program, one function might handle opening a file, another might adjust brightness, and another might save the result.

This approach has two big advantages. First, programmers can reuse functions across different parts of the program or even in different programs — they do not have to rewrite the same logic over and over. Second, when a bug appears, the programmer knows which function to look at, rather than searching through thousands of lines of code.

Many programs also use libraries — pre-written code that other programmers have already created and shared. A library for handling dates and times, for example, saves every programmer from writing their own date code. This is why software updates often include security patches: the library a program relies on had a flaw, and the programmer updates their program to use the fixed version.

What happens when a program crashes or freezes

A program crashes when it encounters an error it cannot recover from. This might happen because the programmer made a mistake in the code, because the program ran out of memory, or because it tried to do something the operating system would not allow. When a crash occurs, the program stops running and usually displays an error message or closes without warning.

A program freezes when it is stuck waiting for something — a response from the internet, a file to load, or a calculation to finish — and cannot respond to your clicks or keystrokes. If the wait is long enough, your operating system may offer to close the program for you. Restarting the program usually fixes both crashes and freezes because it clears the program's memory and lets it start fresh.

Programmers test their code before release, but they cannot test every possible situation a user might encounter. This is why bugs slip through. When you report a bug to a software company, they investigate, find the error in the code, and release an update that fixes it.

How programs store and retrieve information

When you save a document, take a photo, or create an account, a program writes that information to your device's storage or to a company's server. The program uses a file system — a way of organizing data into files and folders — or a database — a structured system for storing and finding large amounts of information quickly.

A database is more powerful than a straightforward file. If you have a spreadsheet with a thousand customer names and addresses, a database can find all customers in a specific city in milliseconds. A file system would have to read through the entire file. This is why banks, hospitals, and large websites use databases: they need to store millions of records and retrieve specific ones when ready.

Programs also use temporary storage called cache or memory. When you load a web page, your browser stores images and code in cache so that the next time you visit, it does not have to read them again. This makes the page load faster. Cache is cleared when you close the browser or when it gets too full.

Why programs need updates

Software updates serve three main purposes: adding new features, fixing bugs, and closing security holes. A security hole is a flaw in the code that a malicious person could exploit to steal your data or take control of your device. When a security hole is discovered, programmers write a patch — a small piece of code that fixes just that problem — and release it as an update.

Updates also fix bugs that users discovered after the program was released. A programmer might have missed an edge case — an unusual situation that breaks the code — and users found it in the real world. The update corrects that error.

New features come in larger updates. A web browser might add a new privacy tool, or a photo app might gain a new filter. These updates are optional in the sense that your program will still work without them, but they often improve performance or security, so installing them is usually a good idea.

Frequently Asked Questions

What is the difference between a program and an app?

The terms are used interchangeably today. "App" is short for process and originally referred to programs on phones and tablets, while "program" was used for desktop software. Now both words mean the same thing — a piece of software that does a specific job.

Can I see the code inside a program?

Not usually. Most commercial software is closed source, meaning the company keeps the code private. Some software is open source, meaning anyone can read and modify the code — examples include Firefox, LibreOffice, and Linux. Open source does not mean free, though many open source programs are.

Why do programs sometimes ask for permission to access my camera or location?

The operating system requires programs to ask before they use sensitive hardware or data. This is a security feature. A program cannot secretly turn on your camera or track your location without your permission. You can usually change these permissions in your device's settings.

What is a virus or malware in relation to programs?

Malware is a program written intentionally to harm your device, steal your data, or use your computer for the attacker's purposes. A virus is one type of malware that copies itself and spreads to other files or devices. Antivirus software scans programs and files to detect known malware before it can run.

Do I need to understand programming to use a computer?

No. Programs are designed so that people without programming knowledge can use them. You interact with the program through buttons, menus, and text boxes — the programmer handles the complex logic behind the scenes. Understanding how programs work helps you troubleshoot problems and make better choices about software, but it is not required to use one.