Take that. I respect the wikipedia discussion decision, but come on, program one compiles and executes. Even if it was based on Canadian elementary and high-school, missing the point, 5-7-5 fake haiku.

So…ummm, it could be program-id. sun. or…

I wasn’t allowed to post that as an actual Haiku on wikipedia. Call it a 5-7-5. Because, it isn’t, really, Haiku.

Compiles to a program that returns a failure code when run. Fails as poetry, fails as code. Your welcome.

Which is an easter egg in the cbrain esoteric programming language, when requesting help for Citizen Band code 10-94, Request for long count. Returns CB code 10-7, Leaving air, radio off.

"that would be "

*> The Weinersmith Fly By Frog Sort, weiner sort for short

*> frogSort, called for help with 10-94, request for count

That comic spawned the writing of frogSort , officially known as the Weinersmith Fly By Frog Sort , or weiner sort .

http://www.smbc-comics.com/?id=2516 (with a small snip from the actual comic, Copyright 2012 Zach Weiner)

And another one; Grace Hopper, by Zach Weinersmith at Saturday Morning Breakfast Cereal.

Here is a link to some actual humour; Bob the Dinosaur, thanks to Scott Adams.

Ok, sorry for the lame.

One. COBOL programmers understand how the world works, they can change a light bulb. Which then lets them see their keyboard so they can fill out screen PF103D, submit job LB103R and request approval for a backup T5W-60.

How many COBOL programmers does it take to change a light bulb?

THIS IS YOUR CAPTAIN SHOUTING.

This is your captain speaking.

You should have seen the look on her face when I drove pasta.

The lady down the street didn’t believe I could build a car out of spaghetti.

Wrote COBOL all morning, all afternoon and into the night. Another carpe, diem’ed .

And being COBOL, I have to show you how little code it takes:

What did GnuCOBOL reply to the executive? Sir, I can

What did COBOL reply to the executive? Yes, I can

A COBOL programmer’s husband asks, “Honey can you go to the store and get some milk. And if they have eggs, get a dozen.” After twenty minutes she returns and flops 12 bags of milk on the table. He looks at her curiously, “Honey, why did you do that?” She responds flatly, “ They had eggs .”

What did COBOL yell to the escaping thief?

Certainly Old But Often Limber.

Can’t Obsolesce Because Of Legacy. And why would you want to?

We know better. The reality is:

A common disrespect of COBOL joke is that the acronym stands for:

And, just because;

A less verbose, more concise version; very unCOBOL that

Rumour has it that the object oriented specification for COBOL was code named

A determined coder can write COBOL programs in any language.

A computer without COBOL and Fortran is like a piece of chocolate cake without ketchup or mustard.

GnuCOBOL has quite a few tools to assist with testing and debugging programs. There are statement tracers to allow capturing the steps taken and in what order. There are low level debuggers, such as gdb that can be used for very detailed analysis of what is happening during a program run. There are profiling tools to help find where performance bottle necks are occurring. And a host of other automated and manual techniques that come into play during the verification and validation of COBOL programs.

Aside from syntax errors, logic errors are much more insidious. The compiler will dutifully compile programs that won’t do the correct thing. This is where the human mind wins out over computers. Adding numbers together at speed is a computer strength. Knowing what numbers to add together is the human advantage. Informing a computer of what numbers to add together when (and how) is the job of the computer programmer. Along with support from others to ensure that the calculations are done properly and are of practical use is the domain of software development.

Typos happen. The compiler will tell you about them. It is very rare to have programs work on the very first compile. Get used to that as a normal part of software development. And as a reminder to always test things, even after what seem like insignificant changes. Typos happen.

Unfortunately, some syntax errors lead to an out of synch compile pass, and a whole raft of unrelated error messages may ensue. Start at the first one, fix it, and then recompile. Keep repeating the Edit -> Compile -> Edit -> Compile cycle until all syntax errors are corrected.

Syntax errors are common when developing programs. A misspelt word, a missed punctuation character, or some critical ordering mix up. The cobc compiler will tell you the line numbers where trouble brews, along with an explanatory error message.

More typing. Create inline-perform.cob . Then compile and run with:

*> return to the to the operating system

Below are some examples of inline perform loops.

This type of PERFORM was introduced with COBOL-85. COBOL-85 has had quite the run, and is still a de facto standard COBOL for many installations and production shops. It was extended with intrinsic functions in 1989 with corrections published in 1993. COBOL has been officially superseded by COBOL-2002 and COBOL-2014 standard specifications, but there is still a lot of COBOL-85 source code being maintained. The NIST test suite is based on COBOL-85 with the extensions from 1993.

You can try it, if you’d like, but be prepared to press Ctrl-C to abort the run, because this code will just spin forever. counter tries to be incremented from 9 to 10, then the rules of COBOL (and pic 9 ) truncates the value to 0 and the perform loop never gets a chance to finish. Looping from 0 to 9 over and over again due to the limited storage size (and no size error testing).

*> this program will need operator intervention

*> this add could have an ON SIZE ERROR clause

*> return to the to the operating system, never happens

*> show the result, which will never happen

*> loop will never terminate, counter limited to max of nine.

Here is a fairly hard to spot infinite loop:

The counter variable is defined as pic 9 . That means the range of legal values that can be stored in the identifier is 0 through 9. 10 would be a size error condition. Testing for greater than or equal to 10 would never work. The value in counter is limited to a maximum value of 9 . If a maintainer was told to increase the loop condition, the counter variable definition would also need to be changed. Increasing a condition test will always imply revisiting the definition of the variable and making additional adjustments if necessary.

See if you can spot one of the glaring maintenance problems with this code? It has to do with the definition of counter .

More typing as part of learning COBOL the hard way. Then compile and run with:

*> return to the to the operating system

This is the type of PERFORM that was in COBOL-60

Functional programming purists probably cringe at the thought of programming via side effect, but it has suited business programming for over 50 years now and banks still seem to keep all our account balances properly tallied.

First an out-of-line procedure PERFORM . Named paragraphs and sections are called procedures in COBOL. Sadly they do not accept arguments, nor can they return results. Most COBOL programming comes down to side effect by changing globally accessible variables. Not completely terrible, all things considered, but it is a cause of more verbosity in COBOL, and a reason to show care and attention when developing larger programs.

COBOL includes two types of PERFORM loop. Inline and out-of-line. Inline is the modern, out-of-line is an older procedure branch and return form and is still very prevalent in COBOL programs.

For now let’s focus on the forms of loops provided by COBOL syntax.

A common idiom in COBOL is a “prime the pump” loop form. Do an initial action that sets the condition and other initial data values. Start the loop body, and then end the loop body with the action that sets the condition. This seems redundant, but it is actually a fairly robust and reliable way of programming loops. You have to duplicate an action, but it often means there are less fencing issues and off by one errors inside the loop body proper. This becomes equivalent to:

All the usual forms of loop are possible, but the syntax is not quite as straight forward as some programmers may be accustomed to. For example, a counted loop form is available:

The qualifier clause WITH TEST AFTER creates an equivalent of the do loop-block until condition form.

The default for those in WITH TEST BEFORE which ends up being equivalent to a while NOT condition do loop-block sort of backwards form.

Seeing as that listing probably makes some people angry about teaching the GO verb, no more will be said about it. Ok, one thing. Use GO TO with care and understanding, don’t just be jumping around a program because it seems easier at the time.

More typing, this time into a file called goloop.cob .

Strict structured programming practitioners treat GO TO as anathema, to be avoided, so let’s start with one of those.

Let’s take a look at another form of control flow. The loop. COBOL has a more restrictive take on looping than some other programming languages. All loops are either self managed by labels and GO TO statements, or through the PERFORM verb.

COBOL includes a few other ways of branching; computed GO TO, ALTER, and DECLARATIVES. These will be covered later.

The evaluate verb can compress a lot of conditional testing into a very small table like structure. Multiple statements are allowed within each WHEN block.

Not only that, but range testing is allowed.

That is conceptually equivalent to

Using a fragment from the example above:

A nice feature of WHEN is that the subject field does not need to be mentioned. Each test assumes the field name before the conditional expression.

So, go ahead and type in evaluating.cob . Then run it with:

EVALUATE is a very powerful selective evaluation statement, even when compared to most modern programming languages. The multiple condition testing allows for very concise multi-branch logic tables. Perfect for the business domain with complex conditions within conditions logic layering.

"This is also true, but the first one wins"

"This is the when block that executes"

*> inside a when conditional, the subject need not be mentioned

A third form of branching is the selective evaluation mechanism. A complete set of options is listed and tested, and the program will execute the first set that tests true. In COBOL this uses the EVALUATE verb in tandem with a practically unlimited number of WHEN clauses.

Many languages use a keyword of goto , the COBOL verb is actually GO , with an optional TO reserved word. In GnuCOBOL GOTO is a syntax error, use GO label or GO TO label .

As stated, some purists eschew this idiom, but in practice, using GO can often avoid artificial conditional branching blocks, which can become quite messy when nested in complex code sequences. As a GnuCOBOL programmer, you are free to choose the style you prefer. In some cases you are free to choose the style as dictated by the project manager (or risk expulsion by velociraptor).

More practical use of GO TO is the common idiom of jumping to the bottom of a long sequence of code. If conditions are met so that further processing is no longer required, just GO TO bottom-of-routine-label .

Not saying much more about that example, other than it should be short lived. It might help during isolation testing. Probably best to not let your peers see code like that unless they are helping you debug a problem.

*> return to the caller, in this case the operating system

*> the next named paragraph to be recognized.

*> knows that this part of the program is terminated and to allow

*> the following full stop is required so that GnuCOBOL

"Why am I even here?"

display "Why am I even here?"

*> this is dead code, never executed

GnuCOBOL includes a cobc feature to help find fragments of dead code.

To compile and run the job, type cobc -xj going.cob as demonstrated below:

The sample simply starts at the top, jumps to the bottom and exits. Don’t write programs like this. Except during development phases where you are experimenting and need to jump over a bunch of code that is unrelated to the task at hand, knowing full well that the GO TO will be removed as soon as possible.

*> return to the caller, in this case the operating system

*> the next named paragraph to be recognized.

*> knows that this part of the program is terminated and to allow

*> the following full stop is required so that GnuCOBOL

