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 (pronounced "koh-bol") is a special computer programming language that uses English-like words. Its name stands for "common business-oriented language." It was created for business tasks, like managing money and information for companies and governments.

COBOL is still used a lot today, especially on big computers called mainframe computers. These computers handle huge amounts of data, like processing many transactions at once. Even though new systems are often built with other languages, COBOL is still important for keeping many older, but still vital, systems running.

This language was designed in 1959 by a group called CODASYL. It was partly based on an earlier language called FLOW-MATIC, created by Grace Hopper. The U.S. Department of Defense wanted a language that could work on different types of computers, and COBOL was the answer. It became very popular and has been updated many times over the years. The newest version is from 2023.

COBOL programs are written in a way that looks like sentences, for example, MOVE x TO y. This was meant to make them easy to understand. However, it also means COBOL programs can be very long and use many special words.

What is COBOL?

COBOL programs are organized into four main parts, called divisions:

  • The identification division gives the program a name.
  • The environment division describes how the program works with the computer system, like what files it uses.
  • The data division is where you set up all the information (data) the program will use.
  • The procedure division contains the actual instructions the program follows.

COBOL has been criticized for being very wordy and sometimes hard to change. This can make large COBOL programs difficult to understand completely, even if individual parts are clear. For many years, COBOL was mainly used on mainframes, but some operations are now moving to cloud computing.

How COBOL Started

In the late 1950s, programming computers was becoming very expensive. Companies and government agencies wanted a way to make it cheaper and easier to move programs from one computer to another.

In April 1959, Mary K. Hawes from Burroughs Corporation organized a meeting to discuss creating a common language for business. Important people like Grace Hopper and Jean Sammet attended. The U.S. Department of Defense (DoD) was very interested because they had many computers and spent a lot of money on programming. They wanted a language that would save time and money.

The First COBOL: COBOL 60

A big meeting happened at the Pentagon in May 1959. People wanted a language that could be used in many different areas, like banking and insurance. They agreed the new language should be easy to use, work on different computers, and use English words.

This meeting led to the creation of the Committee on Data Systems Languages, or CODASYL. A smaller group was given just three months to create the first version of the language.

The committee looked at existing languages like FLOW-MATIC (from Grace Hopper) and COMTRAN (from IBM). FLOW-MATIC was very important because it used long variable names, English commands, and separated data from instructions. Grace Hopper is often called "the mother of COBOL," even though others were also key designers.

The first COBOL specifications were approved in January 1960 and printed as COBOL 60. The goal was to make programs that were efficient, easy to move between computers, and simple enough for new programmers to learn.

Soon, many computer companies started building COBOL compilers (programs that translate COBOL code into computer instructions). The first COBOL program ran on an RCA 501 computer in August 1960. Later, the same program ran on different computers, proving that COBOL could indeed work on various machines.

COBOL Updates and Standards

After COBOL 60, many small issues were found. So, the language was updated several times.

Timeline of COBOL language
Year Informal name Official Standard
1960 COBOL-60 N/A
1961 COBOL-61 N/A
1963 COBOL-61 Extended N/A
1965 COBOL-65 N/A
1968 COBOL-68 ANSI INCITS X3.23-1968
1974 COBOL-74 ANSI INCITS X3.23-1974
1985 COBOL-85 ANSI INCITS X3.23-1985
ISO/IEC 1989:1985
2002 COBOL-2002 ISO/IEC 1989:2002
2014 COBOL-2014 ISO/IEC 1989:2014
2023 COBOL-2023 ISO/IEC 1989:2023

In the early days, COBOL compilers were slow. But they got much faster over time. By 1970, COBOL was the most used programming language in the world.

To make sure COBOL programs worked the same everywhere, groups like ANSI and ISO created official standards.

COBOL 85: Big Changes

In 1985, a major update called COBOL-85 was released. This version added many new features, like:

  • `END-IF`, `END-PERFORM`: These help clearly mark the end of code blocks.
  • `EVALUATE`: A statement that lets you choose different actions based on multiple conditions.
  • `INITIALIZE`: A way to quickly set data items back to their starting values.
  • `PERFORM` loops: You could now write loops directly in the code, making it easier to read.

COBOL 2002: Object-Oriented Features

In the 1990s, programmers started adding object-oriented programming (OOP) features to COBOL. OOP is a way of organizing code into "objects" that combine data and actions, making programs more modular and reusable. This update was officially released in 2002.

New features in COBOL 2002 included:

  • Free-form code: You no longer had to put code in specific columns.
  • User-defined functions: Programmers could create their own mini-programs.
  • Recursion: A function could call itself.
  • Unicode support: Handling different character sets from around the world.
  • Pointers: Ways to directly manage computer memory.

Recent Updates: COBOL 2014 and 2023

COBOL continued to evolve. COBOL 2014 made some features optional and added new ways to handle data. The most recent standard, COBOL 2023, added even more features, such as:

  • Asynchronous messaging: Sending messages without waiting for an immediate reply.
  • Transaction processing: Better ways to manage groups of operations that must all succeed or all fail.
  • XOR logical operator: A new way to combine true/false conditions.
  • `DELETE FILE` statement: A direct way to remove files.

COBOL's Lasting Impact

COBOL programs are still used all over the world by governments and in industries like retail, travel, finance, and healthcare. In 2016, it was reported that many U.S. federal agencies still use COBOL.

As of 2020, COBOL was running the background processes for 95% of credit and debit card swipes! This shows how important it still is for daily life.

The Y2K Problem

Near the year 2000, there was a big worry called the year 2000 problem (Y2K). Many old computer programs, including COBOL ones, stored years with only two digits (e.g., '99' for 1999). People worried that when the year changed from '99' to '00', computers might think it was 1900 instead of 2000, causing major problems.

Many COBOL programmers, some of whom had written the original systems decades earlier, worked hard to fix these programs. This effort cost a lot of money, but it prevented widespread computer failures. After Y2K, many of these updated COBOL programs continued to be used.

Modernizing COBOL Systems

Even though COBOL is old, many organizations still use it. Surveys in 2006 and 2012 showed that over 60% of organizations used COBOL, often for most of their internal software.

However, the number of COBOL programmers is getting smaller as older programmers retire. This creates a challenge for businesses and governments that rely on these systems. Rewriting old COBOL systems in newer languages can be very expensive and difficult. Because of this, there's a push to train more people in COBOL.

During the COVID-19 pandemic, some U.S. states faced problems with their unemployment benefit systems because they relied on old COBOL programs and didn't have enough skilled programmers to update them quickly. This highlighted how crucial COBOL still is for many important services.

How COBOL Code Looks

Syntax: English-like Commands

COBOL uses an English-like way of writing code. For example, you can write x IS GREATER THAN y or simply x > y. Because of this, COBOL has over 300 special words (keywords). Some keywords are just different ways to say the same thing, like `IN` and `OF`.

A COBOL program is made up of words, numbers or text (literals), special characters for data (picture character-strings), and separators like spaces or commas.

Code Format: From Punch Cards to Free Form

IBM keypunch deck for Cobol student program at New York University 1979
COBOL program deck of punched cards, from the 1970s

In the past, COBOL programs were often written on punched cards. This meant the code had to be placed in very specific columns. This was called "fixed-format" code.

Name Column(s) What it was used for
Sequence number area 1–6 For card numbers (ignored by the computer)
Indicator area 7 To mark comments (`*`), new pages (`/`), or continued lines (`-`)
Area A 8–11 For main headings and special numbers
Area B 12–72 For most of the program's code
Program name area 73– To identify the program

Since COBOL 2002, you can also write "free-format" code, which means you can place code anywhere on the line, just like in many newer programming languages. Comments can now start with `*>`.

Data Division: Describing Your Data

The data division is where you tell the program about all the data it will use. This includes information for files, temporary storage, and data passed between different parts of the program.

How Data is Organized

Data items in COBOL are organized in a hierarchy, like a family tree. You use "level-numbers" to show if one piece of data belongs to another.

  • Level-number `01` is for the main data items, called records.
  • Items with higher level-numbers (like `05`, `10`) are parts of the items with lower numbers.
  • Group items contain other data items. Elementary items are the smallest pieces of data.

