Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

COBOL vs. Perl

by Ovid (Cardinal)
on Jun 14, 2000 at 09:55 UTC ( #18048=perlmeditation: print w/ replies, xml ) Need Help??

So there I was, about 6 months ago, working on an IBM mainframe with a piece of COBOL code that wasn't working. The code was supposed to take a comma-delimited string and parse it out into a fixed width string. For those of you who are familiar with COBOL, this is not a trivial task.

The relevant section of code was about 150 lines of rather dense (for COBOL) code. After reading through it and seeing what was going on, I realized that the original author did not understand the proper use of the UNSTRING function (which is similar in concept to Perl's split function).

I rewrote the code and fixed the bug. In the process, I managed to shrink it down to about 80 lines of code. Then, just to play around, I rewrote that section in Perl.

It took 10 lines of code.

Any guesses as to why I quit? And for the record, I am 32 years old and I occassionally found myself fixing code that was written before I was born. :(

Comment on COBOL vs. Perl
RE: COBOL vs. Perl
by btrott (Parson) on Jun 14, 2000 at 09:59 UTC
    Have you read this article by Mark-Jason Dominus, Perl Meets Cobol? Very interesting stuff.
      Yup, read it and loved it. It's probably the only reason I have the guts to mention that I used to program in COBOL :)
      From my 10 years in consulting, I have to say that Mainframe programmers still using COBOL/Fortran/PL/1 or whatever -- just haven't seen the light. Kids are learning PERL, XML, HTML and Javascript in high school. And... can do more with it that any 15 year vet in COBOL/CICS/JCL. COBOL exceled in batch/file processing for non-academics: ie, those people who needed code to say "MOVE WS-MY-BIG-NUMBER TO WS-MY-BIG-TOTAL" instead of a=b.
        Dude, seriously. This thread is over three years old. You also wouldn't say "a=b" in Perl.
RE: COBOL vs. Perl
by davorg (Chancellor) on Jun 14, 2000 at 12:26 UTC

    10 lines of code to do that in Perl sounds a bit excessive!

    Obviously I'm not entirely sure exactly what you were doing, but it seems to me that with split and pack you could probably do it in about two lines.

    Dave...

      Ordinarily, yes. Unfortunately, the format of the input file depended heavily on the computer-illeterate users, so I had to do validation on the input and spit out error messages as appropriate.

      The Moral of This Little Tale: Trust your users, not their input!

      Update: I was going to correct my little spelling error, but I realized others might appreciate the irony of my mispelling "illiterate."

        Absolutely right!

        Something that I think gets lost in this mad rush to find the smallest most obscure code to solve a problem is that often you're sacrificing error-checking along the way. In the real world, I place much more emphasis on Doing the Right Thing than in brevity.

        I applaud you for this. I wish more people followed your lead.

        (Yes, I am a boring old fart :-)

RE: COBOL vs. Perl
by JanneVee (Friar) on Jun 14, 2000 at 20:38 UTC
    I recognize this. I had a course recently where I learned Cobol. I was constantly thinking. "I can redo everything in Perl and SQL in about the half of the time!"
      Uggh - I took a COBOL class for CS majors my last semester of college. It was instructed by the teacher that taught CGI Progamming with Perl (which I attended a year before). Imagine the utter pointless-ness. When it came time to do the last program - my brain shut down from shear abuse. I took a C instead and graduated a happier man.
RE: COBOL vs. Perl
by cbraga (Pilgrim) on Jun 19, 2000 at 03:56 UTC
    It's quite scary that demand for COBOL programmers is still pretty high...

    Perhaps twenty years from now, when we shall be able to tell our computers in natural language what we want from them, they'll still be using some sort of COBOL...


      000100*I've had a COBOL course too, though luckily I never actually had to use it.
      000200*(Shh! Don't tell 'em I skipped the homework ;-)
      000300 ADD A TO B GIVING C.
      000400*;-)
RE: COBOL vs. Perl
by eduardo (Curate) on Jun 20, 2000 at 04:26 UTC
    reminds me of the first time i encountered a VHLL (very high level language) it was my first or second year of CS at school, and we had to program a version of the sieve of erosthenes (sp?) in C and in ASM so we could see the speed difference. my professor, a big fan of VHLL's said: "that's a waste of programmer time!" and in 1 line of a language called ISET-L wrote a sieve of erosthenes program. 20 seconds. that's when i began to learn what a good programming language can do for you... and now, i love perl... the swiss army chainsaw of VHLL's :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://18048]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (15)
As of 2014-12-18 11:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (50 votes), past polls