Walt Mankowski via plug on 11 Apr 2022 05:27:33 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Book: Modern Mainframe Development


The COBOL Fibonacci sequence example on Rosetta Code is a lot more
complex than it needs to be. I've attached a much simpler version.

Walt

On Mon, Apr 11, 2022 at 12:37:51AM -0400, Lynn Bradshaw via plug wrote:
> Not having used COBOL directly but having seen code examples, like the
> Fibonacci sequence ones on Rosetta Code, it looks insanely
> arthritis-inducing. I get the idea is for it to be readable for a pretty
> broad spectrum of different types of workers but I think Smalltalk nailed
> it down better with a mixture of terse algebraic syntax and syntax more
> like English language. APL is the other extreme opposite COBOL and
> Smalltalk sits in that nice golden mean.
> 
> On Mon, Apr 11, 2022, 00:21 Steve Litt via plug <plug@lists.phillylinux.org>
> wrote:
> 
> > JP Vossen via plug said on Sat, 9 Apr 2022 15:00:24 -0400
> >
> > >While this may seem OT for this list, it's not.
> > >
> > >I've just started reading a 2022-03 _Modern Mainframe Development_
> > >book (345 pages), and I find it really interesting.  Thus far it has
> > >made a compelling case for the strong demand side of skilling up in
> > >COBOL and IBM mainframe technologies.  This is pretty interesting too:
> > >https://github.com/search?q=COBOL.
> >
> > I've always thought that COBOL has gotten a bad rap. It has built-in
> > ISAM, which is pretty darn cool. Except for hitting the hardware
> > directly, in COBOL you can do most of what you can do in C,
> > including recursion. I don't know if you can pass references
> > to paragraphs or linked procedures in order to make callbacks. My only
> > real complaint about COBOL is that paragraphs can't have their own local
> > variables: Variables are local to the compiled source file only, so you
> > need to use CALL to call procedures linked in from other files.
> >
> >
> > SteveT
> >
> > Steve Litt
> > March 2022 featured book: Making Mental Models: Advanced Edition
> > http://www.troubleshooters.com/mmm
> > ___________________________________________________________________________
> > Philadelphia Linux Users Group         --
> > http://www.phillylinux.org
> > Announcements -
> > http://lists.phillylinux.org/mailman/listinfo/plug-announce
> > General Discussion  --
> > http://lists.phillylinux.org/mailman/listinfo/plug
> >

> ___________________________________________________________________________
> Philadelphia Linux Users Group         --        http://www.phillylinux.org
> Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
> General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

Program-ID. fib2.
Data Division.
Working-Storage Section.
  01  FIBONACCI-PROCESSING.
    05  FIB-TMP           PIC 9(36).
    05  FIB-ONE           PIC 9(36)   VALUE 0.
    05  FIB-TWO           PIC 9(36)   VALUE 1.
  01  DESIRED-COUNT       PIC 9(4).
  01  FORMATTING.
    05  INTERIM-RESULT    PIC Z(35)9.
Procedure Division.
  000-START-PROGRAM.
    Display "What place of the Fibonacci Sequence would you like (<173)? " with no advancing.
    Accept DESIRED-COUNT.
    If DESIRED-COUNT is less than 1
      Stop run.
    If DESIRED-COUNT is less than 2
      Perform 200-DISPLAY-FIBONACCI
      Stop run.
    Subtract 1 from DESIRED-COUNT.
    Perform 200-DISPLAY-FIBONACCI.
    Perform 100-COMPUTE-FIBONACCI until DESIRED-COUNT = zero.
    Stop run.
  100-COMPUTE-FIBONACCI.
    Move FIB-TWO to INTERIM-RESULT.
    Perform 200-DISPLAY-FIBONACCI.
    Compute FIB-TMP = FIB-ONE + FIB-TWO.
    Move FIB-TWO to FIB-ONE.
    Move FIB-TMP to FIB-TWO.
    Subtract 1 from DESIRED-COUNT.
  200-DISPLAY-FIBONACCI.
    Display INTERIM-RESULT.

Attachment: signature.asc
Description: PGP signature

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug