Search390.com
Developer Tip
August 8, 2001

========================================================
SPONSORED BY: Storage Decisions 2001
========================================================
Storage Decisions 2001 brings together the top storage industry
analysts and expert technologists to give you specific how-to advice
to set storage strategy, make key decisions and manage storage
effectively. This exclusive conference is FREE to those who qualify. 
Apply today at www.StorageDecisions2001.com.
========================================================

============================================
search390 TIPS CONTEST 
============================================ 
Have a great tip of your own that you'd like to share with the rest
of us? Then send it in. Our tip of the month contest has been
extended through the end of August, so there is still time to take
home the fabulous T-Rex remote control dinotronic dinosaur. 

To submit your tip today, go to
http://search390.techtarget.com/tipsSubmit/1,289485,sid10,00.html 
============================================
TODAY'S DEVELOPER TIP:

Snatch this COBOL from my hand, Grace Hopper
By Jim Keohane --- with apologies to Kwai Chang Caine

The following is to be read as if intoned by curmudgeon di tutti
curmudgeons, Andy Rooney:

Would I, who has suckled at the Y2K teat, dare blaspheme against
COBOL, the source of the maintenance work dole? You betcha!

COBOL is to programming what QWERTY is to typing. Original typing
machines jammed when the keys were rapidly struck. The solution then
was to spread the most common letters around the board to slow down
the typist. I fear COBOL must have suffered from the similar initial
design points. COBOL allows the sufficient grasp of the obvious and
mundane logic and stifles the overall conceptualization of a
sophisticated design. COBOL has the benefit(?) that even
non-programmers can read the source. Even management {shudder} can
read COBOL! In short, those with little actual software engineering
skills can fancy themselves accomplished programmers.

If keyboards were being designed today from scratch they would
resemble DVORAK far more than QWERTY. 

See http://www.wordpool.co.uk/wfc/art/dvorak.htm.

A programming language developed today using all that has been
learned about productivity, maintenance, reusability, performance and
even READABILITY would in no way resemble COBOL!

COBOL is a programming language that Charles Dickens would love. He
was paid by the word! Much has occurred in recent decades to graft
onto COBOL that which was endemic to more modern languages.
Unfortunately, it was done following reverse game show rules:

I CAN CODE THAT ROUTINE in 50 words.
I CAN CODE THAT ROUTINE in 100 words.
I CAN CODE THAT ROUTINE in 250 words.
COBOL programmer, CODE THAT ROUTINE!

COBOL has two things going for it. Inertia is one. The other is the
YUCK (or Y2K) factor where the inventorying done in late 90's on
mainframes showed how insurmountable wholesale conversion from COBOL
would be.

The COBOL CABAL cobbled together code generators (Cool:GEN, CA-Telon,
RETIRE, etc.) and off host Integrated Development Environments (IDE's
like MicroFocus, Visual Age, etc.) and even off host production
environments (Fujitsu Power COBOL, CA-Realia, etc.) with varying
degrees of success. The vogue today is to let sleeping COBOL lie and
just wrapper it with Java, COM, CORBA, XML/SOAP, etc.

Object-oriented extensions have been proposed, accepted and
implemented, though you would not know it to look at mainframe COBOL
shops. Curiously, COBOL can actually lay claim to some OO features.
For example, a READ or WRITE can be directed at various file types,
providing a form of polymorphism. MOVEs and other COBOL verbs operate
quite fine on different underlying data types.

The END-xxx closure has been added to COBOL to solve the period (".")
dilemma, a problem no other popular language has. It also provided a
simple means to allow a programmer to grasp the logic without having
to jump all around the source. 

BY REFERENCE and BY CONTENT added to COBOL parameter passing that
which few other languages lacked.

The CORRESPONDING option of ADD, MOVE allows for a more 4GL approach.
By that, I mean you describe what you have and what you want and then
simply describe or call for some operation. Unfortunately, many shops
outlaw CORRESPONDING for what I think are spurious reasons. These
shops insist on different elementary data names and prefer 

MOVE EMP-FNAME TO MGR-FNAME 
MOVE EMP-LNAME TO MGR-LNAME 
MOVE EMP-MNAME TO MGR.MNAME.

instead of 

MOVE CORR NAME OF EMP TO NAME OF MGR.

They are overwrought about a mistaken difference in field name or
hierarchy, causing LOGIC to not work as intended. 

Add in a WITH statement similar to PASCAL and you can do:

WITH MGR 
    MOVE CORR NAME OF EMP TO NAME
    MOVE CORR KEYS OF EXECUTIVE-WASHROOM TO KEYS
    MOVE OPTIONS OF UPPER-MANAGEMENT TO OPTIONS.

