COBOL: (Synonymous with ‘evil’.) A weak, verbose, and flabby language used by card wallopers to do boring mindless things on dinosaur mainframes.

[from the Jargon File]

Given many C and LISP hackers’ opinions of COBOL, it’s perhaps unsurprising that it’s one of the least-mature languages on Linux. While C has a compiler (gcc) that rivals some of the best commercial implementations, I’ve had nothing but frustration so far as I’ve tried to get a working COBOL compiler running.

There are, as far as I can tell, two COBOL compilers that seem like they might be useful for basic testing and development work: TinyCobol and OpenCobol. TinyCobol compiles COBOL and produces GNU Assembly, which are translated into machine code by the GNU Assembler; OpenCobol translates COBOL to C, which is then compiled by gcc.

Not being a C programmer — meaning that one of the benefits of OpenCobol, the ability to debug your COBOL program in C, wasn’t particularly useful to me — I decided I’d give TinyCobol a shot first.

Although there are references around the ‘net to binary packages of TinyCobol, there wasn’t any evidence of one for Debian on TC’s website. Hoping — perhaps naively — that something called ‘Tiny’ wouldn’t be too much of a bear to compile myself, I grabbed the sources and dove in.

Although I didn’t have any problems in configuration, as soon as I went to run ‘make’, the errors began. The crucial one seemed to be:

 gcc -I/usr/include -I/usr/local/include -I../lib -I../ -c scan.c
 scan.c:1062: error: syntax error before 'YY_PROTO' 
 scan.l:122: error: syntax error before 'switch'

After that, things just fell apart. I played around with it for a few hours, trying and retrying, checking all the dependencies, but to no avail. I even went so far as to try it on a brand-new Dapper installation running in a VM, just to make sure something about my system wasn’t poisoning it. Nope.

So after giving up — at least for the moment — on TinyCobol, I decided to give OpenCobol a try instead. Although OpenCobol apparently has a package for Ubuntu Edgy, there’s currently no backport to Dapper, so I was left again with the unappealing alternative of building it myself.

I got the OpenCobol sources and its dependencies installed easily enough, and ran the ./configure script without problems. Looking good so far. But as soon as I typed ‘make’ and started to actually build it, I was filled with a little deja vu:

fileio.c:308: error: syntax error before 'DB'

Followed by several pages of ‘incomplete type’ errors. So much for that. A quick Google for the error didn’t reveal anything, and since I’m not a C programmer, that’s pretty much the end of the line. (There’s a reason why I normally have a blanket rule against any non-trivial software that requires compilation. The number of times I’ve tried compiling some large software package and actually had it work without deal-breaking problems is very, very small.)

I’m tempted to take this as some sort of cosmic sign; the revenge of all those scoffing C and LISP greybeards on their COBOL cousins. Linux — at least my Linux machine — just doesn’t seem to want anything to do with it.

Anyway, should anyone else out there find a way of running TinyCobol, OpenCobol, or some other COBOL compiler on Ubuntu Dapper (before it goes out of support and I’m forced to upgrade anyway), I’m all ears.

At the moment I’m torn between just giving up completely on Linux for this purpose and looking for a working COBOL implemetation for Win32, and feeling like since I’ve already put a day’s worth of work into this, I ought to keep banging on it and see if I can get either TC or OpenCobol working on Ubuntu Edgy or one of the other new versions. I think I’ll probably start downloading a new Ubuntu LiveCD while I look for Windows tools, and see which one I get working first.