开发者

What is COBOL used for? [closed]

开发者 https://www.devze.com 2023-01-17 09:57 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem on开发者_高级运维ly b
Closed. This question needs to be more focused. It is not currently accepting answers.

Want to improve this question? Update the question so it focuses on one problem on开发者_高级运维ly by editing this post.

Closed 9 years ago.

Improve this question

What is COBOL used for?


COmmon Business Oriented Language 'invented' by Grace Murray Hopper ( read about her she is one one of the pivotal people in the development of computing as we know it today). The general idea was to produce a language that was English based as opposed to mathematically based or expressed as such in the code.

Very simply put you would use a construct like

ADD YEARS TO AGE

as opposed to

age = age + years

or

age += years

Appearing in the early 1960's it was massively adopted for processing in the area of business. There are still a large volume of applications built in COBOL still running and maintained and it is still very much alive and kicking. Around 1997 Gartner reported that 80% of the world's business ran on COBOL with over 200 billion lines of code in existence and with an estimated 5 billion lines of new code annually. So you could do a lot worse than learn COBOL to ensure you have a job for life.

The structure of a cobol program is summarised in the Mnemonic In Every Damn Program. Meaning that there is an:-

  • Identification Division giving information about the program
  • Environment Division describing the hardware
  • Data Division (In my day we used CODASYL now better known and newly re-invented as no-sql
  • Procedure Division 'Here be code'

Because of the legacy from punch cards (yes i used them as well) you always started the code by indenting 8 spaces in else some compilers would not recognise it (shades of Python where whitespace is significant).

It is of course a compiled language.

Where is it used. Governments, the Military Businesses of all sizes but usually the larger corporates so i suppose you could say everywhere and it is used to run governments, and the Military and business's. I believe the US's social welfare system runs on several million lines of Cobol written in the mid 60's. Experian a large UK based credit rating company uses it throughout there operation with interfaces to the web. Again in the UK most of the Building Societies and Banks run their core systems on it.

I could go on but i won't go and read about it. And by the way you can even get Object Oriented Cobol if you want


Ever use a credit card? Your transaction is probably touching COBOL code on the backend.


The Right Tool for the Right Job

Batch

The most salient point about COBOL is not its verboseness. It is that it was primarily designed, as a language, to do batch processing. Its I/O functionality in that regard is exceptionally efficient.

Even though it predates OOLs by a geological epoch, it is useful when speaking to a modern-day OO programmer to describe batch programming and COBOL from an OO point of view. Describing it like this, though historically incorrect, helps OO programmers conceptually.

To wit, the utterly fallacious, and yet very true:

COBOL has been "optimized" to iterate over large, nay, vast sequential "collections" (i.e. batches, also known as files). In fact, it is so optimized, that all the OO functionality has been stripped out, leaving a basic API that opens files, processes records, and closes files. In more complex version of the basic algorithm, multiple files are opened, their records matched to each other and manipulated to produce one or more output files (batches).

Where COBOL was co-opted for non-batch processes, for instance pseudo-conversational programming (backing up CICS "green" screens - aka BMS), it was least suitable. Not surprisingly, it is this functionality that has been most quickly replaced by GUI apps written in OOLs.

The Editor

The ISPF Editor on IBM mainframes has been optimized to handle the kind of coding COBOL requires. The basic unit of manipulation in the editor is the line. By default, vertical alignment is static and not flowed or shifted based on context; typing to the end of a line results in a keyboard lock. Because of this "conservation of vertical alignment," it is relatively easy to duplicate lines or blocks of lines, and align commands. With COBOL vertical alignment, as a legibility issue, is of greater importance than OO languages.

It is difficult to describe in a post, but having facility in both programming worlds and with both types of editors, I have to say that I would not want to edit COBOL in an IDE style editor, and I would not want to edit Java and C-family languages in an ISPF Editor. (I imagine you can plug-in an ISPF style editor into the various IDEs, but I haven't had the need to go there.)

N.B. OO COBOL has its uses, but not as a new way to re-engineer code that handles batch processing.


From my, although limited experience, COBOL is used a lot with IBM mainframe systems. So I believe in any situation where I/O is the emphasis (as mentioned above financial systems, insurance companies, government, etc) to the extent that a mainframe is needed or preferred and has been around for a while COBOL is probably used. I say been around for a while since in modern day I do not hear much of COBOL being a go to language.


Cobol is used primarily for financial processing. Any time banks, brokerage houses, credit card vendors, et al are doign business, there will be Cobol in the mix.


The ANSI standard for COBOL and some compilers have evolved considerably in the last 15 years and include libraries for creating and operating web frame contents and interactive sites, for data communications, for running on small processors and devices used in the hand. Well known versions are prefixed with characters like MF, CIS, RF, RM or the names of computer mainframe manufacturers old and new for versions in use primarily in Data Processing computer installations.


Today COBOL is used only because it used to be popular back in the day, and many old large businesses don't want to re-write their code into a modern language. (mainly cost + time)

The maximum length of a line of COBOL code is 72 characters long, why you ask? Because that's how many holes there were in punch cards. Even still the language hasn't been updated to allow for longer lines...

COBOL is an evil, ancient language that has little use any more, unless you are extending OLD programs...


COBOL is used for Business applications. Fortran is for scientific apps. C and C++ for hardware and firmware. Java for the web.

Then you may ask, why COBOL? Well, COBOL is about ten times easier to program for business than any of the other languages.

For example, to move a numeric to a report field and format it as a currency:

   MOVE VAL-A TO REPORT-FIELD-A.

There are no getter or setter methods needed. No need to program two methods for each MOVE statement.

And all the changing to string characters, and formating to $99,999.99 IS automatic. Try that in any of the other languages.

The dirty little secret is that COBOL is really a glorified ASSEMBLER MACRO language. There is even a compiler option to print the assembler code. That makes it easy to understand and powerful.

COBOL: Easy, quick, accurate, readable and maintainable. Everything a boss could ask for.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号