Of All the Programming Languages...
14 years ago
General
#!/bin/sh
printf "%s " "shouting into the void..."
( cat << HERE
printf "%s " "shouting into the void..."
( cat << HERE
This is mainly to bump the last journal entry down.
But of all the programming languages in which to seriously consider writing a Web application, I am leaning toward COBOL. Yes, the dinosaur of a programming language that everyone thinks is dead. If it was dead, we wouldn't have had the Y2K scare a decade ago.
Anyway, there are a few reasons why I'm considering it.
First, COBOL is a compiled language, and compiled programs tend to run faster than interpreted programs. Not always, mind you, but the only real way an interpreted program can outrun a compiled program is if the interpreter does just-in-time compiling with greater optimization than the non-interpreting compiler does, or if the compiler somehow does a worse job than the interpreter at optimizing code.
Regardless, Web application code doesn't change a whole lot, maybe a fraction of a percent of the time the code is run, and as long as the Web server provides a CGI-standard interface, any program whose source code is written in any language that can read an input stream and spit out formatted text works. I stumbled across OpenCOBOL, which compiles COBOL to C and then calls the native C compiler to finish the job and produce a binary, and it compiles and installs as a user program happily enough. I'm aware of the advantages interpreted languages have over compiled ones, but the language is already portable, and I just have to remember to compile after editing source code.
Second, despite COBOL's extreme wordiness, it's very easy to pick up and write nice, well-structured procedures to manipulate fairly simple and easy to understand data structures: files of records and fields. The kind of Web application I have in mind won't need anything more complicated than that for its business logic and data storage. As for user interface, user input is handled by the Web browser or some other RESTful client, and I can get as plain or fancy as I want with the display just by printing an HTML document, a Web page, as user output. Type then click, or just click.
And finally, I'm becoming too complacent in the languages I'm familiar with, and it's time to expand my horizons and give myself a challenge. The Web-oriented programming language I'm most familiar with is PHP, but I'm becoming acutely aware of its inherent flaws and shortcomings. I can choose a variety of languages besides PHP to learn and program Web applications in, and to be honest, Ruby is the most attractive, but I want to do it in COBOL just to say I did it.
Yeah, I'm weird like that.
But of all the programming languages in which to seriously consider writing a Web application, I am leaning toward COBOL. Yes, the dinosaur of a programming language that everyone thinks is dead. If it was dead, we wouldn't have had the Y2K scare a decade ago.
Anyway, there are a few reasons why I'm considering it.
First, COBOL is a compiled language, and compiled programs tend to run faster than interpreted programs. Not always, mind you, but the only real way an interpreted program can outrun a compiled program is if the interpreter does just-in-time compiling with greater optimization than the non-interpreting compiler does, or if the compiler somehow does a worse job than the interpreter at optimizing code.
Regardless, Web application code doesn't change a whole lot, maybe a fraction of a percent of the time the code is run, and as long as the Web server provides a CGI-standard interface, any program whose source code is written in any language that can read an input stream and spit out formatted text works. I stumbled across OpenCOBOL, which compiles COBOL to C and then calls the native C compiler to finish the job and produce a binary, and it compiles and installs as a user program happily enough. I'm aware of the advantages interpreted languages have over compiled ones, but the language is already portable, and I just have to remember to compile after editing source code.
Second, despite COBOL's extreme wordiness, it's very easy to pick up and write nice, well-structured procedures to manipulate fairly simple and easy to understand data structures: files of records and fields. The kind of Web application I have in mind won't need anything more complicated than that for its business logic and data storage. As for user interface, user input is handled by the Web browser or some other RESTful client, and I can get as plain or fancy as I want with the display just by printing an HTML document, a Web page, as user output. Type then click, or just click.
And finally, I'm becoming too complacent in the languages I'm familiar with, and it's time to expand my horizons and give myself a challenge. The Web-oriented programming language I'm most familiar with is PHP, but I'm becoming acutely aware of its inherent flaws and shortcomings. I can choose a variety of languages besides PHP to learn and program Web applications in, and to be honest, Ruby is the most attractive, but I want to do it in COBOL just to say I did it.
Yeah, I'm weird like that.
FA+

Someone on FA who knows what COBOL is. And who has it
dead right about it's virtues. Nota bene: you can go mad hunting for
missing periods (as the code fails to compile for the 75-millionth time).
Me, I know. Learned it in '83 on a CP/M-driven CDC microcomputer.
But for medical snafus that rendered me a pile of goo on the floor, I'd probably
still be working in it.
Keep us posted. And just for fun, where'd you find OpenCobol? Colour
me nostalgically curious.
FB.
The FAQ is at http://opencobol.add1tocobol.com/
to assist, but maybe should just stick to offering encouragement.
Been a long time.
COBOL sort of forces an orderly way of thinking on you, I found.
Led to good habits, paid off with other languages. Emphasizes a
crucial point: never mind the compiler, human beings gotta be able
to read this lot first. Style counts in COBOL. And/or you learn fast
that bad style just makes your job harder.
Have fun with it.
FB.
PS: And maybe me too. Need to code a text preprocessor, aiming
to find a way to post full-justified stories to FA. A quickie
COBOL program? Why not? Get my chops back...
is C code, and I'm just thinking in terms of test programs, not production.
So should be able to stay out of trouble viz. root or su.
Tempted to try the WIN version, though, just to see if it's possible to
get reasonably painless results reasonably smoothly. And that
happens to be where the data is. Shall report back...
Meanwhile by way of reward, if you've got interest in older
languages then this little relic ought to catch your eye:
The Seven Days of Creation (according to a systems programmer)
Almost archaeological. And sonofabitch, does it ever bring back
memories of punched cards.
FB.
The bonus is that Vim does fixed-format syntax highlighting. :3
The gotcha is that, if you run an OpenCOBOL program in a CGI environment that nukes the LD_LIBRARY_PATH variable for security, then that program can't find libcob.so.1 and aborts. The fix is to set/export LD_RUN_PATH when compiling with cobc.
at a config file of your own creation? (to tell Vim what COBOL is).
On the plus side, COBOL's dead-simple to learn compared to a lot of languages. One
of it's strengths, that a *huge* amount of code can still be relatively comprehensible due
simply to how it's structured. Say that about APL. Or FORTH. Or LISP.
As for missing libs, tip noted, and I can only guess how much hair got pulled out
figuring it out. Alternate fix: an install script verifies that libs are accessible before first
run, does something about it if not.
OTOH, only an issue if I was writing something for release. For once, this is programming
for fun.
FB.
Forth and Lisp are reasonably comprehensible to the same extent as C, but I don't think I can say the same about APL.
Yeah, the missing lib thing confused me because the same binary ran perfectly from the shell but caused the web server to throw an HTTP 500 Internal Server Error when run as CGI. The easier fix for me was to write a bash wrapper I named "cobol" that is just
/home/arielmt/bin/cobol wrote:#!/bin/bash
LD_RUN_PATH=/usr/lib cobc -x $@.
I'm getting excited to start writing more than proof-of-concept code for this project of mine.