Of course, it has had its critics. In 1975, Edsgar Dijkstra famously proclaimed that The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence[sic]." This undoubtedly led to the decline of teaching COBOL in universities, but it remained the dominant business language.
Compared to common programming languages today, COBOL is different, and in some ways very limited: you can't do dynamic memory allocation, you can't easily access low-level features of the operating system or particular computer architecture. The most common forms of the language can't use recursion. You'd never want to write a compiler in COBOL. A computer science student presented with COBOL would be appalled.
This is a category error. In modern terminology, COBOL is actually a domain-specific language, specific to the particular domain of business programming. Robert Glass identified specific ways in which COBOL is better suited to business programming than general-purposes languages, among them:
The source files are simple text files. Having a useful programming editor with language support is as convenient for COBOL as any other language, if not more so. The easiest thing for a beginner is to use Visual Studio Code, the only competitor for my affections since EMACS.
There are surprisingly many VSCode extensions for COBOL. Right now, I'm using the bitlang code colorizer and Broadcom COBOL language support. A lot of the others are intended for people programming in a mainframe environment, but that adds complexity we don't need for an introduction.
Columns 1-6 are there for a sequence number. Column 7 is called the indicator area; in general, it's mostly used to indicate comments by putting an asterisk '*' in that column. Code then goes in columns 8 through 72, and columns 73-80 are basically free for the programmers use.
Modern COBOL compilers also accept a free format which doesn't force your code into the 80-column straitjacket, but a very large proportion of existing code is still in the card-image format. For right now, we'll stick with card images.
Brace yourselves: COBOL is not a block-structured language like nearly any other language you've ever used. A major design goal for COBOL from the first was that it should be "self-documenting" with an English-like syntax. Instead of having functions or subroutines and blocks, we have divisions, sections, paragraphs, and statements. (We'll see something almost like a subroutine with the PERFORM verb below.)
COBOL programs always have at least an identification division and a procedure division. The identification division has one important paragraph, the PROGRAM-ID. You need to give the program a name here. The name doesn't need to correspond to the file name or pretty much anything, except when your COBOL program is being called from another COBOL program. This is through the CALL verb, which we're not going to cover.
There's one more bit of card-image format here. Notice that `DISPLAY "Hello, world"` is indented four columns. That's because the part from column 8-72 actually has two parts: the A section, from column 8-11, and the B section from column 12 on. Divisions, sections, and paragraphs need to start in the A section; code statements should start in the B section.
Of course, "Hello, World" doesn't really give you a good picture for any language, so let's look a little deeper into COBOL with something that at least resembles a real business program. We're going to use a pretty common example: computing a paycheck for hourly employees, including computing Federal, State, and FICA tax.
No point in repeating the identification division. We start with a new division, the environment division, which exists to collect the interface between the COBOL program and the outside world.
Once again, we're going to exercise some aspects of COBOL that will be surprising to people who haven't worked in the record-oriented world of data-processing. In UNIX, Linux, MacOS, or Windows, a record is a line of text followed by some end of line character or characters. This causes a problem for traditional COBOL, but COBOL compilers implement a non-standard extension to handle this: ORGANIZATION IS LINE SEQUENTIAL.
The next part of the program describes the data we're working with. In COBOL, all data is generally presumed to be contained in fixed-format records. Those records have a hierarchical structure that's indicated by the level numbers: 01 is the top level, and subdivisions get higher numbers. I used 02, 03, and so forth, but that's arbitrary; we used to use 01, 05, and so on because it was easier to insert cards without repunching them all.
This is our input, which is fixed format; we're connecting it to the TIMECARDS file with the FD line. Following that is the working storage section. It looks a little unfamiliar if you're not used to COBOL, but really, I'm just declaring variables I'll use in the program later.
The unfamiliar part of this is the PIC (or PICTURE) clause. COBOL is not strongly typed at all. Instead, more like C, every declaration is identifying a piece of memory; the PIC tells COBOL how to interpret that memory with a "picture". In this case, 9(4)v99 tells COBOL that a chunk of memory named, for example REGULAR-HOURS is to be interpreted as a six-digit number that is assumed to have a decimal point (the V) in front of the last two digits. USAGE COMP tells COBOL to use an internal format that's suited to fast arithmetic. What that format actually is is somewhat flexible and depends on the architecture, which means you'd best not depend on it being the same everywhere.
If you want to be confident of this, don't use USAGE COMP, which leads to another part of the data, the format for a check to be output. These fields are the default usage, which is printable where USAGE COMP is not.
I bought and ran through this Udemy course, which is pretty good, and among several COBOL books on Kindle, I like Beginning COBOL for Programmers by Michael Coughlan. There are a mountain of YouTube videos, of which I only looked at a few. This one seems good, but search for COBOL and you'll find lots more.
There will be more to come as well. On April 9th, IBM and the Open Mainframe Project announced a joint project to connect states with COBOL skills and to teach COBOL Programming. It has several resources, including a bulletin board for COBOL programmers who want to get back in the business, and the beginnings of an open source COBOL course.
As you can see from this little example, COBOL is not like your normal programming language. You can't write a compiler or a kernel module in COBOL, and the syntax is not what we've grown to expect. But then consider another common domain-specific language: SQL. The syntax is kind of weird, and the semantics depend on relational algebra.
COBOL (common business-oriented language) is defined as a standard programming language developed by a consortium CODASYL (Conference/Committee on Data Systems Language) in 1959 to support business and financial applications. This article explains the fundamentals of COBOL programming language, examples, uses, and the top five challenges it faces.
COBOL (common business-oriented language) is a standard programming language developed by a consortium CODASYL (Conference/Committee on Data Systems Language) in 1959 to support business and financial applications. The language was primarily conceived for mainframe computers and was not dependent on any particular operating system for its working.
Before the inception of COBOL, each operating system had a programming language of its own. However, this seemed to be a hurdle for several companies as they had to work with the systems of numerous brands. This led to the initiation of the COBOL project. The portable framework and usability made COBOL popular across disciplines such as banks, financial institutions, insurance companies, human resources departments, and government agencies.
Since the 1950s, COBOL has had several versions; COBOL 60 being the first one, followed by COBOL 61, COBOL 65, COBOL 68, COBOL 74, COBOL 85, COBOL 2002, and the latest COBOL 2014. Although COBOL has ended its development, its programs are still in use and may continue to exist until the software is ready to migrate to a new alternative.
COBOL has several advantages over its rivals. Firstly, it is a portable language, which means that the language is reliant on any specific vendors. It supports operating systems such as Windows, Linux, mainframes, Unix, and others. Additionally, COBOL is accessible to anyone good at English grammar. Also, COBOL uses the self-documenting feature to ease maintainability by synchronizing the code and its documentation.
Several large enterprises, organizations, banks, financial firms, insurers, and industrial sectors such as healthcare, retail, automotive, shipping services, and others use COBOL for various reasons. For example, companies such as IBM, UPS, Fiserv, Bank of America, JPMorgan Chase, and Cigna still depend on COBOL. Thus, the language continues to play a crucial role in business computing that drives the global economy.
Despite the lesser developments in its versions, COBOL remains the language of choice across diverse markets and business lines. According to a Feb 2022 global survey by Micro Focus, around 92 percent of the survey-takers (software engineers, developers, IT executives, and architects from 49 countries) opined that COBOL applications are developed today to serve the strategic purpose of their respective organizations.
COBOL came into existence with the motto of developing a language that communicates better with computers. However, people observed that the demand for the language grew across industries with time. A lot of credit goes to the readability aspects of COBOL. It allows a layperson to learn and work with the language with proper training.
93ddb68554