"Why am I even here?"

*> this is dead code, never executed

More typing, this time into a file called going.cob .

The next sample is not that brilliant. It simply jumps around for the sake of demonstration.

Common structured elements such as break , continue and/or next in other programming languages, are all actually a form of go branching`, without being named go to . Most of these keywords imply “go to the bottom”, “go to the top”, or “get out” of this code block.

Some languages include go to branching, some do not. Many programmers eschew the go to , but there are times when it is a very efficient way of handling control flow. Errors or early exit conditions from a complex function is one common use case. The C language allows goto , Java does not support this type of branching, even though goto has been listed as a reserved word since the very first Oak specifications (pre Java name).

GO TO has been supported in COBOL since times before structured programming became the status quo. ALGOL had structured programming back in those early days, but other contemporaries of the era, like early FORTRAN compilers, did not. There are very few programming languages in current use that do not support structured programming. Assembly may be the only one in the main stream, and even some assemblers allow structured techniques on the way to machine code. Early BASIC programming was also squarely (and famously) in the not structured camp.

And now for a much maligned form of flow control. Uncontrolled jumping around.

That sample introduces labels, or named paragraphs, to the COBOL repertoire. A user defined identifier used as a named label (requires a full stop as part of the name definition, and that full stop has implications on the normal sequential top down processing rules inherent in COBOL). More on that later.

To run it, type cobc -xj performing.cob as in this captured example:

That program will start at the top, then branch to a subroutine (formally a procedure ) and then return to the line following the PERFORM to continue sequential line by line execution.

*> then we return to the caller, in this case the operating system

*> and carries on with the next line

*> then branches to a procedure, then returns back

Time to fire up the editor again, and create a file called performing.cob .

COBOL includes various forms of a PERFORM statement. A looping form, discussed soon, and a simple branch to and come back here form, discussed here.

The controlled form is via PERFORM . The less controlled form is via GO TO . There is also CALL , but we’ll get to that very powerful verb a little later.

Along with conditional do-this or do-that branching, flow of control change in COBOL can also be caused by jumping around. And there are two forms of jumping around. A controlled, visit there and come back here, and the less controlled, go there, with no real come back here part.

And by the way, the whole 42 thing is from The Hitchhiker’s Guide to the Galaxy , by Douglas Adams. A very worthy “trilogy” of six science fiction books. Along with 42 the books also emphasize a motto of “Don’t panic”.

The THEN reserved word is optional, and some COBOL programmers find it wasteful to include in source code. I find THEN to be reassuring and it reads well.

That program sample is compiled during generation of this document (every time). There is no absolute guarantee that I didn’t break something and that the universe is still ok. In all likelihood, the expectation matches the actual. I work on the compiler, and sometimes mistakes are made on the local install. Those mistakes are always short lived, but may influence the generation of some releases of this tutorial.

If all is right with the universe then that program just output:

This time around one of the display statements will execute depending on the conditional test. Same compile command model as before: cobc -xj , as captured below.

"There is something wrong with the universe: "

"The ultimate answer is still "

Now finally to the second form of conditional, IF true THEN do-this ELSE do-that .

Have I ever mentioned that COBOL includes an overwhelming number of details, best left out of an introductory tutorial?

It also satisfies a requirement of being friendly to the markup processor used to produce this document, which uses indentation based highlighting and paragraph detection logic, but that has nothing to do with COBOL really.

Also note the *>GCOB marker is ignored by the compiler. Fixed format source (which all programs start out in by default) skips over the first 6 columns of every line in a program. It is one of the reasons I like FIXED form, it allows for small notes in the margins. In this case a trick is used, and the marker is actually a valid comment, so that source will work in either mode.

That listing, includes all the preamble text that is part of the downloadable copies of these tutorial entries, to show the directive.

"There is something wrong with the universe: "

As a pleasantry, all sources will now include that line, or a similar directive to explicitly state that the assumed source mode is FIXED.

As a protective measure, GnuCOBOL includes an in source directive that can be used to alleviate remembering to pass -free to cobc every time. Due to the default way that cobc starts, the initial directive must occur at the very top of the file, and it must start in column 8 or greater.

cobc will complain loudly if that last example is compiled assuming fixed format.

All further samples will be written to allow either -free or -fixed compile modes. -fixed is the default, -free is more modern.

But now cobc has to be told to compile in a free format friendly manner.

"There is something wrong with the universe: "

And a note on the promise of FORMAT FREE versus FORMAT FIXED. The author of this tutorial actually prefers FIXED format COBOL, but from now on, the source listings are crafted to allow both modes of compile. That code could also be formatted as:

Same output as before, but using source code slightly less suitable for non programmers. COBOL is flexible enough to allow both, and the context should determine who a program is written for. Some managers, developers and customers will prefer the full long form, others may prefer the shorter symbolic form.

"There is something wrong with the universe: "

The same level of verbosity was used for the IF statement. Full words for IS GREATER THAN , OR EQUAL TO and LESS THAN . GnuCOBOL will allow for more symbolic forms as well.

COBOL was designed to help business people solve business problems and it is deemed polite, and beneficial, to at least attempt to allow business managers, that may not be programmers, to reason through some of the calculations performed, when programs are running to manage their business.

just-if.cob also introduces another feature of COBOL. Full English statements for math calculations and conditionals. It is a design feature of COBOL. Some programmers find it far too verbose to have to type MULTIPLY ; but non programmers have a much higher chance of knowing what is going on when reading the words instead of some computer glyph symbol (like the asterisk, which means multiply in many programming languages, and in COBOL COMPUTE statements).

The second test in just-if.cob will not display any message unless there is something seriously wrong with the computer, or the universe in general. We know that 6 times 7 is less than 100. You will rarely see such blatantly predictable false code except in test suites that are verifying a compiler or other unit testing frameworks.

Skipping ahead a little. The full stop period is also a way of terminating a sequence of code in a conditional block, but that use can lead to subtle, hard to spot errors. A full stop will terminate ALL nested IF conditionals, and that can sometimes be the wrong thing to do. The recommendation is to use the scope terminator reserved words when you need to delimit blocks of code. These are much easier to spot than small dots in the source code.

That program introduces the IF statement. The first IF is the one we expect to ring true, 6 times 7 being less than 100. There is also the END-IF statements. These tell the compiler where to end a conditional branch fragment.

"There is something wrong with the universe: "

More typing, save this file as just-if.cob :

The IF statement. If something is true, do this, otherwise skip it. And a more complete, if something is true, do this, otherwise do that.

Along with sequential processing, computers also do conditional and iterative processing. IF statements and loops .

That heady sounding expression is just another way of stating that programs run in a predictable order. Also termed control flow . Unless told otherwise, GnuCOBOL programs execute from the top of the source code down, each line executed in sequence. The first line executes, then the second, then the third, as so on. This sequential processing is built into COBOL, and you don’t have to tell the compiler anything special to have that happen. It is a natural state of most programming. Execute statements, in the order given in a source listing, until told otherwise.

I’m in the habit of placing the two characters such that the asterisk is still in column 7, but that is an old habit, and -free compilation will free you from that historical burden (which isn’t a burden, but it still looks old, and who wants to look old).

To avoid that complication from now on we will use a new cobc compiler switch, -free , which puts the compiler into a more modern free format mode. Because there is no longer a special indicator column, comments will use a more modern syntax of two characters, *> . The two character form of comments can be placed anywhere on the line, and all text afterwards will be ignored by the compiler until the next line starts.

In the listing below, the line of numbers is just a ruler line to help count the columns. It has a an asterisk in column 7, and COBOL will treat the whole thing as a comment line..

Source lines are divided up in parts. Columns 1-6 hold a sequence number, any characters allowed, ignored by the compiler, and historically used to help humans keep track of the order of source lines. (When a deck of punch cards was dropped on the floor, chaos ensued getting the cards back in the proper order). Column 7 is an indicator column, and an asterisk in column 7 informs the compiler to ignore the entire line as a comment line, only meant for human readers. Column 8 through 72 holds the actual compiler instructions.

A short side trip into source formats. GnuCOBOL supports two forms of program text. SOURCE FORMAT IS FIXED and SOURCE FORMAT IS FREE . For historical reasons, the default compile mode is FORMAT FIXED .

Of other note is that the identifier answer is a two digit numeric field, defined with PIC 99 . That field would be incapable of properly storing or displaying any number less than zero or greater than ninety-nine. And again, don’t worry, we’ll see ways of allowing for much larger (and negative) values, shortly. For the impatient, you’ll have to wait, as the PICTURE clause includes an overwhelming number of details that require a lot of explanation.

Don’t worry, we’ll learn an easy way to avoid displaying the trailing spaces soon enough. For the impatient, there is an intrinsic function, called TRIM.

For a demonstration, the program is run again with the output passed through the tr utility; all spaces translated to dots so you can see them.

Of note is that the identifier program-message is a fixed length 64 character variable, defined as PIC X(64). COBOL will fill in any remaining character positions with spaces during a MOVE to that field. And the DISPLAY verb actually prints all 64 characters each time.

Same answer. Which is good. Computers would be much less useful if results were not consistent. COBOL programmers need to write programs that have consistent results, as this keeps everyone’s bank balance from indiscriminately changing.

Your working directory will now also have a new executable program file, simple-data , ready for more runs without needing to compile the source.

If there are no errors, then you are now rewarded with the answer to the ultimate question about the meaning of life, the universe, and everything.

This time, we will use a feature of cobc that compiles the program and then runs it, all in one step. The -j switch is a mnemonic for job. Along with -x it means, compile this code to executable and then run the job for me.

While you type in these examples you are building up your own personal collection of code templates that can be used later to quick start a project.

See Do you have a reasonable source code skeleton for GnuCOBOL? for a handy example of this. But keep in mind that you need to practice walking before running ahead to the hop, skip and jump phase.

On typing. COBOL programmers are famous for type it once, then copy and change it. There is actually quite a bit of paperwork in the average COBOL program.

Once again, a COBOL programmer cannot be afraid of typing, it is part and parcel of the job, so it is recommended that you struggle to type that in. Spacing counts. COBOL harkens back to a day before modern computer screens, and source text was entered on physical punch cards. Those days are long behind us, but the format used in this example (called FORMAT FIXED) needs to be properly spaced. Soon, we’ll use an updated feature of COBOL so that we won’t have to worry about the indentation as much, but for this example, the format is FIXED, code lines start in column 8, and the asterisks that start a comment have to be in column 7.

Fire up the text editor, in your tutorial working directory, and type that code into a file called simple-data.cob . Or, click the download link and save the file to your working directory.

For this example, quoted character literals are moved into a message area for display. The messages could have simply been literals used with the DISPLAY verb, but for this example the messages are moved into a variable first, and displayed from there.

MOVE is a work horse data movement verb. It does more than simply move data from place to place, it also has rules about the form of the data movement, taking into account both the source and the destination data types. More on that soon.

COMPUTE is a verb that tells the compiler to evaluate an arithmetic expression and put the result in a variable.

This next program also introduces more COBOL verbs, MOVE and COMPUTE .

Our next program is going to manage some data. It includes a DATA DIVISION . Inside the DATA DIVISION is the omnipresent WORKING-STORAGE SECTION . The WORKING-STORAGE SECTION is a mainstay of COBOL data storage. It implies that somewhere in the computer’s memory banks there is space reserved for the data. During any particular run it will remain fixed in place, ready for retrieval and/or manipulation, the working store.

The initial 01 on those lines in a field grouping level number. More on that topic soon. For now, the CUSTOMER-NAME and ITEMS-PURCHASED identifiers are known as “elementary items”, not grouped or split into sub-fields. For the impatient: level number 77 is reserved for defining elementary items, but top level 01 level numbers are used here.

You can’t do math with a customer name, and you can’t stick non-digit characters in the numeric count of items purchased.

An X is a place holder for any character and here we set aside memory for 40 characters. A 9 is a placeholder for any digit, 0-9 inclusive (6 digits worth in this example, which could also be written as PIC 9(6) .

Most other programming languages cater to the computer chip point of view of numeric values. COBOL is rare in this design feature, using decimal arithmetic by default. (As does REXX and very few others).

Numbers in this case are not for the benefit of the computer, they are defined for the benefit of the human reader. As it turns out, computers have a different natural view of numeric values than us humans. Computer don’t have ten fingers to count on, they only have on/off. We all grow up using a base 10 (decimal) assumption about what numbers mean, and COBOL is designed with that fact in mind. Computers inherently have a base 2 (binary) assumption. The designers of COBOL decided that compiler writers should do all the nitty-gritty hard work of converting numbers from human form to machine form, and let business people think and reason about problems using dollars and cents in a human natural decimal format.

A PICTURE , shortened to PIC , is a human readable view of computer data. And there are two main types, character and number.

COBOL is designed to help business people solve business problems. Data definitions in COBOL are designed for people to easily reason about the problem at hand. Definitions are rigid, and explicitly sized by PICTURE .

Back to the attention box at the start of the tutorial; in order to avoid overwhelming a beginner, there are many details left out in these initial exercises. The details will be touched on later. In particular, COBOL is very well suited for defining very complex record structures, but that has to wait.

COBOL has a very rigid and technically detailed view of data. Unlike many programming languages, COBOL has a separate division for describing data layouts. Data definitions are not intermingled with code as they are in many other programming environments. This feature is a blessing. It forces a minimum level of discipline when programming. You need to think about, and plan, a COBOL program.

Almost all useful programs need to keep track of and manipulate data. Data forms the variable part of the code/data programming duality.

A small piece of advice is to use the minimum number of full stops to satisfy the rules of COBOL syntax. No more, no less. For now, just know that the period character is an important symbol in COBOL. It terminates a unit of text to let the compiler know when and how to compile source code. Before you know it, it will all make sense and you’ll be a master of the COBOL full stop.

You need to worry about full stops in COBOL, and later on we’ll see how they can effect the interpretation of the instructions in the PROCEDURE DIVISION in weird and wonderful ways.

That code won’t compile, and cobc will complain again:

*> This program will NOT compile, missing a full stop after

Don’t bother typing this one in either, it has different bugs in it.

Let’s see what happens if we forget a period in one of the critical spots. This version of hello.cob is missing the full stop after the IDENTIFICATION DIVISION phrase.

A side trip, an important one. The period, . , also known as full stop, is an important character in COBOL. It terminates labels, sentences, paragraphs, sections, and a few other critical pieces of COBOL syntax.

Do yourself the favour and just repeat:

That code won’t compile, and cobc will complain:

You can skip typing that one in, it has bugs in it.

*> This program will NOT compile properly, divisions out of order

Let’s see what happens if the hello.cob source code is out of order:

Entire DIVISIONS can be excluded (rarely), but when included, they must be in the proper order.

IDENTIFICATION, ENVIRONMENT, DATA, PROCEDURE. GnuCOBOL will complain (COBOL will complain) if you try and put the PROCEDURE DIVISION before the DATA DIVISION, or mix up the order in any way. A handy mnemonic when starting out:

The order of the divisions is important. They must be entered in the same order as the list above.

In the hello.cob example, we only needed two DIVISION entries. IDENTIFICATION and PROCEDURE. That is a very rare case for COBOL programming. Anything that does useful work will have a DATA DIVISION. Anything that touches on external resources (usually data files on disk) will include the ENVIRONMENT DIVISION.

Each DIVISION is broken down into SECTIONS, PARAGRAPHS and SENTENCES. Sentences are broken down into STATEMENTS. Statements are made up of RESERVED WORDS, literals and variable identifiers. Paragraphs and sections have labels. Each of these fragments are terminated by a full stop period, much like in English.

For the time being, forget that you saw that short-cut version of Hello. To learn COBOL you need to understand the paperwork phrases. They are important. Think of it as learning how to walk before starting to run. We all want to hop, skip and jump, but first we need to practise walking (after putting in some time crawling, which is hard on the knees, but we all start out that way).

As promised above, there will be other examples of Hello, world programs that look totally different in the pages ahead. COBOL is a comprehensive and feature rich programming language

The outcome is the same, but the path getting there is a little different, and this time cobc emitted some warnings about some assumptions being made.

Even though that looks much simpler, it is actually fairly advanced COBOL. You need to know the first version for this one liner version to really make any sense. To compile the short version, we need to tell the compiler to relax some of the normal COBOL syntax rules.

Skipping ahead a little: GnuCOBOL is actually quite a sophisticated COBOL compiler, and it can make assumptions about some of the paperwork instructions. All of that typing can be condensed down to a simple

With GnuCOBOL being quite flexible, this program could be written in a wide variety of ways, all with the same outcome. We will see different forms of programs that produce equivalent outcomes later on in the tutorial.

That ends the initial quick tour of a Hello, world program in GnuCOBOL.

The last line is end program hello. (terminated with a period). This is optional with this particular program, and is another housekeeping phrase. The identifying program name has to match the program-id . It tells the compiler that this program unit is complete. Later we will see that this is important (and becomes mandatory) when a source file contains more than one program unit and when nesting sub-programs.

That one sentence contains two statements, DISPLAY literal and GOBACK .

The next statement is GOBACK . This keyword tells the compiler to generate code to return to the caller. Seeing as this is a main program, that means the return goes all the way back to the operating system shell. A status code is implicitly set by default, in this case a success code of 0. You rarely have to worry about COBOL setting a proper status code. It is a built in convenience feature. The GOBACK is terminated with a full stop period, the end of the one (and only) executable sentence in this program.

COBOL does not get its reputation for being verbose from lack of trying. As you continue learning COBOL you will find that all these housekeeping instructions are actually a good thing. It keeps code organized and also enforces a minimum level of discipline when developing programs. These factors become much more important once programs grow larger than simple introductory examples.

Then we finally get to the first actual executable instruction on line 19. A DISPLAY statement, which is followed by a quoted literal message "Hello, world" . There could be a period following this statement, but it isn’t mandatory. Sequential lists of statements form a COBOL “sentence”, and this example program is a single sentence, with two statements. All the previous lines of source code are paperwork statements (and comments). This is the first line of code that actually does something when we run the program.

Then we get to the PROCEDURE DIVISION (and full stop) on line 18. This is another trigger phrase to tell the COBOL compiler that executable code follows. A little more paperwork.

The next line is the PROGRAM-ID. statement, followed by a user defined program name. Both end with full stop periods. The name must follow a few technical rules, both to satisfy COBOL naming conventions and to satisfy operating system linkage rules. The operating system has to know how to find the program name when linking with other code, and COBOL can’t let you put things like periods or commas in the name. The literal hello is fine for both the language and most operating system naming restrictions. This is a form of COBOL “paperwork” that effects the operating environment.

I sometimes refer to these types of COBOL instructions as “paperwork” or “housekeeping”. These statements do not actually do anything in terms of run time effect, but they do influence how the compiler sets things up and organizes the technical details.

Next up is the first actual instruction to the compiler, line 15, the IDENTIFICATION DIVISION statement (which ends with a full stop period). This lets the COBOL lexical parser know that a new program definitions is starting. Mandatory with every program or nested sub-program. (That’s not entirely true, but true enough for an introductory tutorial).

The comment indicator used for GnuCOBOL is *> , and this tells the compiler to ignore the rest of the text, up to the end of the line.

Hopefully all your programs come with this minimal level of preamble. Even if you never share a program, it is nice to be able to just glance at a header to see how to properly build and run a program. This is as simple as it gets, programs only get more complicated from here.

The first 14 lines are comment lines, they introduce the purpose of the program, show some dates, the usage rights and include some hints on how to build from source and how to run the program. I call that last part the tectonics .

Let’s go over hello.cob one more time. This time, from a full listing that is available in the downloadable copy.

A short note about Windows. On Windows, without a reasonable console, what will happen is that invoking the program will start a console, display the message and then immediately close the console. All you may see is a flicker. More recent versions of GnuCOBOL now include a default exit handler that will pause the console shutdown, giving you a chance to see the output. Versions of GnuCOBOL older than 2.0-rc3 will not have this feature.

If it didn’t work, then you have Gary’s Programmer’s Guide and this document to help you with trouble shooting. There is also an awesome forum on SourceForge, ready and willing to answer any questions you may have regarding Help getting started at https://sourceforge.net/p/open-cobol/discussion/help/ .

It might seem trivial, but the validation means that a lot of things in the background are properly working. A lot. Really, a huge number of things have to be properly setup for that simple message to be displayed on screen.

The purpose of Hello, world programs is to verify that the system is installed to a minimum functioning level. The message on the screen tells the operator that the compiler worked, and the run time system can at least do basic output.

And there is your introductory COBOL program with GnuCOBOL.

Yes, hello to the world, GnuCOBOL is working.

That command will start the new hello program. Using that command syntax, the system will not bother searching through the command path to find hello. hello is the program to run. The initial ./ part is a short form directory specification meaning from here, in the current directory. So, dot-slash hello, ./hello , means run hello , from here in the current terminal workspace.

If there are no syntax errors then you should now have another file in your working directory, called hello . It will have modes and permissions already set for you to to be allowed to run the program.

Note the silence in the example compile. If nothing goes wrong, cobc is usually quiet, and just does as asked. In this case, generating an executable program.

The -x switch is what tells cobc to create the executable file. cobc can generate other forms of output, but we want a runnable program at the moment.

This starts the compiler and asks cobc to generate an executable program.

This is where cobc comes in. cobc is the GnuCOBOL compiler front end command. It does a lot of nifty things, but for now we will focus on compiling and then running this simple program.

Once you have the Hello source code sample in a file called hello.cob , the real fun begins.

One note about spacing. COBOL uses two formats for source code. Old, FIXED format, harkening back to the days before interactive terminals. And new, FREE format. Old fashioned FORMAT FIXED is the default for the GnuCOBOL compiler, (because it is the default source format in all COBOL Standards so far, 1960 through COBOL 2014). The hello.cob example is in that form. The first six columns are a special sequence number field, ignored by the compiler. Column 7 is a special indicator column. Compilable code starts in column 8. For this exercise, make sure the asterisks are in column 7 for the first three lines and the other lines start in column 8.

Side trip on source code formats: Don’t fret these details, gloss over this next bit if you just want to get on with trying the compiler.

There is a handy download link for that source code if you are browsing this on the web, but as a COBOL developer, you need to get used to typing. So learn some COBOL the hard way and start typing. I use vim , but you will want to use a text editor you are comfortable with. Text editing is tool of the trade that you need to be comfortable using, and there are literally hundreds of choices.

Fire up your favourite editor and type the following into a file called hello.cob . (That filename is the name that will be used throughout the rest of this tutorial, so if you pick a different name this time, you are on your own to remember what it is, and to change each of the commands to suit).

We will start with Hello. Of the four main COBOL divisions, this introductory sample only includes IDENTIFICATION and PROCEDURE. There are a few comment lines, some COBOL “paperwork” phrases and only two executable statements. We’ll compile and run the program as part of the exercise.

You can use that name, gcfaq/tutorial , if you like, but it is much better to pick your own easy to remember favourite. No one will be able to remind you, as it is a personal choice, so pick one you like and that you will be able to remember a few months from now if you ever need to come back for a refresher.

Go ahead and create the directory, and/or change into it. For example:

A subdirectory in my login home, called lang/cobol . You are free to choose your own working directory. All you need to remember is that you need to remember where it is, so when you come back to the computer after a break you’ll be able to find your work.

For this tutorial, you will need a working directory to store source code, executables and data files. I use:

COBOL is a big programming language. There are thousands of details. This tutorial will gloss over many issues in order to try and focus on one or two key points without overwhelming the reader. What may be stated as “fact” is likely less than half the story. You will eventually learn enough COBOL to know where details were omitted during this introduction.

Getting started with GnuCOBOL. This section assumes a GNU/Linux install, but much of the COBOL material is platform agnostic. Command examples will be shown using bash inside a terminal console.

Although subject to change and correction, the sources used are listed here under bubble-cobol.tcl .

Extra font control was added, and in the GnuCOBOL FAQ version of the syntax diagrams, a non-bold font is used to denote GnuCOBOL extensions that are not part of the COBOL 2014 specification. Or at least, attempts were made to do so. GnuCOBOL does not claim any level of conformance to standard, and the syntax diagrams in this document are not indicative of COBOL syntax as defined by ISO and/or ANSI .

Sourced from the SQLite repository, and discovered at http://wiki.tcl.tk/21708 . In this author’s opinion, true to Richard’s other works, these scripts produce beautiful diagrams. Tcl/Tk is used to produce Postscript outputs, which are then further processed by ImageMagick to produce the final .gif and .png images.

Dr. Richard Hipp created a small set of Tcl/Tk scripts to assist in drawing syntax diagrams for SQLite. These public domain scripts were modified slightly to create the syntax diagrams used in the GnuCOBOL FAQ, as bubble-cobol.tcl and bubble-cobol-data.tcl . In keeping with the spirit set by Dr. Hipp, the syntax diagrams in this document are also dedicated to the public domain.

Or, where did the GnuCOBOL syntax diagrams come from?

The good folk that host this FAQ, also host http://oldsite.add1tocobol.com and http://add1tocobol.com

GnuCOBOL is hosted on SourceForge at http://sourceforge.net/projects/open-cobol/

Last updated: June 11th, 2013. If you know of a worthy entry, drop me a note.

Although open source COBOL is still rare, and free even rarer, that is slowly changing. This entry will be a perpetually growing list, until the universe is at peace.

Thanks to Ray, Paul, and Daniel on LinkedIn.

I like the last one. ccpcn, pronounce that as kick-pickin’.

I came up with Publicus Negotiatio Cursus Lingua, and then smarter people suggested:

which is about 8 megabytes of text. Sadly this archive does not include all the metadata (author, and timestamps) that were included with the forum entries, but is still a treasure trove of GnuCOBOL related technical wisdoms.

opencobol.org was redirected to the SourceForge site in October of 2015 . There is an archive of the forum posts, and knowledge base, stashed away at

In case anyone is wondering, as of May 2014, 1 (one) entry has shown up in the spam folder and required moderation. Thanks, SourceForge; frees up many hours of volunteer time. Many. There was spam in the reviews, well, hit count hounds, and even those seem to be dealt with, quietly in the background. Nice.

The active site is now hosted by SourceForge, at

Due to robot spam, new registrations on opencobol.org were disabled in 2012.

Initial indentation counts. Code starting with column 8 followed by a comment in column 7 can confuse the indentation detection. That can be fixed by adding a sequence number tag in columns 1 through 6 to the first line of code in the listing.

This is a context free regular expression colourizer. It gets true COBOL wrong, but mostly right, for the benefit of colour.

"ok, what now?"

This is now included on SourceForge. In the discussion groups, source code can be highlighted using SourceForge markup. A blank line, a line starting with six tildes, another line starting with two colons, followed by a language tag. Many, available, but for fixed form COBOL use cobol, for less indented, free form COBOL, use cobolfree. Then code, then six closing tildes.

As of January 2013, the COBOL lexer is in mainline Pygments. No more mucking about required. Georg Brandl did a wonderful job of refactoring the COBOL highlighter into his Pygments system. Many thanks to Georg, Tim and team Pocoo.

I wrote a Pygments lexer, mushed it into a local copy of Pygments and then call a rst2html-pygments.py program. Requires a fair amount of mucking about. See ReStructuredText and Pygments for some details.

Along with Gary’s OCic.cbl http://opencobol.add1tocobol.com/doxyapp/ to demonstrate how easy it is to generate world class, audit friendly source code documentation, drilled right down to how the COBOL run-time is interacting with the operating system.

Dimitri van Heesch’s 1.7.4 release of Doxygen, http://www.doxygen.org was used to produce http://opencobol.add1tocobol.com/doxy/ .

This is mentioned elsewhere, but the GnuCOBOL compiler source code bundle works beautifully with Doxygen. Mix application and compiler sources for overwhelmingly complete call graphs.

Downloads of versions beyond 4.99.42 of ROBODoc will be COBOL friendly when passed the --cobol command line option. ROBODoc is in the Fedora package repos and work is in progress to have this package re-included in Debian repositories.

Frans accepted changes to the main ROBODoc source tree, hosted at https://github.com/gumpu/ROBODoc to be more friendly with COBOL sourcecode, dashes in names being the biggest change.

The ROBODoc homepage is at http://rfsber.home.xs4all.nl/Robo/robodoc.html .

A ROBODoc experimental project to document the source codes is hosted at ocrobo . See ROBODoc Support for a sample configuration file.

on Debian GNU/Linux will retrieve the most recent released package sources.

Most distributions of GNU/Linux will also have source code bundles. For example

The SourceForge Files section has links to older release and pre-release archives.

Absolutely. Being a free software system, all sources that are used to build the compiler are available and free.

While GnuCOBOL can be held to a high standard of quality and robustness, the authors do not claim it to be a “Standard Conforming” implementation of COBOL.

In May 2014, the new specification for COBOL 2014 was Published by ISO/IEC. The document was approved in early summer, and adopted by ANSI in October, 2014.

This is highly subject to change, but a Draft of COBOL 2014 is/was available at http://www.cobolstandard.info/j4/index.htm and in particular http://www.cobolstandard.info/j4/files/std.zip

The COBOL 85 standard is documented in

The mailing lists were transferred to Savannah in December 2016, replacing the long standing SourceForge list archived at

A private mailing list is managed for developers, and anyone that signs up as a contributor will be provided with access to the (low volume) dev list. Everyone is allowed to view, subscribe and post to the other lists.

Once you have subscribed, the list will accept messages at gnucobol-users@gnu.org

Subscribe to the users list at

An archive of the users list is available for browsing at

There are lists for bugs, messages, users and dev.

The GnuCOBOL project mailing lists are graciously hosted on savannah.gnu.org.

And please note that these translations are only the compiler and libcob run-time messages, not COBOL syntax or reserved word spellings in source code. COBOL is, by specification, an English programming language.

To try Spanish messaging, see Setting Locale , basically export LC_MESSAGES=es_ES before calling the compiler.

Activity will take place on http://translationproject.org

The GnuCOBOL translation effort will be included in an official translation project. Thanks to the many volunteers there. From Simon:

OK, here is the http://www.filedropper.com/open-cobol]pot-file from 11-09-06.

Current assignments of translations: fr: eraso (finished [updates will be needed later]) [earlier: Bear (maybe aouizerate, too)] hi: Yanni de: erstazi es: jcurrey (finished [updates will be needed later]) ja: minemaz (later) it: ?federico?

If you’re not sure if one of the translations is correct mark it as fuzzy with [ALT]+[U] or via edit menu.

Use [ALT]+[C] often. It copies the original string to the translation field where you can change what’s needed. This function can be found in edit menu, too.

Always keep special characters like %s, %d, n, … The % are place holders (values will be inserted there by OpenCOBOL). n is a line break, t a tab, etc

Translate the text in the lower pane.

Choose the string you want to translate in the upper pane.

Save file with chosen language abbreviation like it is placed in http://www.iana.org/assignments/language-subtag-registry

Insert project name: “open-cobol 2.0” and the rest as needed

For a new translation create a new catalogue from the pot file. I encourage everybody to use a GUI for that. Some explanations how to do that with my favourite language file editor [url=http://www.poedit.net/]Poedit[/url] and some general instructions:

From the last discussions I remember people wanting to do this for French, Italian, Spanish, German but I don’t remember who exactly said that he/she will help. We already have a Japanese translation, but that needs an heavy update.

Before posting every stuff here I want to gather the translators here. Who is able and willing to translate the strings (currently 724) into what language(s) [or has somebody who does this]?

We’re starting to translate upcoming versions into different languages. The necessary code changes for OC 2.0 were already done. Now we need translators.

From Simon, some many moons ago, when he went by the nickname human.

A new project has started to see native language support in the cobc compiler and run-time systems. Skip ahead a little to see the links for the new efforts. What follows in historical information, just for completeness.

And a big one, which will require signatures for reassignment, internationalization and translations.

Other contributions include cheerleading, bug reports, discussions, notice of free COBOL that works with the compiler, or should, but needs porting, etc.

DOH! 2008 through 2015. I don’t really want to count how many hours have been spent typing END-DISPLAY into code examples. As of Oct 2015, there will be less of those.

It has been pointed out that a few of these scope terminators aren’t just more typing, they also clutter long understood source code constructs when there are no conditional imperatives such as ON EXCEPTION.

Full disclosure: I’ve been writing samples for this FAQ that usually compile warning free with -W by adding scope terminators with END-DISPLAY, END-ACCEPT, END-COMPUTE etc. I thought approved samples followed the MUST rule.

The rule for project approved samples can be seen as:

That’s GNU, and contributions to the GnuCOBOL source tree. Contributions outside that tree are also welcome, as long they count as free software.

There is more commentary on the need for the inconvenience and a lot more in the GNU Coding Standards, , but again, the “project” is more than the compiler project.

The GNU recommendations can be found at http://www.gnu.org/prep/standards/standards.html which includes

GnuCOBOL is also a COBOL project. Not all contributions are part of the legally copyrighted GnuCOBOL sources, owned by the Free Software Foundation, Inc. Be that code, documentation, or other media. Contributions can be made under other forms and licensing, and they are addressed separately. No blocks will be put in place of anyone wanting to help, aside from the overriding concerns that pay homage to the principles of free software.

Officially, GnuCOBOL is a GNU project, so we will abide by the rules and recommendations provided by this very successful free software foundation. Write access to the sources is restricted to those that have signed legal copyright transfer documents, noted below.

First to clarify a little bit. The GnuCOBOL “project” has two parts. The official GnuCOBOL compiler source tree, and external free software contributions, currently held in a source tree named contrib . Ok three parts; from the point of view of the “project”, we will gladly reference free software, commentary, and other free resources related to GnuCOBOL and COBOL by simple request or notice from authors. The keyword is free, freedom free. In term of the “project”, free COBOL is the main theme. Terminology wise, the “project” encompasses more than the GnuCOBOL project, a name normally associated with the official source tree, but being only a small part of the big picture.

Absolutely. Visit the SourceForge project space and either post a message asking what needs to be done, or perhaps join the development mailing list to find out the current state of development. See Is there a GnuCOBOL mailing list? for some details. GnuCOBOL is an official GNU, GPL licensed, free software project, with a small team that handles the read/write permissions on SourceForge. The project is very open to code submissions. Having this central point of development allows for the consistency and the very high level of quality control enjoyed by GnuCOBOL users.

Is still available, at OpenCOBOL Programmers Guide .

A very well written and masterful OpenCOBOL reference and COBOL development guide. By Gary Cutler, GnuCOBOL Programmers Guide .

add1tocobol.com is a place to find out about a few of the fan initiatives. (An older website is readonly at http://oldsite.add1tocobol.com )

The discussions on the opencobol.org website permanently redirected to SourceForge, have been archived at http://open-cobol.sourceforge.net/files/opencobol.org-archive.tar.gz (2Mb) and as plain text at http://open-cobol.sourceforge.net/files/opencobol.org-archive.txt (8Mb).

Use the site to see how well disciplined COBOL should look and then hopefully carry that over to your own works.

Most listings in the COBOL Connection will compile with GnuCOBOL unaltered, but please abide by the usage terms. Most pages on the site include allowances for personal review and evaluation and count as fair use in that context (at least by Canadian standards), but anything beyond that would require reaching an agreement with SimoTime.

Highly recommended. A few of the listings are freely available, but most require a licensing agreement with SimoTime Technologies. Take care to read through the licensing terms for each page before copying any sources.

The SimoTime COBOL Connection includes a wide range of practical COBOL programming examples, along with full descriptions of why certain things are done the way they are done. http://simotime.com/indexcbl.htm

SimoTime Technologies has a very comprehensive website that acts as both a COBOL learning centre, and as a template for complete, robust, well disciplined COBOL programming.

Some of the most well written, professional, publicly available COBOL sources can be viewed (not always copied) at http://simotime.com .

Robert will be trying to ensure the continuity of the site, and modernizing it along the way, at http://newcobug.com . He has even gone as far as adding a subdomain, (which we have not yet taken full advantage of), for GnuCOBOL related COBOL issues. http://gnucobol.newcobug.com . Robert, being involved with a large internet service provider in Brazil, is well versed in all things internet, and newcobug.com has a very good chance of becoming the new cobug.com.

cobug.com was for many years, a go to place for all things COBOL related, in particular a vendor agnostic, but still commercially oriented set of COBOL pages.

After the passing of Thomas Perry in 2014, cobug.com went off the air. It is archived in the Wayback Machine, and those pages became the starting point for Robert Skolnick’s new newcobug.com site.

They also include instructions for setting up Hercules, a System/370 emulator, and include IBM MVS samples, including JCL listings to launch UCOB compiles. The Hercules samples are “at home only” and have not been linked to the web form Try It buttons. Any COBOL tried online will be passed through a GnuCOBOL compiler, and will, by necessity, only work with sources supported by GnuCOBOL (or more accurately, OpenCOBOL pre-release 1.1).

The COBOL course includes source listings with a Try It button, OpenCOBOL used in the background to run compiles and display results to the web forms. (Once GnuCOBOL 2.0 makes its way into the main free software distribution repositories, they will very likely upgrade to the latest builds)

As you can tell, I disagree with not pointing out the tutorialspoint tutorial, but you will likely be much better off starting with Micheal Coughlan’s CSIS tutorials, listed above.

Before reading any further, note this critique, from Bill Woodger (July, 2015):

There is an online learning centre, tutorialspoint.com Simply Easy Learning, and they have posted courseware for COBOL, JCL, and many other topics.

See REPORT for a very complete sample and introduction to using the ReportWriter features that are available in the reportwriter branch of the GnuCOBOL source tree.

You’ll find sample programs for parsing CSV, displaying the number of days between dates, and lots more.

Jay has also added a GnuCOBOL page to his large mix of information pages.

See Hercules for more details.

Jay Moseley has written up quite a few COBOL related tutorials, and has added a lot to the world of the Hercules System/390 emulator. He dug in and wrote up bootstrapping instructions for old MVS releases so people can experiment with versions of big iron operating systems on home computers. Including getting a public domain copy of a 1972 version of IBM ANS COBOL up and running.

There is a scrolling transcript that keeps pace with the dialogue, and these are professional grade videos.

Peggy touches on mainframe issues when discussing some COBOL issues, so this is a fairly solid start for anyone interested in COBOL programming.

Recommended for anyone wanted to get setup with GnuCOBOL on Windows, and a recommended share to anyone looking to get into COBOL programming in general.

Well spoken, well paced. About 50 videos, taking a little over 3 hours start to finish.

Hosted by Peggy Fisher, and Lynda.com, there is a very well done set of video tutorials available for getting Up and Running with COBOL. Peggy runs through setting up GnuCOBOL with Windows and Notepad++, and then follows up with

http://www.csis.ul.ie/cobol/course/Default.htm for most of the courseware links, but don’t miss out on the other pages linked on the “All Things COBOL” main page. These pages are over a decade old, and like all things COBOL, still very relevant at that young of an age.

http://www.csis.ul.ie/cobol/ for all the links, and

One of the preeminent COBOL learning resources on the internet, are the tutorials, example programs, COBOL programming exercises, lecture and other notes written for the Department of Computer Science and Information Systems of the University of Limerick, by Michael Coughlan.

For COBOL code samples, (aside from the listings included in this document, and with a much wider range of authoring style), the Rosetta Code website is a very good reference. See Rosetta Code for more information on this comprehensive programming language resource.

While GnuCOBOL can be held to a high standard of quality and robustness, the authors do not claim it to be a “Standard Conforming” implementation of COBOL.

Work on the next COBOL 202x Standard started in late 2017.

along with a copy at open-std.org at

An archive of a pre-vote draft for the COBOL 2014 spec is stashed at COBOL-2014

As a side note, when the original specification was being written, one of the committee members, Howard Bromberg commissioned a tomestone, in 1960. Ignore the trend setter tones and look to the reality. http://www.computerhistory.org/fellowawards/hall/bios/Grace,Hopper/

Work on the next COBOL 202x Standard started in 2018.

A new spec for COBOL 2014 was Published in May 2014 by Donald Nelson of ISO/IEC with adoption by ANSI in October 2014. Not dead, or dying or any such thing. With free COBOL, in GnuCOBOL, it’s still dancing.

Please ignore the “COBOL is dead” tone that many of these articles may be permeated with. COBOL isn’t dead, but it is usually used in domains that require the highest level of secrecy, so the billions of lines of production COBOL in use around the globe, rarely, if ever, get mentioned in internet chatter. Hopefully by reading through this document, and keeping an open eye on reality versus trends, you will see the importance that COBOL has held, does hold, and will hold in the computing and programming arena.

A google of the search words “COBOL” or “GnuCOBOL” or “OpenCOBOL” are bound to lead to enough days worth of reading of in-depth articles, opinions and technical information to satisfy the greatest of curiosities.

A copy of Bill’s works were placed on SourceForge, with his permission:

The COBOL FAQ by William M Klein is a great place to start.

Full disclosure: This author is a involved in the corporation, and we maintain a contact and project management space at http://occside.peoplecards.ca/

Although we’d rather that free COBOL is also fiscally free; anyone needing commercially backed technical support or development assistance can contact Open COBOL by the C Side. OCCSide Corporation.

What more could a volunteer team ask for?

See What is COBJAPI? for some details on this very powerful sub-system.

Another quote from Oscar on SourceForge

With László Erdős’s COBJAPI contribution, an entirely new way of programming COBOL has appeared. Rod Gobby was impressed enough to take on the task of porting his company software inventory to this new system.

From Vincent Coen, also author of the CobXRef utility used by cobc -Xref .

I hope people don’t mind a little advertising in this FAQ, but Jim has done a lot for GnuCOBOL, and his company is a community minded company. http://curreyadkins.com/custom-programming-linux-php-apache-open-source/

Another reference by Jim, some 6 months later in February 2010, which seems to be enough time for any rose-coloured glass effect to have worn off if it was going to.

Another post from opencobol.org in April 2009, reprinted with permission.

Reported on opencobol.org , The Nagasaki Prefecture, population 1.44 million and 30,000 civil employees is using GnuCOBOL in support of its payroll management system. A team of 3 ported and maintain a suite of 200 COBOL programs, mingled with Perl and specialized reporting modules, running on Nec PX9000 big iron and Xeon servers.

If GnuCOBOL is going to break, it’s going to break right in front of you, during compiles. If something is not fully supported, GnuCOBOL fails very early on in the trial process. With most COBOL 85 and many nifty COBOL 2014 features, if cobc doesn’t complain during compiles, then GnuCOBOL is a very trustworthy and robust COBOL. If you work with newer features, beyond 1989 intrinsics, there may be more reason to keep an eye on things. It would be due diligent to run comprehensive tests before committing to mandatory regulatory reporting systems or other life and core critical deployments. Be prepared to scan emitted C source codes. Know that GnuCOBOL is a free software system. Critical issues can be, are being, and will be addressed. No permission is required to try and make GnuCOBOL a better, more reliable system, and there is a host of very smart people willing to pitch a hand forwarding that goal.

See the chapter on GnuCOBOL in production for a growing list of details regarding GnuCOBOL in production environments.

And yes, GnuCOBOL is used in production environments.

The licensing allows for commercial use, but GnuCOBOL also ships with notice of indemnity, meaning that there are no guarantees when using GnuCOBOL, directly or indirectly.

Depends. GnuCOBOL is still in active development. Feature coverage is growing, and while the current implementation offers great coverage, applicability to any given situation would need to be analyzed, and risks evaluated, before commitment to production use.

There are other IDEs that support COBOL. Google may respond with a list that suits taste.

Geany is a light weight GTK based development environment and has surprisingly pleasant COBOL support. http://www.geany.org/

It is best to visit the LaunchPad cobcide parent pages for the latest source code, GNU/Linux packages and Windows installers at

From Robert W. Mills, author of cobolmac , (See Does GnuCOBOL support source code macros? )

Nice system. People like it. There have been over 12,000 downloads of the Windows installer. Which turns out to be a very quick and easy way to get up and running with GnuCOBOL in a Windows environment.

By Colin Duquesnoy. He just released version 4.7.6 (December 2016), and it now includes a MinGW binary build that Arnold Trembley helped put together for developers running Microsoft Windows. (see What is the current version of GnuCOBOL? )

There is a GnuCOBOL specific IDE getting good press, posted in PyPi at https://pypi.python.org/pypi/OpenCobolIDE

See Does GnuCOBOL work with make? for some information on command line compile assistance.

See Is there a good text editor for GnuCOBOL development? for some alternatives to using an Interactive Development Environment.

Many text editors have systems in place for invoking compilers. SciTE, Crimson Editor, Vim and emacs, to name but a few of the dozens of programmer text editors that support edit/compile/test development cycles. See Kate for some notes and details on the GnuCOBOL development potentials in the KDE Advanced Text Editor.

There is also the Eclipse IDE and a major project for integrating COBOL but this will not be GnuCOBOL specific.

See Can the GNAT Programming Studio be used with GnuCOBOL? for more information. Update: this effort is likely abondoned . See OpenCOBOLIDE, below, for the current leading, and project approved, GnuCOBOL IDE.

The add1tocobol team was working to create extensions for the GNAT Programming Studio. This was working out quite nicely, but more effort would be required to make this a viable alternative for GnuCOBOL developers.

Yes. (And no, there is no IDE that ships with the product but there is a contributor interactive development environment, written explicitly for GnuCOBOL). There are also other IDEs that support COBOL.

See Can GnuCOBOL interface with Agar? for details.

The Agar (libagar) toolkit can also be put to good use with GnuCOBOL. A project has started to bind libagar features in GnuCOBOL user defined functions. Along with a GUI there is also cross-platform support for things like datasources, networking, and system access tools.

See Can GnuCOBOL interface with XForms? for details.

One step up from X11, XForms is a framework for building graphical user interfaces on systems that support X11.

Another very powerful option for graphics programming is available with the COBJAPI user defined function repository. See What is COBJAPI? for more information.

There are also a few examples of using X11 directly from GnuCOBOL. See Can GnuCOBOL interface with X11? for details.

See cobweb-periodic listing for the source code that produced that image. Please note that with recent changes to GTK+ theming, as of 3.16, the buttons are no longer properly coloured. New code needs to be written to provide CSS property management for GTK+ button colours.

Without recompiling, the events and graphics are handled by the browser.

Here is a GTK based interactive periodic table of the elements, written in GNU Cobol (6 lines of C support code), linked to GTK+ 3.0, and running with

More on this in A GTK+ calendar

GDK 3 supports a backend called Broadway. Transform GTK desktop applications to websockets and HTML5 web guis. Here is a GnuCOBOL sample, written to explore the desktop GTK calendar widget, redirected to a browser using GDK Broadway, with clicks in the browser window invoking GnuCOBOL graphical event callback handlers, no change to the desktop application source code.

Vala will also open up a quick path to GUI development with GnuCOBOL. There is already an embedded web browser using the Vala bindings to WebKit. See Can GnuCOBOL interface with Vala? for a lot more details.

to your Tk script. Where . represents a Tk window (in this case, the top level window).

That easy. cobc will take care of the Tcl integration. To allow the Tcl/Tk event loop to play nice with GnuCOBOL, add

That option to ./configure when building cobc will provide a built in Tcl interpreter that is Tk ready.

And there is an optional build sequence being built for Tcl as an Intrinsic Function.

Another wrapper for Tcl/Tk is being developed for GnuCOBOL 2 that leverages User Defined Functions, and exposes an event loop to COBOL programmers.

The Tcl/Tk engine by Rildo Pragana is already quite complete but does place most of the burden of GUI development squarely on the Tk side.

See GTK-server for a sample and download links. GTK-server can support GTK 1, GTK+ 2 and GTK+ 3 library installs and developers can customize which functions are available (along with sophisticated macros) in a simple and elegant configuration file.

Peter van Eerten, author of BaCon , also develops an interpretive scripting interface to GTK. Commands are passed to the GLib/GTK libraries as text lines. A very COBOL friendly way of programming a Graphical User Interface. No external code is required, just READ and WRITE statements.

with the shell vte, being a fully functional terminal widget.

This procedure division: (part the of the library self-test)

An experimental FUNCTION-ID wrapper is working out well

The expectation is that GTK+ will be completely bound as a callable interface. That is currently (March 2018) not the case, with perhaps 2% of the GTK+ functionality wrapped (but with that 2%, fully functional graphical interfaces are possible).

Third party extensions for Tcl/Tk and linkage to GTK+ and other frameworks do allow for graphical user interfaces. See Does GnuCOBOL support the GIMP ToolKit, GTK+? and Can GnuCOBOL interface with Tcl/Tk? .

Yes, but not out of the box. There is not currently (March 2018) anything that ships with the product.

For those developers looking to serve GnuCOBOL applications on hosted systems without super user privileges, see How do I use LD_RUN_PATH with GnuCOBOL? for some pointers on getting hosted executables installed properly. LD_RUN_PATH can make it easier for CGI programs to find a locally installed libcob runtime, something a hosted service may not provide.

to get proper linkage with libfcgi.

Some platforms (ala Cygwin) may need

*> Always send out the Content-type before any other IO

*> carriage-return is x"0d" and newline is x"0a"

The CGI processing code then needs to add a simple looping structure internally.

# Sample make rule for using FastCGI with GnuCOBOL

FastCGI can also work with GnuCOBOL. A small wrinkle in the tectonics is that the standard IO C header file that is generated by cobc needs to be swapped out for fcgi_stdio.h . This isn’t too bad, as cobc can be used to generate intermediate C and after a quick text replacement, can then be called a second time to compile the generated C code into an executable suitable for placing in the web server space.

And it all just works

More specially, this screenshot was taken on a Fedora 19, XFCE desktop with a libvirt VM install of Ubuntu 13.04, running Firefox and browsing a locally spawned cloud instance. The instantiation of the Juju Charm creates another virtual machine, installs a base operating system, compiles and installs GnuCOBOL with Report Writer, builds up a small testsuite of CGI ready COBOL applications, installs everything, starts apache and serves up the pages.

Here’s a screenshot of GnuCOBOL running in Apache server CGI, in the Cloud as a Juju Charm.

Also see Can GnuCOBOL display the process environment space?

Yes. Through standard IO redirection and the extended ACCEPT ... FROM ENVIRONMENT ... feature, GnuCOBOL is more than capable of supporting advanced Common Gateway Interface programming. See How do I use GnuCOBOL for CGI? for a sample Hello Web program.

I’ll opine; Bill’s and Roger’s COBOL is a LOT easier to read than the other entries, being C, C#, Java. (The Turbo Pascal link seems broken, can’t speak to the readability), but I’m calling COBOL for the win on this one, wire to wire.

Data files and other code listings are copyright Mike Cowlishaw and IBM, so go to the speleotrove site, linked above, for all the details.

*> By William Klein, used with permission

With Bill’s permission, the benchmark code is listed here: (with the first few lines added for the benefit of an indent based code highlighter)

2 seconds for the short test, 12 for the long, on a fairly small machine.

A run on an older pentium 4 and the million number file gave:

In summary, the benchmark reads a large input file containing a suitably distributed list of telephone call durations (each in seconds). For each call, a charging rate is chosen and the price calculated and rounded to hundredths. One or two taxes are applied (depending on the type of call) and the total cost is converted to a character string and written to an output file. Running totals of the total cost and taxes are kept; these are displayed at the end of the benchmark for verification.

Update: There is a version tuned for GnuCOBOL, especially the ROUNDED NEAREST-EVEN support. It gives correct results for what would be common default GnuCOBOL settings and compiler configurations, and Banker’s Rounding. Listed below.

to point to the correct filename for your local copy of the benchmark million entry file and a suitable OutFile name for a clean compile and run.

There is a benchmark posted at http://speleotrove.com/decimal/telco.html and thanks to Bill Klein [wmklein] , there is a COBOL entry. From the source code listed below, you should only have to modify

GnuCOBOL, by default, generates code optimized for big-endian hardware. Fairly dramatic speed improvements on Intel architecture can come from simple USAGE IS COMPUTATIONAL-5 clauses in the DATA DIVISION.

COBOL has a legacy dating back to 1959. Many features of the COBOL standard provide defaults more suitable to mainframe architecture than the personal computer a 3rd millennium GnuCOBOL developer will likely be using.

and limits tests within the:

GnuCOBOL-reportwriter does not include support for:

This is up from the 1.1 Feb 2009 release count of 9082.

The summary.log from a run in November 2013 with initial Report Writer support:

With the addition of GLOBAL support, the GnuCOBOL-reportwriter pre-release fails none of the attempted tests.

It got easier too, just type make checkall during a source build to automatically download, extract and run the NIST test suite.

Basically, it is a simple uncompress and make then sit back and relax. The scripts run GnuCOBOL over some 424 programs/modules and includes thousands of different, purposely complicated stress test passes.

Instructions for use of the NIST suite is included in the build archive under:

While the system successfully compiles over 400 modules, failing none of the over 9700 tests attempted; GnuCOBOL does not claim conformance to any level of COBOL Standard.

GnuCOBOL passes many of the tests included in the NIST sponsored COBOL 85 test suite.

This used to be at: http://www.itl.nist.gov/div897/ctg/cobol_form.htm and redistribution comes with conditions; this is for official purposes of testing a COBOL compiler build. It is not for general redistribution.

The National Institute of Standards and Technology, NIST, maintained, and now archives a COBOL 85 implementation verification suite of tests. A compressed archive of the tests, last updated in 1993, to include Intrinsic Functions, A copy of the archive has been placed in

Mostly. Not all. All attempted tests are passed. Over 9000.

85 seconds down to 25 seconds, when tested in parallel.

and without TESTSUITEFLAGS (some may be pre-cached etc…)

will run tests in parallel, pick a number appropriate to the number of cores.

It supports a few options, one in particular:

will evaluate and report on the test suite. See make check listing for a current output listing of a test run.

3.0-rc1 in 2018 is approaching a total of 1,000 make check checks.

2.0-rc3 in early 2017 includes 34 general usage, 203 syntax, 21 listing, 409 coverage, and 26 data representation tests for a total of 693 test areas during build.

88 syntax, 253 coverage, and 22 data tests in a 2010 cut. 456 tests in the 2014 sources, and growing. (501 tests in early 2015).

Why yes it does. 74 syntax tests, 170 coverage tests, and 16 data representation tests in the February 2009 pre-release.

See the THANKS file in the source code archive for more names of people that have worked on the OpenCOBOL, now GnuCOBOL, project. Roger points out that the list is woefully incomplete. To quote:

Many people. In particular Keisuke Nishida , Roger While , Simon Sobisch , Ron Norman , and Sergey Kashyrin .

GnuCOBOL is poised to change that historic trend, and allow for the long overdue sharing of wisdom that legions of COBOL developers have accumulated over 50 years of success and failure. The GnuCOBOL conversation may be more POSIX than mainframe, but there is now room to share, critique and pass on the hard lessons learned from critical systems computing. Given that millions of COBOL programmers kept billions of lines of COBOL source out of the press, surely some of the wisdom can be passed on in a way that keeps all the secrets secret while curious developers are exposed to COBOL outside the vaults.

COBOL has historically been very secretive and low key. Its domain of use being very secretive and low key. COBOL programmers rarely work on systems that would allow for open internet chat regarding details, let alone existence. It is a tribute to the professionalism of these programmers that most people rarely, if ever, hear the name COBOL, a programming language with billions of lines of source code compiled and in production around the world over half a century.

This author believes so. For a free implementation of COBOL, GnuCOBOL may surprise you in the depth and breadth of its COBOL feature support, usability and robustness.

While GnuCOBOL can be held to a high standard of quality and robustness, the authors do not claim it to be a “Standard Conforming” implementation of COBOL.

Allowing for substitution of mixed length strings, something not normally so easy in COBOL. The above will output:

"This is the orginal string."

Passing the equivalent of char**, pointer to pointer to char. Just as a small example of the level of coverage and flexibility provided by GnuCOBOL.

GnuCOBOL implements most COBOL technical features, allowing source code such as

GnuCOBOL 3.0 adds Report Writer and a host of features that have been developed in the reportwriter branch along with even more support for COBOL 2014 and existent COBOL extensions.

GnuCOBOL 2.0 implements a more substantial portion of the COBOL 85 Dialect, COBOL 2002 and a growing number of vendor extensions. Support COBOL 2014 features is in active development.

OpenCOBOL 1.0 implements a substantial portion of COBOL 85 , supports many of the advances and clarifications of COBOL 2002 , and includes many extensions in common use from Micro Focus COBOL, ACUCOBOL and other existent compilers.

Rename the .7z to .exe, and click for an easy install. Open a console, run set_env.cmd in the extract directory, then freely create, compile, and run your COBOL programs.

Those builds include Indexed IO, full decimal math support, screens, Report Writer, more. From the soon to be GnuCOBOL 3.1-dev release. G-BDB is built with Berkeley DB, and includes GNU Debugger symbols. VBI is VB-ISAM instead of BDB, without debug symbols in the compiler. Visit the site for the latest, and more configuration choices.

Scroll down to GnuCOBOL Compiler install binaries and choose from a few configurations. Recommend

The best option at this time is hosted at https://www.arnoldtrembley.com/GnuCOBOL.htm

There are archives for lots of different cuts of GnuCOBOL for Windows along with a plethora of other tools and utilities, with nuggets of wisdom and how-to information sprinkled throughout.

Mario Matos is building up a pile of files of GnuCOBOL related archives, in the cloud at

Keep an eye on http://sourceforge.net/projects/open-cobol/files/gnu-cobol/2.0/ for the latest snapshots.

New upload of http://sourceforge.net/projects/open-cobol/files/gnu-cobol/2.0/gnu-cobol-2.0_nightly_r411_win32_vc11_bin.7z - works correctly now

Paraphrased from some posts by Simon on the forge:

This build is now also included in Colin’s OpenCOBOLIDE .

As the name implies, this complete compiler build includes Berkeley DB for ISAM, PDCurses for extended screen IO, and MPIR for the decimal arithmetic and other multiprecision math features of GnuCOBOL.

An official GnuCOBOL project MinGW build, put together by Simon Sobisch, is stored on SourceForge, at

Arnold put together an INNO installer, based on Gary Cutler’s MinGW builds of OpenCOBOL 1.1. Makes it pretty easy to get COBOL running on a PC. You can find it attached to SourceForge discussions, or at Arnold’s site:

for the latest. Usually in synch with Arnold’s releases, but there is usually a few days between Arnold posting a new build and the links being updated.

Then take a look through

This is the link you want to follow first

Arnold Trembley has been supporting the project with installers for a long time now. His latest is bundled with the OCIDE distribution, or see

In particular, http://sourceforge.net/projects/cobol/files/open-cobol/ can come in handy, with sources and MinGW binaries at a minimum. Maybe more as time goes on.

There are GnuCOBOL links at http://cobol.sourceforge.net

Also check out kiska.net for binary builds on various platforms. Thanks to Sergey Kashyrin, who is also the author of the version that emits C++ intermediates.

The official project releases are in source form and will be posted to ftp.gnu.org.

Please note that none of these packages are project affiliated, but come to you out of the goodness of the hearts of the volunteers involved.

There is a page with just about all details of official packaging at

GnuCOBOL packages are slowly being introduced, and will likely see a revision from open-cobol-1.1 to GnuCOBOL 3.0 and gnucobol, after some release announcements and posting to GNU servers.

Fedora and RedHat yum repositories usually have open-cobol as a choice for

More recently the official repos will have package gnucobol and it is usually version 2.2.

Thanks to the gracious efforts of Bart Martens, bartm on Debian’s .org domain.

A Debian Advanced Package Tool binary package exists for GnuCOBOL 1.1 as open-cobol and lists dependencies of

Debian APT , and RPM packages exist. Packages for NetBSD. Many. Google opencobol packages for older builds, and gnu cobol for any late breaking news.

Rename the .7z to .exe, and click for an easy install. Open a console, run set_env.cmd in the extract directory, then freely create, compile, and run your COBOL programs.

Those builds include Indexed IO, full decimal math support, screens, Report Writer, more. From the soon to be GnuCOBOL 3.1-dev release. G-BDB is built with Berkeley DB, and includes GNU Debugger symbols. VBI is VB-ISAM instead of BDB, without debug symbols in the compiler. Visit the site for the latest, and more configuration choices.

Scroll down to GnuCOBOL Compiler install binaries and choose from a few configurations. Recommend

The best option at this time is hosted at https://www.arnoldtrembley.com/GnuCOBOL.htm

GnuCOBOL 3.0 , is in pre-release but may show up in some official distributions.

GnuCOBOL 2.2 , is now making into official repositories. As an example, Ubuntu 18.04, sudo apt install gnucobol is release 2.2.

others, Raspberry Pi (quote was $35 for hardware, OS and GnuCOBOL)

GnuCOBOL 1.1 , the previous official release version has been built on

While GnuCOBOL can be held to a high standard of quality and robustness, the authors do not claim it to be a “Standard Conforming” implementation of COBOL.

GnuCOBOL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

What this licensing means, roughly, is:

All source codes were copyright by the respective authors. With many thanks to Roger While and Keisuke Nishida for sharing their work with the world.

The run-time library is licensed under GNU Lesser General Public License .

The compiler is licensed under the GNU General Public License .

A stable, business oriented language, that helps people meet the common objectives; across all the computing platforms, around the globe. That is not an official acronym or anything, just a suggestion.

Later… and even better, perhaps:

A discussion group posting on LinkedIn tweaked this again, Common Object Business Oriented Language. I like it. And with GnuCOBOL C++, perhaps Sergey can lead the charge/change.

As an aside: I’d like to steal the O in COmmon, and haven’t found a suitable word as of yet. Common Originally Business Oriented Language, was tried, trying to connote “it’s been extended”, but it sounds diminishing, like GnuCOBOL can’t do Business anymore. Which isn’t the case. So, the quest continues.

COBOL is an acronym for COmmon Business Oriented Language. This author has always thought of it as “Common Business” Oriented more than Common “Business Oriented”, but that emphasis is perhaps up to the reader’s point of view.

Ignore the tricky formatting, that was all for looks on a particular forum that only allows 52 characters on a line before scrolling. GnuCOBOL normally looks far more professional than the odd snippet of fun you may read in this document.

In this author’s opinion, GnuCOBOL is a world class COBOL compiler, very capable with almost all of the COBOL 85 specifications, plus having some very internet ready, next generation potentials.

The original OpenCOBOL Programmer's Guide can be found at OpenCOBOL Programmers Guide .

A valuable reference, the GnuCOBOL Programmer's Guide can be found at GnuCOBOL Programmers Guide .

The official page for GnuCOBOL is:

GnuCOBOL was OpenCOBOL. OpenCOBOL started around 2002, and on September 26th, 2013, GnuCOBOL was accepted and dubbed a GNU package by Dr. Richard Stallman. One day before the 30th anniversary of the GNU announcement.

GnuCOBOL translates COBOL into C and compiles the translated code using the configured C compiler, usually gcc. You can build your COBOL programs on various platforms, including Unix/Linux, Mac OS X, Microsoft Windows, OS/400, z/OS 390 mainframes, among others..

GnuCOBOL implements a substantial part of the COBOL 85 , COBOL 2002 , and COBOL 2014 standards, as well as many extensions of the existent COBOL compilers.

Regarding COBOL Standards, Official COBOL Standards: There are many references to standards in this document. Very few of them are technically correct references. Apologies to all the hard working men and women of the technical committees for this unintentional slight. For specific details on what wordings should be used please see What are the Official COBOL Standards?

Many thanks to the original designers, supporting organizations, and individuals of the day.

The COBOL standard acknowledgment, with respect and gratitude.

Below is a copy of the long standing acknowledgment request that appears in all versions of the CODASYL COBOL Journal of Development and most ANSI/ISO COBOL standards.

You should have received a copy of the GNU General Public License along with this document. If not, see < http://www.gnu.org/licenses/ >.

This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

This documentation is free; you can redistribute and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This file is part of the GnuCOBOL FAQ.

(with the invaluable assistance of many others)

Comments, corrections, and suggestions regarding this document can be posted to GnuCOBOL FAQ feedback hosted in the GnuCOBOL project space.

Banner courtesy of KolourPaint, Copyright 2015 Brian Tiffin. Licensed under CC-BY-SA 2.0. Includes Sire, the Draft Horse, and the GNU Head by Aurelioi A. Heckert. http://www.gnu.org/graphics/heckert_gnu.html https://commons.wikimedia.org/wiki/Category:Old_English_Black http://creativecommons.org/licenses/by-sa/2.0/

Website favicon by Mark James, help.png from the FAMFAMFAM Silk icon set. http://creativecommons.org/licenses/by/2.5/

This FAQ is more than a FAQ and less than a FAQ. Someday that will change and this document will be split into a GnuCOBOL manual, a cookbook, and a simplified Frequently Asked Questions file. The mythical, Someday.

GnuCOBOL 2.2 is the release version. GnuCOBOL 3.1 with Report Writer, and C++ versions are available for testing. OpenCOBOL became GNU Cobol on September 27th, 2013, officially dubbed a GNU project. The spelling of GNU Cobol changed to GnuCOBOL on September 20th, 2014. Copyrights were assigned to the Free Software Foundation on June 17th, 2014.

This is a 3.0 work in progress release of the GnuCOBOL FAQ. Sourced at gcfaq.rst . Courtesty of ReStructuredText , Sphinx , Pandoc , and Pygments . PDF format available at GnuCOBOLFAQ.pdf .

The future of COBOL is what we will make of it. High costs no longer needs to be the primary area of modernization discussions surrounding heritage COBOL systems. They can be, for those that feel the need to spend; and there will be vendors willing to sign you up, for decades to come. Or, for those willing, GnuCOBOL will be waiting to ease some of the financial burdens, and open up the future to the opportunities that await.

Need a network module? CALL it, or use cobc to link object code directly into a master program. Need a slicker user interface, use cobweb-gtk or cobweb-tk and offer up modern screens. CALL a few other modules and have a browser ready interface. Need the flexibility of some advanced data structure or multiprocessing system? Link it in. Need the Cloud? Put an instance of GnuCOBOL on your Cloud. Need a DevOps strategy, well, build that layer around heritage and let your GnuCOBOL developers talk with your GnuCOBOL operations teams. Need to interoperate with some monster third party system? Dig in, knowing full well that it’ll work at the common layer of the C application binary interface.

COBOL 2014 has some very nice features. Not all the features a modern development team may want or need, networking and user interface come to mind again, but a very solid core for problem solving. GnuCOBOL being a trans-compiler heavily rooted in C (or C++, thanks to Sergey), bridges the business computing model enshrined in COBOL, with the computer sciences enshrined in just about all the other programming development systems in use today. There are C implementations of nearly all mainstream programming languages. Java is actually based on a C implementation, as is Python, Perl, Ruby, PHP, to name but a few. There are C implementations of Ada, Fortran, BASIC, Lisp, Prolog, Javascript, a very long list. COBOL is a first class citizen in all of these environments with GnuCOBOL. GnuCOBOL bridges the gap between Business and Science, and can take on either role, fully, or in a mixed paradigm.

Reality is likely somewhere in the middle. And part of the opinion, this author leans to staying with COBOL unless there are some serious reasons not to. User interface, interoperability and networking portions of hertitage applications come to mind. With GnuCOBOL, staying with COBOL may be a more attractive option. Source codes may need only minimal change, the money pit shrinks considerably, and at the same time interoperability potentials may increase, considerably. Keep all the heritage COBOL, extend into the future and build up, not sideways.

COBOL is still very much in use with large systems, and big iron COBOL is a big business, all on its own. Millions are spent setting up and maintaining COBOL development systems. Many millions. That can be seen as a good thing, a bad thing, or a neutral thing. Some people are deeply invested in COBOL and see change as anathema. Some people are itching to get away from what they see as a money pit, stagnant as the world progresses. Some may be suffering internal conflict, split by both those extreme views.

That is a good question. What follows is strictly opinion, and readers are encouraged to make the future and not wait for it to just happen.

While Ron still works in the reportwriter branch, GnuCOBOL 3.0+ has the Report Writer module and many of Ron’s other enhancements to the compiler included now. After many years of split, GnuCOBOL has merged in the Report Writer.

Or, read through some of the NIST test code, perhaps SM/SM101A.CBL, a program that puts COPY through its paces. Please note that newcob.val is not for redistribution . Get it from the source, and share the link, not the file.

While the test is running, take a look at REPORT .

Party, big party. Dancing, and woo hoos, like it’s 1985. Actually, the last test suite update was in 1993, shortly after Intrinsic Functions.

and for more validation, the NIST COBOL 85 test suite

and the make, test, and install

# note the .. up directory, while in build/

# to see any options you may want to tweak

Set up for an out of tree build. Not necessary, but cleaner.

GnuCOBOL has removed pre configured scripts, and now uses a bootstrap method to create the configure script.

or with wget, thanks to Simon for the snippet.

to download any new development archives. libCURL tests the modification timestamps, so this procedure is very resource efficient, only pulling from the server if there is something new. A -b option is accepted that will spawn off tar , configure and the make pass to compile a fresh copy. -b does not do an install, you’ll still have to do that manually after verifying that everything is ok.

Thanks to [aoirthoir] for hosting these; currently (March 2018) at

If you build of OpenCOBOL 1.1 or GnuCOBOL (any) and have libcurl, you will be able to compile the occurlrefresh.cbl (with occurlsym.cpy ) application and an early occurl.c libCURL wrapper that allows file transfers off the internet. occurlrefresh includes default filenames for retrieving the most recent pre-release source archive and only updates the local copy if there has been a newer upstream release.

The above instructions also apply to the GnuCOBOL 2.0 releases.

Be sure to see What are the configure options available for building GnuCOBOL? for all the available options for building from sources.

The ldconfig after make install is important, GnuCOBOL installs shared libraries, and the link loader cache needs to be informed.

will place a new set of binaries in /usr/local , ready to roll.

After a download and extract from http://sourceforge.net/projects/open-cobol/files/latest/download?source=files

Ensure things are setup in the proper prefix location with

Then install and refresh the linker cache

For more validation, the NIST COBOL 85 test suite can be used with

# note the .. up directory, while in build/

# to see any options you may want to tweak

Set up for an out of tree build. Not necessary, but cleaner.

Will build the initial ./configure script. bootstrap does some low level work to create this file.

Default configuration places the newly created binaries in /usr/local . cobc , in /usr/local/bin and other files in /usr/local/share/gnucobol .

2.3 is the trunk branch at this point. It’ll be released to fix any reported bugs in 2.2, as preparations are made for the Report Writer merge.

GnuCOBOL with Report Writer will merged into mainline tru