kids encyclopedia robot

Computer program facts for kids

Kids Encyclopedia Facts

A computer program is like a recipe or a set of instructions that tells a computer exactly what to do. These instructions are written in a special language called a programming language. Think of it as the computer's brain, guiding its actions.

A program that humans can read is called source code. Computers don't understand source code directly. They need another program, like a compiler or an interpreter, to translate the source code into machine instructions that the computer can understand and follow. Once translated, the program can run!

When you ask a computer to run a program, its operating system loads the program into the computer's memory. Then, the central processing unit (CPU) starts following each instruction, one by one. If it's source code, an interpreter translates and runs each step, which can be a bit slower than running a pre-translated program.

Example Computer Program

A classic example to show how a programming language works is the "Hello, World!" program. It simply makes the computer display "Hello, World!".

Here's an example of a program written in a language called BASIC (from 1964). BASIC was made to be easy to learn. This program helps you average 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 END

This program first asks how many numbers you want to average. Then, it asks you to enter each number. It adds them all up and finally calculates and shows you the average. Once you learn the basics, there are many more powerful languages to explore!

History of Computer Programs

Diagram for the computation of Bernoulli numbers
Ada Lovelace's notes from 1843, showing a method for calculating Bernoulli numbers. Some historians consider this the first computer program.

The way we create computer programs has changed a lot as computers themselves have improved.

Early Ideas: Analytical Engine

In 1837, a machine called Jacquard's loom (which used punched cards to create patterns in fabric) inspired Charles Babbage. He tried to build a mechanical computer called the Analytical Engine. It had a "store" for numbers (like memory) and a "mill" for calculations (like a CPU). It was supposed to be programmed using two sets of punched cards: one for instructions and one for numbers. However, this complex machine was never fully built.

Ada Lovelace worked with Charles Babbage. In 1843, she wrote detailed notes about how the Analytical Engine could calculate complex numbers called Bernoulli numbers. Many historians believe her notes describe the world's first computer program.

Theoretical Computers: Universal Turing Machine

Universal Turing machine
A simple drawing of a Universal Turing Machine.

In 1936, Alan Turing imagined a theoretical device called the Universal Turing machine. This machine could model any calculation. It's like a simple machine with an endless tape that it can read, write, and move back and forth. It follows a set of rules to perform an algorithm (a step-by-step process). All modern computers are based on the ideas of a Turing machine.

First Electronic Computer: ENIAC

ENIAC-changing a tube
Glenn A. Beck changing a tube in ENIAC.

The Electronic Numerical Integrator And Computer (ENIAC) was built between 1943 and 1945. It was the first large-scale electronic computer. It was huge, weighing 30 tons and taking up a lot of space! It used almost 17,500 vacuum tubes (like old light bulbs) to create its circuits.

Programming the ENIAC was a big job. It involved connecting heavy cables into plugboards and setting thousands of switches. It could take up to two months to set up a program and a week to fix mistakes! ENIAC was used for important calculations, like predicting weather and helping aim artillery guns.

Programs in Memory: Stored-Program Computers

Instead of rewiring and flipping switches for every new task, a new idea emerged: the stored-program computer. This meant that a computer's instructions could be loaded into its memory just like data. This made programming much faster and easier.

Presper Eckert and John Mauchly, who built ENIAC, came up with the "stored-program concept" in 1944. Later, John von Neumann helped develop this idea further, leading to the von Neumann architecture in 1945. This design is still the basis for most computers today.

The IBM System/360 (1964) was a family of computers that all used the same set of instructions. This meant that programs written for one model could run on another, even if the computers were different sizes. These computers could also run multiple programs at once, which was a big step forward.

Until the 1970s, many computers were programmed by hand using switches on their front panels. Programs were written on paper, and then each instruction was entered by setting switches and pressing an "execute" button. Programs could also be loaded automatically using paper tape or punched cards.

Tiny Circuits: Very Large Scale Integration (VLSI)

Diopsis
A VLSI integrated-circuit chip.

A huge step in computer development was the invention of the Very Large Scale Integration (VLSI) circuit in 1964. This technology allowed engineers to put millions of tiny electronic components, like transistors, onto a single small chip.

This led to the creation of the microprocessor. In 1971, Intel created the Intel 4004, the first microprocessor. It was a "computer on a chip." Today, the terms "microprocessor" and central processing unit (CPU) are often used to mean the same thing.

Modern Computers: x86 Series

IBM PC-IMG 7271 (transparent)
The original IBM Personal Computer (1981) used an Intel 8088 microprocessor.

In 1978, Intel released the Intel 8086 microprocessor, which was later simplified into the cheaper Intel 8088. IBM used the Intel 8088 in their first personal computer in 1981. As more people wanted personal computers, Intel kept making better microprocessors. This line of processors is known as the x86 series.

A cool thing about the x86 series is that newer processors can still understand instructions from older ones. This is called backward compatibility. It means you can buy a new computer, and your old programs will still work!

Programming Tools: From Terminals to GUIs

DEC VT100 terminal transparent
The DEC VT100 (1978) was a popular computer terminal.

VLSI circuits also helped programming tools get better. Programmers used to work on computer terminals, which were like simple screens with text only. They typed commands into a command-line interface. By the 1990s, graphical user interfaces (GUIs) became common, making it much easier to write and manage code with visual tools.

Programming Styles and Languages

Programming languages are designed to help people tell computers what to do clearly and efficiently. They have special words, symbols, and rules (called syntax) that programmers use.

  • Keywords are special words that have a specific meaning in the language.
  • Symbols are characters like `+`, `-`, `=`, or `(` that perform operations or separate parts of the code.
  • Identifiers are names that programmers create for things like variables (which hold data) or functions (which perform actions).
  • Syntax Rules are like grammar rules that make sure the code is written correctly.

A programming language helps you create an algorithm, which is a step-by-step plan to solve a problem.

Generations of Programming Languages

W65C816S Machine Code Monitor
Machine language on a microprocessor.

Programming languages have evolved over time, often grouped into "generations":

  • First Generation (1GL): Machine Language

This is the lowest level language, directly understood by the computer. Programmers had to use numbers (called machine code) for every instruction. It was very hard to read and write!

  • Second Generation (2GL): Assembly Language

Assembly language uses short, easy-to-remember words (like "ADD" for addition) instead of numbers. A special program called an assembler translates these words into machine code. It's still very close to how the computer works, but much easier than 1GL.

  • Third Generation (3GL): High-Level Languages

These languages use compilers or interpreters to run programs. They are much easier for humans to understand and are not tied to a specific computer's hardware. Examples include Fortran (1958), COBOL (1959), ALGOL (1960), and BASIC (1964). The C programming language (1973) became very popular because it was high-level but still produced very efficient machine code. Most programming today uses 3GLs.

  • Fourth Generation (4GL): Focus on "What"

These languages focus on *what* you want to achieve, rather than *how* to do it step-by-step. They try to reduce errors and make programming faster. Structured Query Language (SQL), used for databases, is a good example. You tell the database what data you want, and it figures out how to get it.

Imperative Languages

Object-Oriented-Programming-Methods-And-Classes-with-Inheritance
A computer program written in an imperative language.

Imperative languages are like giving a computer a list of commands to follow in order. They use:

  • Declarations: Naming a variable and saying what kind of data it will hold (like `var x: integer;`).
  • Expressions: Things that produce a value (like `2 + 2` which gives `4`).
  • Statements: Commands that do something, like assigning a value to a variable (`x := 2 + 2;`) or making decisions (`if x = 4 then do_something();`).

Fortran

FORTRAN (1958) was one of the first high-level languages, designed for science and math. It was good at handling numbers and calculations. It became popular because IBM supported it, and it made programming scientific problems easier.

COBOL

COBOL (1959) was made for business tasks. It was designed to be easy for managers to read, with English-like statements. It was very important for handling text and business data.

Algol

ALGOL (1960) was very influential in how programming languages are designed. It was known for its clear, structured design and was the first to formally define its syntax. Many modern languages, like C, C++, and Java, were inspired by Algol.

Basic

BASIC (1964) was created at Dartmouth College to teach programming to all students. It was simple and became very popular with early microcomputers in the late 1970s. BASIC was one of the first languages to allow interactive sessions, where you could type commands and see results immediately.

C

C programming language (1973) was created to write the UNIX operating system. It's a small but powerful language that lets programmers control the computer almost as closely as assembly language, but with a much easier-to-use syntax. C is known for its flexibility and efficiency.

Computer-memory-map
A simplified map of how computer memory is organized.

C allows programmers to decide where data is stored in the computer's memory.

  • Global and Static Data: These variables are stored in a special area and keep their values throughout the program's run. Global variables can be seen by any part of the program.
  • Stack: This area is used for "local variables" (variables declared inside functions or blocks of code). They are automatically created when a function starts and disappear when it finishes.
  • Heap: This is a flexible area where programmers can ask for memory as needed. This memory stays until the programmer specifically frees it or the program ends.

C++

C++ (1985) was built on top of C, adding features for object-oriented programming. This style of programming helps organize large projects by grouping data and the actions that work on that data into "objects."

In object-oriented programming, you define a "class" (like a blueprint) for an object. For example, a `STUDENT` class might have a `name` and a `grade`. When you create an actual student, that's an "object." C++ also supports "inheritance," meaning a new class (like `STUDENT`) can inherit features from an existing class (like `PERSON`). This helps reuse code and model real-world relationships.

Here's a simplified example of how C++ code might be structured for a school application:

  • `grade.h` and `grade.cpp` define how a `GRADE` object works (e.g., converting a letter grade to a number).
  • `person.h` and `person.cpp` define a `PERSON` object (e.g., holding a name).
  • `student.h` and `student.cpp` define a `STUDENT` object, which "inherits" from `PERSON` (so a student is also a person) and has a `GRADE`.

This way, you can create a `STUDENT` object, give it a name, and assign it a grade, all organized neatly.

Declarative Languages

Declarative languages are different from imperative ones. Instead of telling the computer *how* to do something step-by-step, you tell it *what* you want to achieve. This often leads to fewer errors. Two main types are functional languages and logical languages.

A functional language treats computation like mathematical functions. You give it inputs, and it gives you outputs, without changing anything else in the program. This makes them good for tasks where you need to be very precise and avoid unexpected changes.

Lisp

Lisp (1958) is one of the oldest programming languages still used today. It's great for working with lists of data, which it organizes like a tree. Lisp is often used in artificial intelligence because it's very flexible.

ML

ML (1973) is another functional language. It's known for being very strict about data types, meaning it checks to make sure you're comparing apples to apples (and not apples to oranges!). This helps catch errors early.

Prolog

Prolog (1972) is a logic programming language. Instead of writing instructions, you state "facts" and "rules," and then you ask Prolog questions. It uses logic to figure out the answers.

For example, you could tell Prolog:

  • `cat(tom).` (Tom is a cat.)
  • `animal(X) :- cat(X).` (If something is a cat, then it is an animal.)

Then you could ask: `?- animal(tom).` (Is Tom an animal?) And Prolog would answer `true`.

Prolog is used in artificial intelligence for things like knowledge representation and problem solving.

Object-Oriented Programming

Object-oriented programming (OOP) is a popular way to organize programs. The main idea is to create "objects" that combine data (like a student's name) with the actions that can be performed on that data (like changing their grade).

Think of it like this:

  • You identify the "objects" in your problem (usually nouns, like `Student`, `Grade`, `Person`).
  • You figure out what describes each object (its "attributes," like a student's `name`).
  • You figure out what actions each object can do (its "operations" or "methods," like a student getting a `grade`).
  • You identify how objects relate to each other (like a `Student` is a type of `Person`).

This approach helps break down big programming problems into smaller, more manageable parts, making programs easier to build and maintain.

Software Engineering and Computer Programming

Two women operating ENIAC (full resolution)
Before programming languages, Betty Jennings and Fran Bilas programmed the ENIAC by moving cables and setting switches.

Software engineering is about using good techniques to build high-quality computer programs. Computer programming is the actual writing of the code.

In a formal setting, a systems analyst first figures out what a business needs from a computer system. They create a detailed plan, like an architect's blueprint for a building.

Goals for Programs

When building software, there are important goals:

  • Quality of Output: Is the information useful for making decisions?
  • Accuracy: Is the information correct and true?
  • Format: Is the information easy to understand?
  • Speed: Does the program deliver information quickly, especially when time is critical?

These goals must be balanced with costs, including:

  • The cost to develop the software.
  • The cost of computer hardware needed.
  • The ongoing cost to run and maintain the software.

Finding errors early in the development process is important because fixing them later becomes much more expensive.

The Waterfall Model

The waterfall model is a way to develop software step-by-step: 1. Investigation: Understand the problem. 2. Analysis: Figure out possible solutions. 3. Design: Plan the best solution. 4. Implementation: Write the program. 5. Maintenance: Keep the system working and make changes or fixes over time.

Computer Programmers

A computer programmer is a specialist who writes or changes the source code based on the detailed plan. Large projects often need a team of programmers. It's important for team members to work well together and for the program to be broken into smaller, manageable parts called "modules."

Program Modules

Modular programming is a technique where a program is divided into smaller, independent pieces called program modules. Each module has a specific job.

  • The function of a module is what it does.
  • The context of a module is what data it works on.
  • The logic of a module is how it does its job.

Good modules are like well-organized building blocks. They should have high cohesion (meaning all parts of the module work together for a single purpose) and low coupling (meaning modules don't depend too much on each other, making them easier to change or reuse).

Types of Computer Programs

Operating system placement (software)
A diagram showing how the user interacts with application software, which interacts with the operating system, which interacts with the computer hardware.

Computer programs can be grouped into different types based on what they do:

Application Software

Application software helps users do specific tasks. This includes programs like:

  • Word processors (for writing documents)
  • Web browsers (for surfing the internet)
  • Games
  • Enterprise applications (large systems for businesses, like managing sales, accounting, or customer information).

Businesses can either develop their own custom software or buy "off-the-shelf" software. Custom software is made exactly for their needs, but it can be expensive and take a long time. Off-the-shelf software is usually cheaper and faster to get, but it might not fit all their specific needs.

Sometimes, companies use an application service provider (ASP). An ASP is a company that provides the software, hardware, and support for an application, often over the internet. This can be a good option for smaller companies that don't have their own large IT teams.

Operating System

Concepts- Program vs. Process vs. Thread
Program vs. Process vs. Thread
Scheduling, Preemption, Context Switching

An operating system (OS) is the main software that manages a computer's basic functions. It's like the computer's conductor, making sure everything runs smoothly. Examples include Windows, macOS, and Linux.

In the early days (1950s), programmers had to manually manage everything. But in the 1960s, operating systems were developed to automate these tasks.

The core of an operating system is the kernel. The kernel's main jobs are:

  • Managing Processes: It makes sure different programs (called "processes") can share the computer's CPU fairly, giving each program a little bit of time to run.
  • Managing Memory: It decides where programs and data are stored in the computer's memory, making sure each program has enough space and doesn't interfere with others.
  • Managing Files: It handles creating, saving, opening, and deleting files on your disk drives.
  • Managing Devices: It helps programs communicate with hardware like the mouse, keyboard, printer, and speakers.
  • Managing Networks: It helps send and receive data over a network.
  • Providing System Functions: It offers basic services that programmers can use, like reading from files or getting the current date and time.
  • Communication Between Programs: It allows different programs to talk to each other.

Modern operating systems are usually written in high-level languages like C.

Utility Programs

A utility program is a small program designed to help manage and maintain the computer system.

  • They can check the health of your disk drives or memory.
  • They can optimize how files are stored.
  • They can compress files to save space or speed up transfers.
  • They can detect and remove computer viruses.

Microcode Programs

Not-gate-en
NOT gate
NAND ANSI Labelled
NAND gate
NOR ANSI Labelled
NOR gate
AND ANSI Labelled
AND gate
OR ANSI Labelled
OR gate

A microcode program is the lowest level of software, even below the operating system. It directly controls the tiny electronic circuits inside the central processing unit (CPU).

These circuits are made of "logic gates," which are like tiny switches that can be "on" or "off." By combining these gates (like NOT, AND, OR, NAND, NOR gates), the computer performs all its basic operations, like adding numbers or moving data.

Microcode instructions tell the CPU exactly how to perform each basic task, like fetching an instruction from memory, decoding it, and then executing it using the hardware. They also control how data moves between the CPU and the computer's memory.

See also

Kids robot.svg In Spanish: Programa informático para niños

kids search engine
Computer program Facts for Kids. Kiddle Encyclopedia.