What Is Software? Code and Programs for Beginners
Your phone reminds you about a meeting, a map app finds a route home, and a payment app splits a dinner bill to the last rupee. Behind each of those, someone wrote down every step the device should take. This lesson answers what is software, how written instructions become a running program, and why programs sometimes do the wrong thing.
What is software? Instructions, input and output
Software is the instructions that tell a computer what to do. One set of instructions written for a job is a program: an app on your phone is one program, or a few working together. Hardware is the opposite: the physical parts you can touch.
The instructions are written as code: text in a programming language, a language with strict rules so that each instruction has exactly one meaning. JavaScript, Python and Java are popular ones. A line of code says something precise, such as "add these two numbers" or "show this message".
Nearly every program follows one pattern. It takes input, the data it is given, such as what you type or tap. It follows its instructions to work on that data. Then it produces output, the result: a message on screen, a sound or a saved file. In the diagram, notice that each part of the recipe has a partner in the program.
From code to a running program
The code people write is called source code. The computer's processor, the CPU (central processing unit), cannot run it directly. It understands only machine code: very simple instructions stored as numbers. So source code has to be translated, in one of two main ways.
A compiler is a program that translates all of your source code into machine code before it runs, and saves the result as a program file, such as an .exe file on Windows. C, Go and Rust usually work this way. The file can then run again and again without the compiler.
An interpreter is a program that reads your source code and carries it out as it goes, without saving a machine-code file. Python is usually run this way. Many languages mix the two: your browser's JavaScript engine, the part that runs a page's code, starts by interpreting it, then compiles the busiest parts to machine code while it runs.
Either way, the operating system (OS), the software that manages the hardware, such as Windows, macOS, Linux or Android, takes the last step. It copies the program into memory, the computer's short-term workspace, and gives it turns on the CPU (more on operating systems). With an interpreter, the program the OS starts is the interpreter itself. In the flowchart, notice that both routes end in the same place.
Kinds of software
Software comes in layers, and each layer relies on the one below it:
- Apps, short for applications, are the programs you open and click: a browser, a chat app, a game. When they need the screen, files or the network, they ask the OS.
- The operating system manages the hardware and shares it between apps, so that one app cannot trample on another.
- Firmware is software stored on a chip inside a device. A simple washing machine or a TV remote runs nothing else. In your computer, start-up firmware wakes the hardware and starts the OS when you press the power button.
- Websites are software too. Your browser downloads a site's code from a server, a computer that answers requests over the internet, and runs it, while more code runs on the server. How the two halves cooperate is the next lesson.
In the diagram, notice that apps never touch the hardware: every request goes through the operating system.
Why bugs happen
A bug is a mistake in software that makes it behave differently from what its authors intended. The computer is not being careless: it does exactly what was written, every time. A bug is a gap between what was written and what was meant.
Some bugs break the language's rules, like a recipe step with its words scrambled. The compiler or interpreter cannot make sense of it, so the program will not run, or stops at that point, and shows an error message that usually names the line. These are often the quickest to fix.
Harder bugs are valid instructions that mean the wrong thing. Say a shop wants 10% off orders of ₹500 or more, but the code says "more than 500". A ₹500 order gets no discount, nothing crashes and no error appears. Others come from input nobody planned for, such as an empty basket. Hunting bugs down step by step comes later, in Debugging Basics.
How people build software
Nobody writes a whole program in one go and gets it right. Developers work in a short loop: write a little code, run it, look at the result, fix what is wrong, and repeat. Small steps keep each mistake small and easy to find.
Software is also never really finished. Users ask for new features, bugs turn up, security weaknesses are found, and the world changes: new phones, new tax rules. That is why your apps update so often: each update is a new version of the same software.
Check yourself
A shop app shows a wrong total but no error message. Is the computer faulty?
Almost certainly not. It follows its instructions exactly, and the instructions say something other than what the authors meant. That is a bug, so the fix is to change the code.
Why can a compiled program run without its compiler, while a Python program needs the Python interpreter every time?
The compiler has already turned the code into machine code and saved it in the file. An interpreter translates while the program runs, so it has to be there on every run.
You play a game on a laptop. Which kinds of software are at work, and what does each do?
The game is an app: it asks the operating system for the screen, keyboard and memory. The OS drives the hardware. Firmware started the laptop and also runs inside parts such as the storage drive.