<daver>

@gomerbud.com

Cobol Sucks

Let's face it, cobol sucks. What follows is a comparison of different programming languages. The program is extremely simple and pointless, but it does a good job at illustrating the nastiness of cobol.

Sample Program in C

This is nice and simple. No tricks here...

#include <stdio.h>

int
main(void)
{
   int newDate, newTime, intOne, intTwo;

   printf("Input the date to remember: MMDD\n");
   scanf("%d", &newDate);

   printf("Input the time to remember: HHMM\n");
   scanf("%d", &newTime);

   printf("Give me the first integer...\n");
   scanf("%d", &intOne);

   printf("Give me the second integer...\n");
   scanf("%d", &intTwo);

   printf("Sum: %d\n",        intOne + intTwo);
   printf("Difference: %d\n", intOne - intTwo);
   printf("Product: %d\n",    intOne * intTwo);
   printf("Quotient: %d\n",   intOne / intTwo);
   printf("So long, beautiful language.\n");
   printf("Date: %d\n", newDate);
   printf("Time: %d\n", newTime);

   return 0;
}
      

Sample Program in C++

Ah, our old friend C++. The only difference here is the use of the shift operators for stream input and output.

#include <iostream>

int
main(void)
{
   int newDate, newTime, intOne, intTwo;

   cout << "Input the date to remember: MMDD" << endl;
   cin >> newDate;

   cout << "Input the time to remember: HHMM" << endl;
   cin >> newTime;

   cout << "Give me the first integer..." << endl;
   cin >> intOne;

   cout << "Give me the second integer..." << endl;
   cin >> intTwo;

   cout << "Sum: "        << intOne + intTwo << endl
        << "Difference: " << intOne - intTwo << endl
        << "Product: "    << intOne * intTwo << endl
        << "Quotient: "   << intOne / intTwo << endl
        << "So long, beautiful language." << endl
        << "Date: " << newDate << endl
        << "Time: " << newTime << endl;

   return 0;
}
      

Sample Program in Perl

Yes Nick, I know you could probably do this program as a one liner. I am not the 1337 perl hax0r that you are, so don't complain.

#!/usr/local/bin/perl -w

print "Input the date to remember: MMDD\n";
$newDate = <STDIN>;

print "Input the time to remember: HHMM\n";
$newTime = <STDIN>;

print "Give me the first integer...\n";
$intOne = <STDIN>;

print "Give me the second integer...\n";
$intTwo = <STDIN>;

print "Sum: ",        $intOne + $intTwo, "\n";
print "Difference: ", $intOne - $intTwo, "\n";
print "Product: ",    $intOne * $intTwo, "\n";
print "Quotient: ",   $intOne / $intTwo, "\n";
print "So long, beautiful language.\n";
print "Date: ", $newDate;
print "Time: ", $newTime;
      

Sample Program in Fortran 90

Fortran is a bit cheesy. It reminds me of Basic.

PROGRAM STUPID
INTEGER :: newDate, newTime, intOne, intTwo

PRINT *, "Input the date to remember: MMDD"
READ *, newDate

PRINT *, "Input the time to remember: HHMM"
READ *, newTime

PRINT *, "Give me the first integer..."
READ *, intOne

PRINT *, "Give me the second integer..."
READ *, intTwo

PRINT *, "Sum: ",        intOne + intTwo
PRINT *, "Difference: ", intOne - intTwo
PRINT *, "Product: ",    intOne * intTwo
PRINT *, "Quotient: ",   intOne / intTwo
PRINT *, "So long, stupid language."
PRINT *, "Date: ", newDate
PRINT *, "Time: ", newTime

END PROGRAM STUPID
      

Sample Program in Cobol

Here is where life gets a bit uncomfortable. I think the code speaks for itself.

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. STUPID.
000300 ENVIRONMENT DIVISION.
000400 DATA DIVISION.
000500 WORKING-STORAGE SECTION.
000600 01  NEW-DATE  PICTURE IS 9999.
000700 01  NEW-TIME  PICTURE IS 9999.
000800 01  INT-ONE   PICTURE IS 9999.
000900 01  INT-TWO   PICTURE IS 9999.
001000 01  ANSWER    PICTURE IS 9999.
001100 PROCEDURE DIVISION.
001200 PROGRAM-BEGIN.
001300     DISPLAY "Input the date to remember: MMDD".
001400     ACCEPT NEW-DATE.
001500     DISPLAY "Input the time to remember: HHMM".
001600     ACCEPT NEW-TIME.
001700     DISPLAY "Give me the first integer...".
001800     ACCEPT INT-ONE.
001900     DISPLAY "Give me the second integer...".
002000     ACCEPT INT-TWO.
002100     COMPUTE ANSWER = INT-ONE + INT-TWO.
002500     DISPLAY "Sum: " ANSWER.
002200     COMPUTE ANSWER = INT-ONE - INT-TWO.
002600     DISPLAY "Difference: " ANSWER.
002300     COMPUTE ANSWER = INT-ONE * INT-TWO.
002700     DISPLAY "Product: " ANSWER.
002400     COMPUTE ANSWER = INT-ONE / INT-TWO.
002800     DISPLAY "Quotient: " ANSWER.
002900     DISPLAY "So long, stupid language.".
003000     DISPLAY "Date: " NEW-DATE.
003100     DISPLAY "Time: " NEW-TIME.
003200 PROGRAM-DONE.
003300     STOP RUN.