Now all you need is PL/I's LIKE statement to make the above even
easier. Be of good cheer, COBOL 2002 is adding such via SAME AS
option. Naturally, COBOL's prolixity prefers SAME AS to the more
succinct LIKE.

Now that I think about it, it's not that COBOL is so bad. I wrote my
first program, self-taught from a COBOL manual, on a S/360 model 30.
It was kind of nice to see prime number calculations visibly slow.
{smile}

I also worked on COBOL convertors and optimizers and even
COBOL-to-XML generators from which I drew a measure of satisfaction.
It's just that, in mainframe world, COBOL enhancements are slow to be
implemented and worthwhile older features are foolishly
circumscribed. {sigh}

Some proposed COBOL 2002 enhancements: Visit
http://www.merant.com/Standards/d2.pdf.

* Literals and arithmetic expressions as CALL parameters. 
* Recursive CALLs of active COBOL (sub)programs. 
* Limited concatenation of literals. 
* ALLOCATE and FREE for dynamic memory. 
* AREA A and AREA B nonsense has been expunged. 
* The awkward FUNCTION, added to provide what virtually all modern
languages provide, has been further streamlined. You no longer have
to code FUNCTION in every invocation. This is the first known
violation of the COBOL prolix directive. 
* Same line comments allowed after '*>'. About time! 
* VALUE can initialize a TABLE declaration. About time! 
* Fuller POINTER support for data and logic. 
* SAME AS allows for like declarations. PL/I had LIKE 3 decades ago!
Helps CORRESPONDING logic. 
* TYPE and TYPEDEF support similar to C. 
* User-defined-functions (UDF's) can be written and invoked like
intrinsic functions. 

I'm sure no one took offense at the above. Why, I bet that ...

Who's that? Oh, no. It's the X-Man CyCOBOLops! He's facing me.
Raising his shades, err, visor. Why, it's Tom Ross, the QWERTY-WORDY
man! That light! Noooooooooo!!!!!!!!!!!! {thump}

For extra credit:

Visit http://www.cs.man.ac.uk/~pjj/babel/index.html where "99 bottles
of beer" and "Hello World" contrast COBOL with hundreds of other
programming languages. Often, quite humorously.

I particularly liked the Quines (self-reproducing programs) that,
when run, produce as output their full and complete source. There is
no COBOL version. In particular is Dan Hoey's one line ASCII C
example below. It not only reproduces itself, it does it as kind of a
palindrome!

main(){char*a="main(){char*a=c%s%c%;printf(a+42,34,a,34);};)43,a,43,24+a(ftnirp;%c%s%c=a*rahc{)(niam";printf(a+42,34,a,34);}
 

So, a C programmer can say to a COBOL programmer "Go code yourself!"

------------------------------------------------------
About the author: Jim Keohane ([EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>) is president of New York
consulting company Multi-Platforms, Inc. His company specializes in
commercial software development/consulting with emphasis on
cross-platform and performance issues. 

Did you like this tip? Send us an email <mailto:[EMAIL PROTECTED]>
to let us know your thoughts.

=======================================================
Share the knowledge!
=======================================================
Have you got some code secrets to share with your colleagues?  Don't
miss out on the opportunity to help someone else or to post your own
questions.  Check out our search390 Developer Discussion Forum at
http://search390.discussions.techtarget.com/WebX?50@@.ee83ff7

Also check out our other search390 forums on operating systems,
e-business, and sound off (aka miscellaneous!).  There's sure to be
something there to spark your interest.

========================================================
Disclaimer: Our tips exchange is a forum for you to share technical
advice and expertise with your peers and to learn from other IT
professionals. Techtarget.com provides the infrastructure to
facilitate this sharing of information. However, we can't guarantee
the accuracy and validity of the material submitted. You agree that
your use of the ask the expert services and your reliance on any
questions, answers, information or other materials received through
the web site will be at your own risk.
========================================================

======================================================== 
If you would like to sponsor this or any TechTarget newsletter,
please contact Gabrielle DeRussy at [EMAIL PROTECTED]
======================================================== 


If you no longer wish to receive this newsletter simply reply to 
this message with "REMOVE" in the subject line.  Or, visit 
http://search390.techtarget.com/register 
and adjust your subscriptions accordingly. 

If you choose to unsubscribe using our automated processing, you 
must send the "REMOVE" request from the email account to which 
this newsletter was delivered.  Please allow 24 hours for your 
"REMOVE" request to be processed.

Reply via email to