10 Things I Hate About You, COBOL

Actually, I don't hate COBOL. I just couldn't resist the blog title. But there are some things about it that I find annoying.

1. All Variables are Global

Global variables make it difficult to track down bugs; when a variable can be changed at any point in the code it's hard to tell what happened. In COBOL, every variable is a global variable.

2. No Parameter Passing

In most languages, you can pass parameters to subroutines. But you can't do that in COBOL. So how do you move data to a subroutine for processing in COBOL? You put it in … global variables.

3. No Returning Values

Just like you can’t pass values to a subroutine, you can’t return values from one either. You can, however, store the results in…global variables.

4. Verbosity

They say it was designed so non-technical people could read it. Problem is, non-technical people don't read it.
I've worked in three shops that used COBOL. None of them had non-programmers looking over COBOL code. So, to make things easier for these people, they made it harder for programmers. They optimized for the wrong user.

5. PERFORM is overloaded

The same keyword used to call a subroutine is also used to create a Loop.

6. Working Storage

All variables in a COBOL program are declared in the WORKING-STORAGE section. So, when you're working on a piece of code and need to see how a variable is declared you have to go to the working storage section, find it, and then go back to your code. This becomes a time-consuming process. Especially with large programs that have hundreds of variables.

7. Levels

Levels end up allowing multiple variables to point to the same piece of data. Changing one changes the others. While this can be helpful, it makes it difficult to track down bugs.

8. String Handling

Not having a variable length string type makes it hard to work with strings in COBOL.

9. Ending IF Statements with Periods

COBOL 85 added END-IF, but I still run into a lot of code that uses periods. This is especially annoying when there is a large block of code with multiple IF statements.

10. NEXT SENTENCE and CONTINUE

I find it hard to figure out where a NEXT SENTENCE or CONTINUE will send control - especially inside of IF statements that use periods.

Comments

Popular posts from this blog

Restoring Color Icons in Gimp 2.10

My Nullable DateTime Picker

PowerBuilder and SQL Server: Tips On Working Together