kids encyclopedia robot

COBOL facts for kids

Kids Encyclopedia Facts
Quick facts for kids
COBOL
Paradigm Procedural, imperative, object-oriented, generic
Designed by Howard Bromberg, Norman Discount, Vernon Reeves, Jean E. Sammet, William Selden, Gertrude Tierney, with indirect influence from Grace Hopper
Developers CODASYL, ANSI, ISO/IEC
First appeared 1959; 66 years ago (1959)
Stable release
ISO/IEC 1989:2023 / 2023
Typing discipline Weak, static
Filename extensions .cbl, .cob, .cpy
Major implementations
GnuCOBOL, IBM COBOL, Micro Focus Visual COBOL
Dialects
COBOL/2, DEC COBOL-10, DEC PDP-11 COBOL, DEC PDP-11 COBOL-85, DEC VAX COBOL, DOSVS COBOL, Envyr ICOBOL, Fujitsu COBOL, Hitachi COBOL2002, HP3000 COBOL/II, IBM COBOL SAA, IBM COBOL/400, IBM COBOL/II, IBM Enterprise COBOL, IBM ILE COBOL, IBM OS/VS COBOL, ICL COBOL (VME), Micro Focus ACUCOBOL-GT, Micro Focus COBOL-IT, Micro Focus RM/COBOL, Micro Focus Visual COBOL, Microsoft COBOL, Raincode COBOL, Realia COBOL, Ryan McFarland RM/COBOL, Ryan McFarland RM/COBOL-85, Tandem (NonStop) COBOL, Tandem (NonStop) SCOBOL, UNIVAC COBOL, Unisys MCP COBOL74, Unisys MCP COBOL85, X/Open COBOL, Veryant isCOBOL, Wang VS COBOL, WATBOL
Influenced by
Initial: AIMACO, COMTRAN, FACT, FLOW-MATIC
COBOL 2002: C++, Eiffel, Smalltalk
Influenced
CobolScript, EGL, PL/I, PL/B

COBOL (which stands for "common business-oriented language") is a computer programming language that works a bit like English. It was made for business tasks. Think of it as a set of instructions you give to a computer to help companies and governments manage their money and information.

COBOL was created in 1959 by a group called CODASYL. It was partly based on another language called FLOW-MATIC, designed by Grace Hopper. The U.S. Department of Defense wanted a language that could work on different computers, and COBOL was their answer. Even though it was first seen as a temporary solution, the Defense Department made computer makers use it. This helped COBOL become very popular.

COBOL programs use simple, English-like sentences, like MOVE x TO y. This was meant to make them easy to read and understand. However, it also means COBOL programs can be very long and use many special words (over 300!).

COBOL programs are divided into four main parts: identification, environment, data, and procedure. These parts help keep the code organized. Even though it's an older language, COBOL is still used today, especially in big companies and governments, for important tasks like managing bank accounts or processing large amounts of data. Many of these programs run on powerful mainframe computers.

History of COBOL

COBOL has been around for a long time, and it has changed quite a bit over the years.

How COBOL Started

In the late 1950s, computers were becoming more common, but writing programs for them was very expensive. Companies and government offices needed a better way to handle their data. A study in 1959 showed that it cost a lot of money to write programs and even more to change them to work on new computers. People thought that if there was one common language for business, it would save a lot of time and money.

On April 8, 1959, a computer scientist named Mary K. Hawes brought together people from universities, computer companies, and users. They wanted to create a common language for business. Important people like Grace Hopper, who invented the English-like language FLOW-MATIC, and Jean Sammet were there.

The group asked the Department of Defense (DoD) to help. The DoD had many computers and spent a lot on programming. They liked the idea of a portable language that could work on different machines. This would save them money and make it easier to update their systems.

COBOL 60: The First Version

On May 28 and 29, 1959, a big meeting happened at the Pentagon to talk about creating this new language. Forty-one people attended, and they all agreed that more people should be able to program computers. They also decided that the new language should use as much English as possible, be easy to change, and work on different computers.

A small group was given just three months to create the first version of the language. This deadline seemed very short to them! This group was called the Committee on Data Systems Languages, or CODASYL.

