Random writing on computing, baking, life. Find me on Mastodon too.

COBOL and the web

Putting apps on the web is the way the world has gone.

We know there are billions of lines of COBOL code still running today, running the world. COBOL isn’t going anywhere, even if the talent pool that knows it has dwindled.

If you think about how the vast majority of web apps work, especially the “enterprise” ones, it’s a common pattern -

We have basically reinvented the wheel several times over, in each subsequent language developed. Mainly we do this with general purpose languages, where web frameworks have been developed to accomplish this for the web.

IBM (and others) have made integrations to publish this existing COBOL code on the web, via integrating with Apache, JSON and XML libraries, SOAP, etc.

You can do quite a bit of this on your personal computer through GnuCOBOL also.

So, along those lines, I’ve been thinking of a way to write a webapp in COBOL on Linux.

Thinking through the structure that would make up a COBOL MVC web framework:

Model

Use esqlOC to do embedded SQL

View

A template engine would be slow if it were parsed in realtime. Instead, pre-process the templates into COBOL code, something like esqlOC to translate a template to a COBOL source file would be faster at runtime.

Controller

Controllers could return a view using a template as mentioned above, or return JSON using the JSON subroutines in GnuCOBOL.

Routing

Routing would use a table structure to hold the routes, but tables are a fixed size. So you would declare a large table (say, 100 entries?) and let the user change it.

Library structure

The “framework” wouldn't be a library, more like it would be source files you checked in, like a template / scaffold.

Keep the “framework” files in a separate folder, then you would update that folder to update the framework.

Running the code

Compile and bind everything into a single executable.

Use FastCGI to serve the process, via nginx or Apache.


So this is very high level right now, but I’ll post more as I put it into something workable.