How I learn to code in COBOL Programming Language In just one day.
Recently the COBOL programming language makes it to the news. The Government of New Jersey cried out for COBOL programmers to help out when the COVID-19 hit on the unemployment system that was built using COBOL. COBOL is mostly a language of the mainframe computers that can handle large scale datasets. At the moment the need for more COBOL engineers needed to maintain the existing system is growing and it will, after COVID-19. Remember, the old system needs to be maintained to function properly. New engineers are needed to be trained for this.
Note: COBOL is a very powerful programming language and it's still as faster than most of the modern programming language will use today.
I have never programmed in COBOL before until today, however, I have read about the language in the course of learning the history of computer programming.
Brief History
Just like others, I enjoy and love histories and I like to know a brief history of whatever I am learning and why. COBOL was invented by Grace Murray Hopper team in 1959 and it becomes Object-oriented language in 2002. It was one of the prominent programmings highly use at that time for business applications and large dataset processing like the unemployment system in New Jersey U.S.A and even now many government applications are still running on COBOL. This simply means the old system will have to use a lot of batches of files that need to be processed at the same time and endless output in file formats.
Well!!, COBOL is not exactly as bad as it was described as a hard language to learn. It's quite very simple to program. Remember language can be only simple when there is a large community of developers and tools, libraries and books to be read.
It should be quite easy for a developer to pick a language within 2-5 days and he or she should be able to start a practical project with it.,The only problem with language learning is the syntax and structuring of coding and choosing the compiler to use and how to set it up.
Tips in learning a new language
- Setting up your development environment.
- Data Type and Variable Declarations
- Data Type operations
- Control Structure
- Code Organisation
- File Operation and Accessing computer resources
- UI Programming if the language supports it.
- Choose a real-world problem to solve and implement.
The above is how I learn to code with COBOL programming language and it only took a few hours of my time.
SETTING UP COBOL DEVELOPMENT ENVIRONMENT.
Using the Open Cobol IDE for this tutorial, since setting it up is quite simple and just a normal installation process of installing an application, I prefer to use it for the now in case there is better IDE out there that I don't know of.
Download & Installation
Download and install the window version and there is a lot of tutorials out there to do the same in another operating system like MAC or Linux(I don't know how to do that yet)
Creating your First Programming Language Using The IDE above.
- Click on the new button as shown below.
Click on the okay button, the IDE will show an empty file and you can type this code hello world code into it and compile & run to make it runs and display the output.
If it does work and the out is display as shown below then yea! you are a COBOL coder and the rest is just to understand the language structure and I will show you how I learn it today.
Output result.
Data Type and Variable Declarations
If you understand how computer data type works, you should already know by now that these are merely memory abstractions and type restrictions enforce by the language on how to generate the data to be store on computer memory.
COBOL programming language is kind of different compare to current modern traditional languages.
In other, for me to learn the language quicker within as I claimed today, I started to think of the language as a data sheet with an organized structure which is:
- SECTIONS
- PARAGRAPHS
- SENTENCES
- STATEMENTS
- CHARACTERS
- DIVISIONS
If you take a close view of the Hello example above you will notice that 3-division has already be used.
which are IDENTIFICATION, DATA and PROCEDURE Division
The IDENTIFICATION division is used to identify the program id.
While-else, the data division is used to declare variables and data to be used in your program.
Finally, the PROCEDURE division is where your program logic code goes in.
How to declare a variable.
Every COBOL variable has to be declared before it can be used in the procedure division where the logic of the program is implemented.
Variable Declaration Syntax.
LEVEL-NUMBER VARIABLE-NAME PICTURE-CLAUSE VALUE[optional].
1) LEVEL NUMBER
Use to specify the level of data in a record.
01 - mean Record Description entry level:
2) VARIABLE NAME
This can be any name the user what to give to the variable.
3) PICTURE-CLAUSE
This is used to specify what data type and its size to be declared.
Syntax
PIC DataType(Size),
DATA TYPE
9 = Numeric
A = Alphabetic
X = Alphanumeric
Y = implicit Decimal
....
VALUE
This is a keyword used to initiate the data during a declaration.
Therefore to declare a variable that will hold an age of users you can do this in the data division and use it in the procedure section.
I bet you can tell the output of this program, you don't have to learn all the command of a language to solve a problem.
The article is getting bigger and I am going to stop here to start a new article on Data Type Operations and how I learn to code in COBOL during covid-19 lockdown within a day.
Regards