The committee looked at existing languages like FLOW-MATIC, AIMACO, and COMTRAN. FLOW-MATIC was very important because it was already working. Grace Hopper, who created FLOW-MATIC, helped the committee. FLOW-MATIC gave COBOL ideas like using long names for variables, English words for commands, and separating data descriptions from instructions.

Some people call Grace Hopper "the mother of COBOL," but Jean Sammet said that Hopper wasn't the main creator. IBM's COMTRAN language also influenced COBOL, adding features like formulas and better ways to manage files.

The first version of COBOL, called COBOL 60, was approved on January 8, 1960. Its goals were to make programs efficient, easy to move between computers, and simple for new programmers to use.

Soon, many computer companies started building COBOL compilers (programs that turn COBOL code into something the computer understands). The very first COBOL program ran on August 17, 1960, on an RCA 501 computer. This showed that COBOL could work on different machines!

COBOL Changes Over Time

After COBOL 60, many small problems were found. So, the language was improved several times.

  • COBOL-61 to COBOL-65: These versions fixed problems and added new features like sorting and report writing.
  • COBOL-68: This was the first official standard version of COBOL, making sure different versions of the language worked the same way.
  • COBOL-74: By 1970, COBOL was the most used programming language in the world! This version added more features for handling files and debugging.
  • COBOL-85: This update brought big changes. Some companies worried it would be too expensive to update their old COBOL programs. But it added useful features like `END-IF` and `EVALUATE`, which made programs easier to write and understand.
  • COBOL 2002: In the early 1990s, people started adding "object-oriented" features to COBOL. This means organizing code into "objects" that can do things. This version also allowed for more flexible code writing and support for different languages like Unicode.
  • COBOL 2014: This version updated how COBOL handles numbers and made some older features optional.
  • COBOL 2023: The newest standard added features for sending messages between programs and handling transactions (like money transfers).

COBOL Today

COBOL programs are still used all over the world by governments and businesses. In 1997, it was estimated that 80% of the world's business programs ran on COBOL, with over 200 billion lines of code!

Near the end of the 1990s, many COBOL programmers worked hard to fix the year 2000 problem (Y2K). This was a big deal because older programs only used two digits for the year (like '99' for 1999). When 2000 came, computers might think it was 1900! COBOL programs were especially affected because they dealt with so many dates.

Even today, COBOL is very important. In 2017, it was reported that 43% of banking systems still used COBOL. However, many COBOL programmers are getting older and retiring. This means there aren't as many people who know COBOL, which can be a problem for organizations that still rely on it. During the COVID-19 pandemic, some US states had trouble with their unemployment systems because they were built with COBOL and needed experts to fix them quickly.

How COBOL Works

Program Structure

COBOL uses an English-like way of writing code. This means you can often read a COBOL program and understand what it's trying to do, even if you don't know much about programming. For example, you can write x IS GREATER THAN y or just x > y.

A COBOL program is divided into four main parts, called divisions:

  • Identification Division: This part gives the program a name and describes what it is.
  • Environment Division: This part tells the program about the computer system it's running on, like what files it will use.
  • Data Division: This is where you tell the program about all the data it will use, like numbers, text, or dates.
  • Procedure Division: This is the most important part! It contains all the instructions (or "statements") that tell the computer what to do.

Each division is then broken down into smaller parts called sections, paragraphs, and sentences.

Code Format

IBM keypunch deck for Cobol student program at New York University 1979
COBOL programs used to be written on punched cards like these in the 1970s.
Original XEDIT
A computer screen showing COBOL code, similar to how it looked in the past.

When COBOL was most popular, people used machines called keypunch machines to put their code onto punched cards. These cards had holes that represented the code. Because of this, COBOL code used to have a very strict layout, called fixed-format. Each line of code had to be in specific columns.

For example:

  • Columns 1-6 were for numbering the cards.
  • Column 7 was for special symbols, like `*` for comments (notes that the computer ignores).
  • Columns 8-11 were for main headings.
  • Columns 12-72 were for the actual program code.

Since 2002, COBOL also allows free-format code. This means you can write code anywhere on the line, just like in many newer programming languages.

Object-Oriented Programming

