REBOL for COBOL programmers

Go to table of contents Go to feedback page

The same, but different

Date written: February 5, 2015
Date revised:
Date reviewed:

This is some obvious points about programming languages that it might be helpful to remember.

One never knows what little bit of information will trigger a sudden understanding, so these points are offered in case they are helpful.

COBOL was popular in the days when what computers did was referred to as "data processing." Data was obtained from screens on terminals, it resided in fixed-format files or database management systems, It was "processed" in large volumes, it was printed on large amounts of paper. Also, computers were smaller and slower. COBOL was designed for that environment. Data was brought into the program a record at a time because there was not enough memory to bring in a whole file. The "01" record area was used to define fixed-format records like punch cards. Printing was confined to lines of 132 characters at six or eight lines per inch.

REBOL does not come from that era, so it is not going to be good at doing that stuff. So don't look for that capability. If you want to do that stuff, you will have to struggle. It can be done, but not always easily. That can be a sticking point of you think, "How can I define a fixed-format record. How can I zero-suppress a number and right justify it at position 57 in a 132-character print line?" The answer might be, you can't. Someone who has not seen COBOL might ask, "And why would you even want to?" It's a different world, so watch for yourself trying to muscle new things into the old paradigms.

So think about the things you do with a computer program and how you write the program in COBOL. You have to get data into a program. If it comes from a person, it comes from a screen defined in the SCREEN SECTION. If it comes from a flat file, you read the file one line at a time. If it comes from an indexed file or a relative file, you have those native structures available. If it comes from a database management system, you have some interface to that. Once the data is in memory, you have to define its format in a memory area. You will need other memory areas set up in advance (at compile time) for temporary storage. Some of those memory areas will be structured, like a record area. Others will be independent items. Others will be one thing after another (OCCURS).

In REBOL you are going to do similar things. Not exactly the same, perhaps, because if you had to do exactly the same things it might be too much of a struggle to use REBOL. COBOL still is an active product, and it can do anything required of a computer these days. But anyway, if you have to get data from a person, you can get it from a window defined in VID. If your data is in a flat file, the usual method is to read it all into memory at one time because computers now have enough memory to do that. REBOL does not have its own native file system for indexed or relative files, but it does have the ability to connect to database management systems with ODBC. REBOL is written for data that is NOT in a fixed format. If you have fixed-format data, you will have to work with that data as a big string, and use the various series functions to extract fixed pieces of it. However, if you can get your data in one of REBOL's known formats, like string, money, decimal, date, then you have a lot more power than you would have in COBOL because REBOL recognizes those formats. For WORKING-STORAGE items, that is, "variables" for temporary storage, you assign words to refer to values, and if you have data that is one thing after another (like OCCURS), you can put that stuff into a block and use the various series functions to work on it.

In other words, try to think of REBOL as what it is, look at the problem you want to solve, decide if there is a good match, and realize that there might NOT be a good match. REBOL can get data from windows, from text files by reading the whole file at once, and from databases by using ODBC. It works best on data that is recognized as native data types. It's not so good at printing, but it is good at making web pages. If your problem fits into that, REBOL can help.