COBOL B COOL - Aayush Neupane, Jonathan Pak, Tri Ninh

HISTORY

  • COBOL stands for COmmon Business Oriented Language
  • 1959 COBOL developed by CODASYL
  • COBOL-61 released in 1961 with various improvements
  • In 1968, ANSI approved COBOL-68 as a standard language for commercial use
  • Major revisions in 1974 and 1985 to COBOL-75 and COBOL-85, respectively.
  • In 2002, Object-Oriented COBOL was released which allowed encapsulated objects to be used in COBOL programming

MAIN PURPOSE OF INVENTING COBOL

During the 1950s, businesses were growing at an incredible rate and began develop needs for business data processing. In 1959, the Conference on Data Systems Language (CODASYL) helped to develop COBOL which stood for Common Business Oriented Language. Thus, COBOL was born.

COBOL Paradigm(s)

  • Imperative paradigm - sequential command execution and use of variables in place of memory addresses
  • As of 2002, includes object-oriented paradigm
  • Procedural - focus on procedures, routines, and subroutines, top down way of writing a program, similar to imperative

How successful is COBOL?

  • Over 200 billion active lines of COBOL code in use today according to the Gartner Group, 1997
  • In 1997, COBOL was used in 80% of business machines, dropped to 60% by 2012
  • As of May 2016, ranked 23rd by TIOBE programming community index

A Code Divided

  • COBOL uniquely has four divisions in its code. They structure the rest of the code by increasing granularity through sections, paragraphs, sentences, statements, and characters
  • Identification Division - In every COBOL program with PROGRAM-ID the only mandatory paragraph.
  • Environment Division - Used to specify input-output and redirection for the COBOL code.
  • Data Division - Several sections to define how data, variables, and external usage of the program will be done.
  • Procedure Division - Statements and program logic will be written here.
  • To stop a program would involve use of the STOP RUN sentence. To end a program you have to call END PROGRAM <PROGRAM-NAME> which was declared in the Identification Division.

DATA TYPES

  • Data Name (User-defined name excluding reserved words)
  • Level Number (Differentiates the level of data whether data is grouped or atomic)
  • Picture Clause (Defines data type, sign, decimal point position, and length)
  • Value Clause (Optional clause which can be used to initialize data)
  • The three data types include alpha-numeric (defined by the keyword X), Alphabetic (defined by keyword A), and numeric (defined by keyword 9)

VARIABLES

  • Temporary variables are declared in its Data Division
  • Static scoping, provides compile time binding for variables
  • External - Variables are also seen as global variables
  • Global Program Scope - Variables declared as global variables that are visible to entire program and all the nested subprograms contained in the program
  • Program Scope - Variables are visible to the entire program in which they are declared, but are deleted and reinitialized on every invocation.
  • Nested Program Scope - COBOL doesn't distinguish between functions and programs. Can be many programs inside one program with the scope limited to each subprogram.

DATA STRUCTURES

  • Arrays are called Tables in COBOL (think DB context) declared through use of OCCURS # TIMES
  • Most COBOL programs operate in a domain where the program complexity lies in the business rules that have to be encoded rather than in the sophistication of the data structures or algorithms required.
  • COBOL has a concise and flexible syntax for defining complex data structures and odd data types, perfect for working with databases

CONTROL STRUCTURE

  • IF - used as in any other programming language with IF, THEN, ELSE, similar to END-PROGRAM, IF control is ended with END-IF
  • IS, NOT - used for conditions such IS GREATER THAN or IS NOT LESS THAN
  • PERFORM - used to create loops, just like for loops or to run certain paragraphs
  • GO TO - used to branch out to another statement
  • EVALUATE - used a ‘SWITCH’ statements in modern languages which is often combined with PERFORM to assign a task.

sample code

Very structured even in the columns of the code

OBJECTS

  • Encapsulated objects, classes, and interface introduced in 2002 by Fujitsu, IBM, and MicroFocus
  • Objects have their own DATA & PROCEDURE DIVISION. Each object has their own data, variables, and methods.
  • Objects have public/protected/private object and method scope

ABSTRACTION

  • Encapsulated objects, classes, and interface introduced in 2002
  • Classes have factor objects containing class methods and variables, and instance objects containing instance methods and variables.
  • Objects are stored as references which may be restricted to certain types
  • Objects have public/protected/private object and method scope

Regularity

  • COBOL has 4 main divisions in the code (Identification Division, Environment Division, Data Division, and Procedure Division)
  • Very specific commands are designated for each division and thus using code in the wrong division proves a lack of orthogonality
  • However with the Object-Oriented COBOL release which utilizes encapsulation, there was more orthogonality in the language
  • The code is extremely uniform in its look, the code is very verbose but manages to stay very clean and uniform in the way code is written.

RELIABILITY AND EFFICIENCY

  • The program reads very much like English language
  • Very good readability; extremely verbose thus extremely long lines of codes but easy to read.
  • Writability was a problem when the program was introduced in the 60s.
  • COBOL's target code is done through using a compiler and turning source code into machine code. Type and size checking are done at compile time but...
  • COBOL’s keywords have built in exception handling.
  • COBOL is extremely robust as evident through its test of time.

EXTENSIBILITY

  • Low extensibility, difficult to add new features
  • Programmer doesn’t have options to invent new commands and use that

DEMO

Made with Adobe Slate

Make your words and images move.

Get Slate

Report Abuse

If you feel that this video content violates the Adobe Terms of Use, you may report this content by filling out this quick form.

To report a Copyright Violation, please follow Section 17 in the Terms of Use.