For example:

       01  some-record.                   *> This is a main record
           05  num            PIC 9(10).  *> A number, part of 'some-record'
           05  the-date.                  *> A group, part of 'some-record'
               10  the-year   PIC 9(4).   *> A number, part of 'the-date'
               10  the-month  PIC 99.     *> A number, part of 'the-date'
               10  the-day    PIC 99.     *> A number, part of 'the-date'

If you have the same name for data items in different groups, you can use `IN` or `OF` to specify which one you mean, like `the-year IN the-date`.

Special Data Levels

  • A level-number `77` means the data item is stand-alone and not part of a group.
  • A level-number `88` defines a "condition name." This is true if its parent data item has a specific value. For example, `wage-is-hourly` could be true if `wage-type` is "H".

Data Types: What Kind of Information?

COBOL has different data types to store different kinds of information:

  • Alphabetic: Only letters and spaces.
  • Alphanumeric: Any characters (letters, numbers, symbols).
  • Boolean: True/false values (stored as 0s and 1s).
  • Numeric: Only numbers.
  • Object: References to objects (used in object-oriented COBOL).
  • Pointer: Used to point to memory locations.
PICTURE Clause: How Data Looks

The `PICTURE` (or `PIC`) clause tells COBOL how a data item should look and what it can contain.

  • `9` means a decimal digit.
  • `X` means any character.
  • `A` means only letters or spaces.
  • `S` means the number can be positive or negative.
  • You can use `(number)` to repeat a character, like `9(5)` for five digits.

For example:

Examples
PICTURE clause Value in Value out
PIC 9(5) 100 00100 (adds leading zeros)
PIC +++++ -10 "  -10" (shows the sign)
PIC 99/99/9(4) 30042003 "30/04/2003" (adds slashes)
USAGE Clause: How Data is Stored

The `USAGE` clause tells COBOL how the data is stored in the computer's memory. For example, `USAGE DISPLAY` means it's stored as a string (like text), while `USAGE PACKED-DECIMAL` stores numbers in a very compact way.

Procedure Division: The Program's Actions

This is where the actual instructions of the program are written.

Procedures: Steps in the Program

Sections and paragraphs in the procedure division are like mini-programs or steps. You can use the `PERFORM` command to run these steps. When a `PERFORM` command finishes, the program goes back to where it was.

Statements: The Commands

COBOL 2014 has 47 main commands, also called "verbs." They fall into categories like:

  • Control flow: Commands like `IF` (for making decisions) and `EVALUATE` (like a `switch` statement in other languages) control the order of operations. `PERFORM` is used for loops and calling procedures. `CALL` and `INVOKE` are used to run other programs or methods. `STOP RUN` ends the program.
  • Input/Output (I/O): Commands like `OPEN`, `CLOSE`, `READ`, and `WRITE` handle files. `ACCEPT` and `DISPLAY` are used for interacting with the user (like showing text on the screen).
  • Data manipulation: Commands like `MOVE` (to copy data), `ADD`, `SUBTRACT`, `MULTIPLY`, `DIVIDE`, and `COMPUTE` (for math). `INITIALIZE` sets data to default values. `STRING` and `UNSTRING` combine or split text.

Scope Termination: Ending Commands

Some COBOL commands can contain other commands. You can end these blocks of code in two ways:

  • With a period (`.`) at the end of a sentence. This ends all open commands.
  • With a "scope terminator" like `END-IF` or `END-READ`. This ends only the specific command it matches.

Using periods to end commands can sometimes cause bugs if you're not careful, especially with nested `IF` statements. Explicit scope terminators like `END-IF` make the code clearer and help prevent these bugs.

Hello, World! in COBOL

Here's a simple COBOL program that displays "Hello, world!":

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

In the past, you would often submit COBOL programs using punched cards and special instructions called JCL. The computer would then run the program and show the output.

Images for kids

See also

Kids robot.svg In Spanish: COBOL para niños

kids search engine
COBOL Facts for Kids. Kiddle Encyclopedia.