visit
COBOL is in the news again. are filing unemployment claims nearly all at once, and the systems to process them are failing. Why? They need to scale to unprecedented levels, they’re written in COBOL, and… .
Here’s a look at the increase in searches for “COBOL programmers”:As a seasoned developer, I can probably assume what most of these things are, but I kept going to see what I’d learn. My first impression was: this is a great way to organize applications. We do this in some form with many applications, but these hard fast rules for organization? I like it.
Identification Division
This provides identifying information, such as the name of the program who wrote it, and the date they compiled it. We see things like this in comments and package files these days.Environment Division
This area tells what kind of system it’s being built on, what compiler is being used, and similar information. It’s not declarative but gives a programmer a general idea of the environment to build it in.Data Division
This is for defining file fields. What type of data will come in? How is it defined? This can be internal fields such as accumulators, flags, and counters, or external fields such as parameters passed to your program.Procedure Division
This is where the action happens. Think statements (sentences in COBOL), methods, computations, all the “meat” of the program lives here. This is the largest division of a COBOL program.This kind of organization is great. It makes sense. We have this in nearly every language we develop with today. You punch in text that’s compiled to an executable run by the computer. That’s where the similarities end.According to , 25,757 companies use COBOL. More than half of the companies I’ve worked for in my career used it somewhere. It’s out there everywhere, quietly processing our transactions every day.
Output for Debugging - COBOL has error codes and other output. You can pipe them to SYSOUT, or a file. You can make it verbose to see what’s happening for debugging purposes, like any other language.
Reusable code- COBOL has functions, which is crucial for abstracting things, and ways of creating reusable code in COBOL. It’s even object-oriented if that’s your thing. You can build libraries to reuse.
Types are important - Type definition, conversions, and all those other headaches are present in COBOL. Types are important, but data formatting is even more important. You really have to get this right in COBOL.
Naming is important - You have a lot of freedom when naming things in COBOL, and how you do it is important. There seems to be an emphasis on the idea that “this program will grow large and be maintained for decades”, which is something you don’t think about as much when writing an Angular app.
The period is your semicolon - In COBOL, everything, and I mean everything, is terminated with a period. This is the idea of “Sentences” in COBOL. The language strives to be as humanly readable as possible.
COBOL has familiar control structures - Not surprisingly, you have many loops, if statements, and other control structures you recognize from whatever programming language you’re using today.
I found jumping into COBOL, it’s easy to understand the basics of how to get rolling, based on my experience with other languages. You can get a general idea of how it works, but it’s not completely foreign. Until you start working with the code.You need a mainframe - To truly develop COBOL, you need a mainframe. I’ve found some simulators online, and is pretty cool, but the real deal lives on mainframes, so you’ll need access to one for true COBOL development.
Human readable - Everything is very human-readable, though the code is in all caps, so it’s yelling. Statements are called “sentences” that are punctuated by a period. The period is small, so it’s tough to find where you forgot to add it.
Rigid Syntax - COBOL earned its reputation for rigid syntax. Spaces at the beginning and end of every line (like bookends) and every single space and character matters. You need an eagle eye for coding with this language.
Wild constraints - There are constraints in place in 2020 that shouldn’t exist, but COBOL is dedicated to backward compatibility. A line of COBOL code is always 80 characters (unless it isn’t), and reports are 132 characters wide. Why? Because of punch cards, and old school impact line printers. Yes, really.
Resource stinginess is built in - You can really see how they designed the language around conserving resources. Memory, hard drive space, and CPU cycles are scarce so use them wisely. It’s easy for modern developers to forget how expensive and precious these things once were (and we should treat it that way now).
You must be very explicit - There isn’t much “loosey goosey” programming happening in COBOL, it won’t allow it. You have to intentional in everything you do. It’s very unforgiving, and that’s a good thing.
Jobs are a big focus of the language - It’s clear that COBOL is modeled around doing “jobs”. The programs are not real-time interactive programs like many applications, they’re designed to run at specified times, and the code is run from top to bottom. It’s meant to read in data, do things with that data, then spit it out.
You should take . You’d be surprised what you’ll learn. If you do, let me know what you think of it! I’d love to chat about it.