COBOL - Is this language relevant today?
09. Juli 2024
The history of COBOL
COBOL (Common Business-Oriented Language) is a programming language that has played a key role in the history of computing. It emerged in the late 1950s, when there was a growing need for a programming language that could be used by companies and government organizations for commercial data processing.
The first version of COBOL was developed by a committee that included members from the government, universities and private companies. This working group was led by Grace Hopper, a key figure in the history of programming.
Between the 1960s and 1970s, COBOL quickly became the standard language for business applications due to its ease of reading and managing large volumes of data. In 1968, the American National Standards Institute (ANSI) published the first official COBOL standard, known as COBOL-68.
From this version, COBOL continued to evolve with the introduction of versions COBOL-74 and COBOL-85, which introduced new features and improvements to the language.
Between the 1980s and 1990s, the COBOL-85 version presented significant improvements, including support for structured programming, which helped to increase the readability and maintainability of the code, and was used very frequently in mainframe systems, especially in banks, insurance companies and other financial institutions.
The year 2000 brought a greater focus of attention on COBOL, as many legacy systems were written in this technology and needed to be revised to solve the problem of the millennium bug. Despite many predictions about its supposed outdatedness, COBOL continued to be used in legacy systems, as numerous organizations chose to modernize their systems rather than replace them. Thus, COBOL has not only stood the test of time, but also continues to evolve and adapt to the current needs of technology.
COBOL Fundamentals
COBOL was designed to be a programming language that could be understood not only by programmers, but also by business managers.
It is a language designed for companies, especially those whose operations involve managing large volumes of data and transactions. Thus, even today, COBOL's ability to support critical systems ensures that it will remain relevant for many years to come.
Structure of a COBOL program
A COBOL program is made up of four main divisions, each with a specific function.
IDENTIFICATION DIVISION
Contains information about the program, such as its name and description.
ENVIRONMENT DIVISION
Specifies the hardware and software environment in which the program will run.
DATA DIVISION
Defines all the variables and data structures that the program will use.
PROCEDURE DIVISION
Contains the program logic, with the instructions to be executed.
Example of the structure of a COBOL program:
IDENTIFICATION DIVISION.
PROGRAM-ID. HelloWorld.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
DISPLAY 'Hello, world!'.
STOP RUN.
IDENTIFICATION DIVISION
This division includes basic identifying information about the program, such as the program name.
IDENTIFICATION DIVISION.
PROGRAM-ID. MyProgram.
AUTHOR. John Doe.
ENVIRONMENT DIVISION
Defines the specific environment where the program will run and contains two main sections:
CONFIGURATION SECTION
Defines the hardware and software configuration.
INPUT-OUTPUT SECTION
Defines the input and output files.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. IBM-370.
OBJECT-COMPUTER. IBM-370.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT InputFile ASSIGN TO 'input.dat'.
SELECT OutputFile ASSIGN TO 'output.dat'.
DATA DIVISION
Defines the variables and data structures used in the program and contains several sections, the main ones being:
FILE SECTION
Defines the files that will be used.
WORKING-STORAGE SECTION
Defines temporary and constant variables.
LINKAGE SECTION
Defines the variables that will be passed to or from other programs.
DATA DIVISION.
FILE SECTION.
FD InputFile.
01 InputRecord.
05 InputField1 PIC X(10).
05 InputField2 PIC 9(5).
WORKING-STORAGE SECTION.
01 WS-Total PIC 9(5) VALUE 0.
01 WS-Count PIC 9(5) VALUE 0.
PROCEDURE DIVISION
Contains the logic of the program, with instructions structured in paragraphs and sections.
PROCEDURE DIVISION.
Main-Logic.
PERFORM Read-Input UNTIL End-Of-File.
DISPLAY 'Total: ' WS-Total.
STOP RUN.
Read-Input.
READ InputFile INTO InputRecord
AT END SET End-Of-File TO TRUE
NOT AT END
ADD InputField2 TO WS-Total
ADD 1 TO WS-Count
END-READ
Key elements and concepts in COBOL programming
COBOL verbs
Instructions that perform operations such as MOVE, ADD, SUBTRACT, MULTIPLY, DIVIDE, READ, WRITE, OPEN and CLOSE.
Data Levels
Hierarchical levels used to define the data structure. The most common level is 01 for defining records and 05, 10, etc. for the fields within those records.
Pic Clauses (Picture Clauses)
These define the format and type of data, such as PIC X for characters and PIC 9 for numbers.
Conditionals and Iterations
Use of instructions such as IF, ELSE, PERFORM to control flow and iteration.
The longevity of COBOL technology
Several factors have contributed to the longevity and relevance of COBOL today, including:
Stability and reliability
COBOL is known for its robustness and reliability. Some critical systems in banks, insurance companies and governments were designed in this technology and have remained functional and stable for many years.
Legacy code base
There is a large amount of code still written in COBOL by various systems, in different sectors, which is still in use. However, completely replacing these systems would represent a high investment and a worrying exposure to risk. Therefore, some companies choose to maintain their existing systems, updating them, rather than completely replacing them.
Data processing capabilities
COBOL is designed to be efficient at processing large volumes of data, which is crucial for many companies. Its oriented syntax makes it easy to maintain and understand the code for this type of operation.
Migration cost
Migrating a COBOL system to a new platform can be a complex and expensive process. For this reason, some companies weigh up the associated benefits against the cost and risk of the investment, opting to keep their current systems.
Compatibility and integration
COBOL systems are often compatible with other existing technologies and infrastructures. Continuous integration with new systems and technologies helps maintain their relevance.
Evolving Language
COBOL has not remained stagnant. It has evolved over time with new versions that have added support for modern features such as object-oriented programming and integration with web technologies and modern databases.
Challenges facing the COBOL language
Professional shortage
A considerable proportion of COBOL programmers are close to retirement. On the other hand, there are few new programmers trained and experienced in this specific language. This scenario creates an eminent challenge in human resource management to maintain and update systems and infrastructures in companies.
Complex systems
Many systems developed in COBOL technology were created decades ago and have layers of modifications and patches. Thus, understanding and modifying these systems can be extremely difficult, especially without the aid of proper documentation.
Cost of maintenance
Maintaining old systems can be expensive. On the other hand, the most modern development tools and environments may not be fully compatible with COBOL, thus requiring the adoption of customized solutions.
Integration with new technologies
Although there are tools to help integrate COBOL with new technologies, the process can be complex and error-prone.
Myths about COBOL programming
COBOL is an obsolete language
Although it is an old technology, it is not at all obsolete, as it continues to be used in critical sectors and has evolved over time to include new features and functionalities.
Difficult learning curve
Although its syntax is different from more modern languages, COBOL is known for its clarity and ease of reading, especially for people responsible for managing business operations.
Lack of support
Today, there are many tools and frameworks that allow COBOL to be integrated with modern systems, including web interfaces and current databases.
Technology only for older systems
COBOL is still used in new projects, especially in systems where reliability and efficiency in transaction processing are crucial.
High operating costs
The total cost of ownership of a COBOL project can be lower than rewriting complete systems in new languages, considering the respective risks and migration costs.
Overcoming language challenges
Training
Investir em programas de formação para novos programadores pode ajudar a mitigar a falta de profissionais qualificados nesta tecnologia.
Modernization tools
Using tools that make it easier to maintain and integrate COBOL with modern technologies can reduce costs and all the complexity of cohabitation with other languages and systems.
Migration planning
Planning and executing system migrations to new platforms in a gradual and controlled manner can mitigate risks and associated costs.
Advantages of the COBOL language over other more modern technologies
Comparing COBOL with more modern programming languages can help to understand its advantages and disadvantages in different contexts. In this regard, we have established some points of comparison between COBOL and more modern languages such as Python, Java and C#.
Simplicity and readability
COBOL is known for its natural language-like syntax, which makes the code easy to read and understand. On the other hand, other languages such as Java and C# can be more complex due to their detailed syntax and boilerplate requirements.
Efficiency in transaction processing
Excellence in managing large volumes of data and transactions makes COBOL the ideal language for financial systems. Similarly, Java and C# are also very efficient and have robust processing capabilities. However, Python, although slower in complex processing operations, compensates through the specialized libraries available.
Stability and reliability
COBOL technology is stable and reliable, with many critical applications running consistently for many years. Java and C# are known for their stability, especially in corporate environments.
Maintenance and updating
Intuitive reading makes maintenance easier, but the lack of new COBOL programmers can be a problem. In other, more modern languages, there may be a greater availability of programmers and resources, as well as advanced development tools that make maintenance easier.
Integration with new technologies
Integrating COBOL with new technologies can be challenging, but there are tools that enable the transition to modern systems. In contrast, today's most common languages are designed for easy integration with contemporary technologies, APIs and web services, allowing for faster implementation of new functionalities.
Development and implementation
Due to the detailed and rigorous nature of COBOL, development can be slower when compared to more modern languages, where development is generally faster due to frameworks, libraries and integrated environments that speed up the process.
Cost of operation and maintenance
Due to its stability and efficiency, COBOL has low long-term operating costs, but higher maintenance costs due to the scarcity of programmers. In the case of modern languages, they may initially have lower costs due to the abundance of programmers, but the long-term operating values may vary depending on the complexity of the system.
Modern features
The latest COBOL updates include support for object-oriented programming and integration with web technologies, but they can still be limited compared to newer languages. On the other hand, newer languages offer a range of modern features, support for object-oriented programming, functional programming and integration with emerging technologies.
Community and support
Although the COBOL support community is solid, it tends to age due to the scarcity of new professionals programming in this language. In contrast, today's most common languages enjoy a growing community, with an abundance of learning resources, forums and ongoing support from major technology companies.
Application in complex systems
As we have already seen, COBOL is ideal for financial systems and other applications that require high reliability and the processing of large volumes of transactions, while more modern technologies are more suited to agile programming such as web development, mobile, Artificial Intelligence, Big Data, etc.
Language modernization and digital transformation
Integrating COBOL into digital transformation initiatives, such as migration to the cloud and adoption of emerging technologies, can be a challenge, but also a necessity for organizations that depend on COBOL systems for their daily operations.
Migration to the cloud
Rehosting or lift and shift
Many companies choose to host their COBOL systems on cloud platforms without significantly modifying them. This involves migrating the systems directly to the cloud, while maintaining the existing infrastructure and business logic.
Refactoring
To make their COBOL systems more suitable for the cloud, some organizations opt for refactoring. In practice, this can involve separating components into smaller services, migrating to architectures based on microservices.
Incremental modernization
Instead of a complete migration, some companies take an incremental approach, modernizing specific parts of their systems while they remain in operation, allowing for a smooth transition without interrupting the company's day-to-day operations.
Adopting COBOL to emerging technologies
Integration with APIs and web services
COBOL systems can be integrated with APIs and web services to facilitate communication with modern applications and cloud platforms, enabling data and functionality to be accessed more flexibly by other systems.
Data analysis and Business Intelligence
Data analysis and business intelligence tools can be integrated with COBOL to extract data and insights allowing companies to make more informed decisions based on historical data about the operation.
Automation and Artificial Intelligence
Automation and Artificial Intelligence technologies can be applied to COBOL systems to improve operational efficiency and reduce costs. Rules-based business processes can be automated and AI algorithms can be used for predictive analysis.
The future of the COBOL language
The outlook for COBOL continues to be influenced by a number of factors, including its continued importance in systems, the demand for skilled professionals and efforts to modernize the ecosystem.
Maintaining legacy systems
Some companies will continue to rely on COBOL systems for their day-to-day operations due to their stability, reliability and efficiency in processing transactions.
While complete migration can be costly and risky, incremental modernization will allow companies to update COBOL systems gradually, integrating them with recent technologies and in cloud environments.
Shortage of professionals
The shortage of COBOL programmers may persist, with the result that some companies will struggle to find qualified talent to maintain and update their systems.
Integration with emerging technologies
The development of specialized tools and partnerships will facilitate the integration of COBOL systems with emerging technologies, making the modernization process more accessible and efficient.
Training
Investment in training will be crucial to meet the demand for new COBOL developers. Academic bodies and organizations need to cooperate synergistically on specialized programs for programmers new to this technology.
Although COBOL is often associated with a classic language, its future prospects remain solid due to its indispensability in legacy systems and the ongoing demand for new professionals. With investment in modernization, talent and integration with emerging technologies, COBOL is set to remain relevant and play a key role in the technological landscape for many years to come.
Wilde Artikel
What is Outsystems and how is it transforming software development
Java - What makes this language so popular among programmers?
The importance of good practices in .NET programming
Linux: a versatile and powerful operating system
Implementing a Business Intelligence system
Emerging Challenges in IT Security - Trends and Strategies to Protect Companies