Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

COBOL VS C++

Is C++ suitable as a replacement to COBOL in the mainframe business


environment?
Michael Riley
Ian Diebert
Spring 2017 CS332 – Organization of Programming Languages
OVERVIEW
• Purpose and Scope
• Introduction
• Programming Requirements
• History
• Syntactic Differences
• COBOL Code Statistics
• C++ Code Statistics
• Questions
PURPOSE AND SCOPE
• These PowerPoint slides contain information concerning a comparison
between the Common Business Oriented Language (COBOL), and C++ in
the following regards:
• Objective
• Execution timing
• Lines of code to perform the same operation
• Binary size on disk
• Subjective
• Readability and maintainability of code
• Ease of learning
• Lack of adherence to SW design principles
INTRODUCTION

• Research Hypothesis: Due to the advances of computer hardware and


being that COBOL is not operational on modern hardware, we expect C++
to outperform COBOL.
• There is a fundamental difference between these languages that is
apparent within the first sentence of the description of each:
• C++ is general purpose, statically typed, free-form, multi-paradigm and
compiled.
• COBOL is a compiled English-like computer programming language designed for
business use. It is imperative, procedural and, since 2002, object-oriented.
• These differences in design scope create a void of applicability between
these two languages. This is not to say that C++ cannot replace COBOL yet
it does present some significant implementation and migration concerns.
PROGRAM REQUIREMENTS
Each program C++ and COBOL will be compared to each other based on the above criteria over
performing the following tasks:

1. Read in a .CSV file


2. Store the data from the file into memory
3. Randomly generate values
4. Update the entire contents of the file by adding the randomly generated number to a specific field
per row of the entire data set
5. Write the data back to a .CSV file

Platform and Operating System Information:


• Windows 7 Professional 64-Bit
• 8 GB Ram
• Solid State Hard Drive
HISTORY
C++
• In 1983 Bjarne Stroustrup altered the name of the ‘C with classes’
programming language he was designing to C++
• C++ was motivated by Bjarne’s work with Simula 67 during his Ph.D thesis,
which he found to be very useful but to slow for software development
• It is of note that the creation of C++ also corresponded with the emergence
of ADA which at the time was a direct competitor to C and by extension
C++
COBOL
• COBOL was developed in the early 1960’s to assist business professionals
with data processing and transactional interactions.
• The syntax of COBOL resembles the normal English sentence structure and
at first can be confusing to the imperative procedural programmer
• There are currently a bout 250 million lines of COBOL code running behind
todays modern businesses
SYNTACTIC DIFFERENCES
• C++ Conditional Expressions • COBOL Conditional Expressions
• If(x == 5){ } • if something is less than or equal to
something else then
• C++ Loops
• While(x == 20){ } • COBOL Loops
• For(x = 0; x < 5; x++){ } • perform varying rec-counter from 1
by 1 until rec-counter is greater than
• C++ String Manipulation 1526
• Resize()
• COBOL String Manipulation
• Find_fist_of()
• Unstring csv-record delimited by ","
• Insert() into rec-geoid(rec-counter), rec-
• Swap() sumlev(rec-counter), rec-state(rec-
counter)…..more things
SYNTACTIC DIFFERENCES CONT.
file section.
* This is like file IO but you have to define the attributes of the file first
fd csv-file
record is varying in size
struct Record
from 0 to 16 characters
{ depending on size-csv-record.
long long GEOID; 01 csv-record pic x(9999).
* This is the output file description, basically a record written as a line at a
int SUMLEV; time
int STATE; fd csv.
01 out-rec pic x(9999).
//....about 26 more attributes...
working-storage section.
// Inside Main * This is like declaring a structure, input output goes into each ‘occurrence’
01 my-table.
vector <Record> table;
05 census-data-info occurs 1526 times.
10 rec-geoid pic 9(10).
// File IO 10 rec-sumlev pic 9(3).
10 rec-state pic 9(1).
ifstream infile("./all_140_in_04.P3.csv"); * About 26 more attributes …
COBOL CODE STATISTICS

• COBOL Lines of Code


(no comments, no empty lines)
• 166
• Execution Time
• About 1.2 seconds
• Binary Size On Disk
• Cobol1.exe -> 16kb
COBOL CODE STATISTICS (CONT.)
• The total lines of code in the COBOL program could have been reduced by
about 25 lines.
• According to research 1.2 seconds is VERY long for a COBOL file IO and sort
operation. This is most likely attributed to running COBOL code in a non
MAINFRAME setting, not using Job Control Language (JCL) files, COBOL Copy
(CPY) files, or any other of the many resources that COBOLER’s typically make
use of.
• The size of the binary executable on disk is probably about the right size since
COBOL was created during a time where memory management is crucial.
C++ CODE STATISTICS
OPTIMIZATION O2

• C++ Lines of Code


(no comments, no empty lines)
• 221
• Execution Time
• About 542 Milliseconds
• Binary Size On Disk
• cs332.exe -> 47kb
C++ CODE STATISTICS –
OPTIMIZATION DISABLED

• C++ Lines of Code


(no comments, no empty lines)
• 221
• Execution Time
• About 14 seconds!
• Binary Size On Disk
• cs332.exe -> 69kb
C++ CODE STATISTICS (CONT.)
• The total number of lines of code in the C++ program was around 220; this was
primarily due to heavy compartmentalization and extremely explicit declaration,
and could have been reduced by around 50 lines of code with very little effort
• C++ is not specifically optimized for the workload however its ability as a general
purpose language may explain its increased speed of COBOL in this basic test
• The size of the executable is larger than its COBOL counterpart due to the fact that
modern C++ does not suffer from the same memory constraints and can afford the
usage
CONCLUSIONS
• Overall our efforts were not a direct comparison between the two programming
languages due to our inability to write COBOL on an IBM mainframe and business
environment.
• Further testing is required to reach a definitive answer as to whether COBOL should
be replaced by C++ in industry. Such testing is beyond the capability and scope of
our efforts for CS332; however, this does seem to be a topic of future research,
perhaps at the master’s level or above.
• Our goal in performing further research would be to find clear examples of code
and data used in industry, and to find the hardware capable of running it. With this
information we would be able to better test against C++, as well as perhaps
multiple other languages that have been proposed as competitors to COBOL.
QUESTIONS?
• Michael Riley Cited Sources Links:
• Embry-Riddle Aeronautical University • www.google.com
• https://sourceforge.net/p/open-
• Computer Engineering cobol/discussion/cobol/thread/b1ede5c5/?limit=25
• Electrical Engineering #55e7
• www.stackoverflow.com
• rileym5@my.erau.edu
• 760-495-2891

• Ian Diebert
• Embry-Riddle Aeronautical University
• dieberti@my.erau.edu
• 503-803-3526

You might also like