Skip to content
Modern COBOL: 2002, 2014, OO COBOL
step 1/4

Reading — step 1 of 4

Learn

~3 min readModern COBOL and Mainframe Ecosystem

COBOL has evolved. The standard has been revised in 1985, 2002, 2014, and 2023. Modern COBOL is a real language — not just the verbose 1959 design.

COBOL-2002 additions

Free-format source — no more column rules:

IDENTIFICATION DIVISION.
PROGRAM-ID. modern.
PROCEDURE DIVISION.
    DISPLAY "freed from columns!"
    STOP RUN.

Use --free flag with GnuCOBOL or >>SOURCE FORMAT IS FREE directive.

Object orientation — classes:

CLASS-ID. Counter.
FACTORY.
    METHOD-ID. NEW.
        PROCEDURE DIVISION.
            INVOKE SELF "NEW"
        END METHOD NEW.
END FACTORY.
OBJECT.
    DATA DIVISION.
    WORKING-STORAGE SECTION.
    01 COUNT PIC 9(5) VALUE 0.
    METHOD-ID. INC.
        PROCEDURE DIVISION.
            ADD 1 TO COUNT.
            EXIT METHOD.
    END METHOD INC.
END OBJECT.
END CLASS Counter.

Not widely used in the wild — but the option exists.

Bit operations for embedded / system code:

COMPUTE X = FUNCTION BIT-OF(BYTE).
COMPUTE BYTE = FUNCTION HEX-OF(X).

Better arithmetic — IEEE-754 floats:

01 X PIC FLOAT-LONG.    *> 64-bit IEEE float
01 Y PIC FLOAT-SHORT.   *> 32-bit IEEE float

Before this, COBOL had only proprietary float types per vendor.

Intrinsic functions & string building — COBOL-2002 added over 100 built-in FUNCTIONs, including ones for cleaning up text:

FUNCTION TRIM(NM)              *> strip leading + trailing spaces
FUNCTION UPPER-CASE(NM)
FUNCTION LOWER-CASE(NM)
FUNCTION LENGTH(NM)

These pair naturally with the classic STRING verb, which concatenates fields into an output area:

01 NM       PIC X(20).
01 OUT-MSG  PIC X(40).

STRING "Hello, " FUNCTION TRIM(NM) "!"
    DELIMITED BY SIZE
    INTO OUT-MSG.
DISPLAY FUNCTION TRIM(OUT-MSG).

Every PIC X field is fixed-width and space-padded — NM holds "Ada " even though only 3 characters were typed in. Without FUNCTION TRIM, STRING would copy all the trailing spaces into OUT-MSG too, so DISPLAY would print the name followed by a wall of spaces before the !. Wrapping both the source field and the final DISPLAY in FUNCTION TRIM keeps the output tight.

COBOL-2014 additions

DYNAMIC LENGTH for variable-length strings:

01 NAME PIC X DYNAMIC LENGTH.
MOVE "Ada" TO NAME.        *> length is now 3
MOVE "Lovelace" TO NAME.    *> length is now 8

No more padding to a fixed-size field.

Exception handling — COBOL gets try/catch:

DIVIDE A BY B GIVING C
    ON SIZE ERROR
        DISPLAY "overflow"
    NOT ON SIZE ERROR
        DISPLAY "ok"
END-DIVIDE.

DECLARE EXCEPTION-OBJECT my-error.
RAISE my-error.

More Java-like syntax than the old ON SIZE ERROR / DECLARATIVES style.

COBOL-2023 (latest)

  • Improved Unicode support (UCS-2, UCS-4 strings)
  • Better integration with C and Java (FFI)
  • Refined module system
  • More math functions

What modern COBOL shops actually use

The surprise: most production COBOL is still 1985 style. Modernizations are gradual:

  • Free format: occasionally used in new code
  • OO COBOL: rare; most code is procedural
  • Better functions: yes, intrinsic functions ARE used
  • Exception handling: gradually replacing DECLARATIVES

Why? Mainframe production code lives for 30+ years. Every change is a risk. Old idioms persist because they work and shops don't break what isn't broken.

Tooling

  • GnuCOBOL (open source) — supports COBOL-85 and large parts of 2002
  • Micro Focus Visual COBOL — full modern, .NET/Java integration
  • IBM Enterprise COBOL — z/OS, full standard plus IBM extensions
  • Linters / static analysis: SonarSource COBOL, Micro Focus tools

For learning: stick with COBOL-85 idioms (what 99% of production looks like). Know that modern features exist for greenfield projects.

What the future holds

COBOL isn't dying — it's gradually migrating. Languages competing:

  • Java — JVM on the mainframe, gradual rewrite
  • Go — for new microservices around the COBOL core
  • Python — for data analysis on mainframe data

The banks running 50-year-old COBOL are NOT going to rewrite it next year. But each new feature is more likely to be in something else.

Learning COBOL today is best for:

  • Government modernization projects (IRS, Social Security, state systems)
  • Banking maintenance jobs (high-paying, low-supply)
  • Insurance and pensions systems
  • Transit and aviation back-end systems

It's a niche, but a high-value one. Know your toolkit.

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…