Computer program facts for kids
A computer program is a list of instructions that tells a computer what to do. It is like a recipe that the computer follows to perform tasks. Programs are a main part of software, which also includes the manuals and other data needed to run the system.
When a person writes a program, it is called source code. This code is written in a programming language that humans can read and understand. However, computers cannot read source code directly. They only understand their own language, called machine instructions or machine code. To make the program work, the source code must be translated. A tool called a compiler translates the whole program into an executable file that the computer can run. Another tool, called an interpreter, can read and run the source code one line at a time.
When you open a program, the computer's operating system loads it into the computer's memory. The central processing unit (CPU) then reads the instructions and does exactly what they say.
Contents
Example computer program
The "Hello, World!" program is a famous simple program used to show how a language works. In 1964, a language called BASIC was created to be easy for students to learn. In BASIC, you do not need to set up complex rules before writing code.
Here is an example of a BASIC program that calculates the average of a list of numbers:
10 INPUT "How many numbers to average?", A
20 FOR I = 1 TO A
30 INPUT "Enter number:", B
40 LET C = C + B
50 NEXT I
60 LET D = C/A
70 PRINT "The average is", D
80 ENDOnce a student understands the basics, they can learn more powerful languages to build larger and more complex systems.
History of programming
As computer hardware improved, the way people wrote software changed too.
Early machines
In 1837, Charles Babbage designed a machine called the Analytical Engine. He was inspired by Jacquard's loom, which used punch cards to weave patterns in fabric. Babbage's machine used similar cards to give instructions. It had a "store" (memory) and a "mill" (processor).
Ada Lovelace worked with Babbage and wrote a description of how the machine could calculate complex numbers. Because of this work, she is often called the world's first computer programmer.
The first modern computers
In 1936, Alan Turing described a theoretical machine, now called the Universal Turing machine. It showed how a machine could follow a set of rules to solve any problem that can be calculated.
The ENIAC was a huge computer built in the 1940s. It used over 17,000 vacuum tubes and filled a large room. Programming it was very hard. People had to plug cables into different panels and flip thousands of switches. It could take weeks to set up a program to calculate things like weather patterns.
Later, engineers developed stored-program computers. Instead of moving cables, the program instructions were stored in the computer's memory, just like data. This made computers much faster and easier to program.
Microchips and personal computers
In the 1960s and 70s, technology got smaller. The invention of the integrated circuit allowed many electronic parts to fit on a tiny chip. This led to the microprocessor, which is a CPU on a single chip.
The Intel 4004 was the first microprocessor. Later, the x86 series of chips became very popular. These chips powered the first personal computers (PCs) in the 1980s. Because the new chips could understand instructions from older chips, people could buy new computers and still run their old software.
How programming languages work
A programming language is a set of words, symbols, and rules used to write instructions. It has a syntax, which is like the grammar of the language.
- Keywords are special words the computer understands.
- Operators are symbols for math or logic (like + or =).
- Identifiers are names the programmer gives to things, like variables.
Generations of languages
Programming languages have evolved in "generations":
- First Generation (Machine Language): This is the raw code the computer reads, made of numbers. It is very hard for humans to read.
- Second Generation (Assembly Language): This uses codes like "ADD" or "MOV" instead of just numbers. An assembler translates these codes into machine language.
- Third Generation (High-Level Languages): These languages look more like English and math. They are easier to write and work on different types of computers. Examples include COBOL, BASIC, C, and Java.
- Fourth Generation: These languages focus on what you want the computer to do, rather than how to do it. SQL is a common example used for databases.
Different ways to write code
There are different styles of programming, called programming paradigms.
Imperative programming
This style gives the computer a list of steps to follow in order. It uses variables (to store data), expressions (to calculate values), and statements (to perform actions).
- Fortran (1958) was used for science and math.
- COBOL (1959) was designed for business.
- C (1973) is a powerful language used to write operating systems like UNIX. It allows programmers to control computer memory very precisely.
Object-oriented programming
As programs got bigger, they became harder to manage. Object-oriented programming (OOP) helps organize code by grouping data and instructions into "objects."
Think of an object like a real-world thing. For example, a "Student" object might have data like a name and a grade. It would also have actions (functions) it can do, like "calculate grade."
- Class: This is the blueprint or definition. It describes what a Student is.
- Object: This is a specific instance, like "The Student named John."
Languages like C++ and Java use this style. It allows code to be reused easily through inheritance. For example, a "Student" class could inherit features from a "Person" class.
Declarative programming
In this style, the programmer describes the result they want, and the computer figures out how to get it.
- Functional languages (like Lisp and ML) use mathematical functions. They are often used in research and artificial intelligence.
- Logical languages (like Prolog) use facts and rules. You tell the computer facts (like "Tom is a cat") and rules (like "Cats like fish"). Then you can ask questions (like "Does Tom like fish?"), and the computer uses logic to find the answer.
Software engineering
Software engineering is the process of designing and building high-quality programs. It is like architecture but for software.
How programs are built
Creating a big program involves several steps, often called the waterfall model:
- Investigation: Understanding what problem needs to be solved.
- Analysis: Figuring out possible solutions.
- Design: Planning the best solution.
- Implementation: Writing the code.
- Maintenance: Fixing errors (bugs) and adding new features after the program is released.
The job of a programmer
A computer programmer writes the code. On big projects, programmers work in teams. They break the program into smaller parts called modules.
- Cohesion means a module does one specific thing well.
- Coupling is how much modules depend on each other. Good programs have modules that are independent, so changing one does not break the others.
Types of software
Application software
This is the software you use to do things. It includes games, word processors, and web browsers. Companies use special software for accounting and managing customers. This can be bought from a store ("off-the-shelf") or custom-made for the company.
Operating systems
The operating system (OS) is the most important program. It manages the computer's hardware and allows other programs to run. Examples include Windows, macOS, and Linux.
The core of the OS is called the kernel. It has many jobs:
- Process Scheduling: Deciding which program gets to use the CPU.
- Memory Management: Giving each program its own space in memory so they do not interfere with each other.
- Device Management: Talking to hardware like the mouse, keyboard, and printer.
- File System: Organizing files on the hard drive.
Computer logic
At the very bottom level, computers run on digital logic. This uses tiny switches called transistors inside the chip. These switches form logic gates (like AND, OR, and NOT) that handle simple "true" or "false" signals (1s and 0s). By combining millions of these gates, the computer can perform complex math and run programs.
Images for kids
See also
In Spanish: Programa informático para niños