Wednesday, January 31, 2024

Programming Paradigms

I thought I had a handle on the programming paradigms such as imperative programming, procedural programming, structured programming, object oriented programming, etc. I thought they were categories of coding style made possible with a language’s feature-set. For example, RPG 4 and Pascal allow for passing arguments to procedures while COBOL and RPG 3 do not. That difference made me think that RPG 3 and COBOL fall into the imperative programming paradigm and Pascal and RPG 4 are in the procedural programming paradigm. ChatGPT convinced me that I’m totally wrong. After a hundred ChatGPT queries, I know what ChatGPT thinks and I’m not happy with it.

ChatGPT tells me that procedural programming paradigm is totally encompassed by the imperative programming paradigm. I can see why this is true, because if/then/else falls into the imperative paradigm so every language that has if/then/else is imperative. However, having languages fall into a trail of paradigms where each newer paradigm can be a subset of its parent makes language categorization by paradigms rather useless.

ChatGPT’s answers led me back in time to the 1969 paper by Edsger Dijkstra, “GOTO Statement Considered Harmful” and to 1973’s "Global Variable Considered Harmful” by Wulf and Shaw. GOTO considered harmful appeared to me to have been the justification for the adoption of languages that have subroutines like COBOL and RPG 3. Global Variable considered Harmful appeared to me to have been the justification for the adoption of C and later, RPG 4, and languages which allow variables to be declared that are scoped only to methods. No, that would be too easy. There was further disappointment when ChatGPT identified a category error in my assumptions about programming paradigms, Structured Programming is not a paradigm. ChatGPT tells me that Structured Programming is a broader category. The first six words in the wikipedia article on structured programming are, "Structured programming is a programming paradigm” but, wikipedia doesn’t provide evidence and it hardly mentions structured programming in the article on programming paradigms.

The disappointment I found in programming paradigms is that the overlapping of paradigm definitions mean that COBOL and C are both classified as procedural and iterative. If a language with lexical scope and procedures that accept arguments falls into the same paradigm as a language that lacks those features then paradigms are useless, they are distinctions without differences.