19 comments

[ 3.2 ms ] story [ 48.2 ms ] thread
It's interesting to see just about every line in the code commented. Makes you re-examine the assumptions made when people say "the code should be self documenting."

Namely, that the code will be read by someone who knows the language. And arguably that the code should be capable of being "self-documenting." Although perhaps people well-versed in COBOL would argue COBOL can be, and I just don't know it.

I know this is a ‘joke’, but it sparked in me actual questions that I am sure some folks here will know the answers to:

What are the security guarantees with writing in COBOL? Like, does COBOL allow out-of-bounds memory access? How does it compare to C or Rust as far as allowing ‘accidental’ security lapses?

People say “pick the best tool for the job” and then refuse to pick COBOL for their COmmon Business Oriented probLems
I thought I could program in any language. But: that Cobol project makes Assembly language look clean and elegant.

I applaud Jms Dnns! This project really makes you think.

Love to see fixed format mode in use :)

For those who are unaware — you can use COBOL in two modes: free mode and fixed format mode.

Fixed format mode is (afaik) the original, based on punch card affordances, and specifies specific columns for specific purposes:

* The first 6 columns for line numbers

* Column 7 for the indicator character (notably: * for comments as you can see here https://github.com/jmsdnns/webbol/blob/main/file-structs.cpy )

* Column 8-11 for special division markers, though they can extend beyond (visible in this file: https://github.com/jmsdnns/webbol/blob/main/webserver.cbl)

* Columns 12-72 for ordinary COBOL statements

* Columns 73-80 for programmer comments or whatever notes you like

All the columns are undoubtedly a bit taxing to the modern developer and their tools, so 'free mode' which discards all the above is the suggested default.

But, I think fixed mode is very charming, and if you're going to write COBOL in 2025, you may as well try to get the most authentic experience!

I'd love to learn more about what `CALL "socket"` is doing. CALL is for running subprograms, but it's not clear to me where "socket" is?

I've thought about a COBOL webserver before, but didn't get beyond reading the GnuCOBOL FAQ that mentions it's possible with CGI https://gnucobol.sourceforge.io/faq/gcfaq.html#id1126

I'm definitely going to dig into this project more later. This is very neat!

IDENTIFICATION DIVISION. PROGRAM-ID. WEBSERVER.
I've always wanted to learn Cobol. So, I of course did what I sometimes do and bought the standard. Of course, it then turned out that the standard used inaccessible diagrams instead of any kind of decently modern syntax notation like EBNF, so I could at most only get scraps from the syntax parts and nothing actually useful. I wasn't entirely sure if even learning it would be worthwhile or be something I would be able to do, but I thought eh, why not give it a go?
In the late 90's I had a girlfriend who worked for a shop that made web pages in COBOL. I thought those were COBOL's death throes, but apparently I was mistaken...
Some things are COBOL aren't too bad - eg:

    MOVE SPACES TO REQUEST-BUFFER
Love this!!! Any tips for learning cobol?
My employer has been around 40 nearly 50 years. We still run COBOL for 90% of our business operations. Day-to-day employees work in bluescreens built in RM/COBOL and RM/PANELS.

As recently as the 2010s, we used to emit HTML out of COBOL, but fell short of it directly responding to HTTP requests. Instead, we licensed an RPC layer that sits behind Apache and translates HTTP calls through CGI to a listener on the COBOL side that then invokes COBOL programs. Those programs send back HTML strings through the CGIRPC interface and, well, out comes a webpage in your browser.

We're still using it to serve XML and have turned it into a makeshift web service that helps power a traditional web application.

But, honestly, this is way cooler.

COBOL used to drive some government and business web sites. You could tell because the HTML was output in 100 column fixed width format.
what are you liking about the language?
I showed my toddler parts of the original TRON not long ago, and for some reason, reading this reminds me of that lol