Since 2002, COBOL can also use object-oriented programming (OOP). This is a way to organize your code into reusable "objects" that have their own data and actions (called "methods"). Think of an object as a blueprint for something, like a "Customer" object that holds a customer's name and address, and can also perform actions like "update address."

Handling Files

COBOL is very good at handling files. It supports different ways to organize data in files:

  • Sequential files: Records are stored one after another, like a list. You have to read them in order.
  • Indexed files: These files have an index, like a book, that lets you quickly find specific records without reading the whole file.
  • Relative files: Records are stored based on their position, like items in an array.

Data Types

In COBOL, you need to tell the program what kind of data you're working with. This is done in the Data Division.

  • Aggregated Data: You can group related data together. For example, you might have a "customer-record" that includes a "customer-name" and a "customer-address."
       01  some-record.                   *> This is a main group of data
           05  num            PIC 9(10).  *> This is a number, up to 10 digits
           05  the-date.                  *> This is a smaller group for a date
               10  the-year   PIC 9(4).   *> The year, 4 digits
               10  10  the-month  PIC 99.     *> The month, 2 digits
               10  the-day    PIC 99.     *> The day, 2 digits

In this example, `some-record` is the main group. `num` is a single piece of data. `the-date` is a smaller group that contains `the-year`, `the-month`, and `the-day`.

  • PICTURE Clause: This is a special way to describe what kind of data an item holds and how it should look. For example, `PIC 9(5)` means a number with 5 digits. `PIC X(30)` means text with up to 30 characters. You can also use it to format numbers, like adding dollar signs or slashes for dates.
Examples of PICTURE clauses
Code What it means Example
PIC 9(5) A number with 5 digits If you put `100` in it, it becomes `00100`
PIC +++++ A number with a sign, formatted If you put `-10` in it, it becomes ` -10` (with spaces)
PIC 99/99/9(4) A date formatted with slashes If you put `30042003` in it, it becomes `30/04/2003`

Statements: What the Program Does

The Procedure Division contains all the "statements" or "verbs" that tell the computer what actions to perform.

  • Control Flow: These statements control the order in which the program runs.
    • `IF` and `EVALUATE`: These are used for making decisions. For example, `IF` a condition is true, do something. `EVALUATE` is like a more powerful `IF` that can check many conditions at once.
    • `PERFORM`: This is used to repeat a set of instructions or to call a part of the program to run.
    • `CALL` and `INVOKE`: These are used to run other programs or methods.
    • `STOP RUN`: This statement stops the program.
  • Input/Output (I/O): These statements handle how the program gets information and shows results.
    • `OPEN`, `CLOSE`, `READ`, `WRITE`: These are used for working with files. `READ` gets data from a file, and `WRITE` puts data into a file.
    • `ACCEPT` and `DISPLAY`: These are used for interacting with the user. `ACCEPT` gets input from the user (like typing on the keyboard), and `DISPLAY` shows messages on the screen.
  • Data Manipulation: These statements change or move data.
    • `MOVE`: This assigns a value from one place to another. Like `MOVE 10 TO MY-NUMBER`.
    • `ADD`, `SUBTRACT`, `MULTIPLY`, `DIVIDE`, `COMPUTE`: These are for doing math. `COMPUTE` lets you use formulas.
    • `STRING` and `UNSTRING`: These combine or split pieces of text.
    • `INSPECT`: This looks for specific parts within a piece of text and can count or replace them.
    • `SORT` and `MERGE`: These arrange data in order or combine sorted files.

Hello, World! Example

A "Hello, World!" program is usually the first program someone learns in a new language. It just prints "Hello, World!" on the screen. Here's how it looks in COBOL:

       IDENTIFICATION DIVISION.
       PROGRAM-ID. hello-world.
       PROCEDURE DIVISION.
           DISPLAY "Hello, world!"
           .

In the past, you would have typed this code onto punched cards and fed them into a large computer called a mainframe computer. The computer would then run the program and show "HELLO, WORLD" on a special screen or printer.

Images for kids

See also

  • Alphabetical list of programming languages
  • CODASYL
  • Comparison of programming languages
kids search engine
COBOL Facts for Kids. Kiddle Encyclopedia.