1

Say, I need to add two matrices. And, I want to solve this problem in the imperative paradigm.

  1. Imperative Programming
  2. Programming paradigm

From (1) know that

The canonical examples of imperative programming languages are Fortran and Algol. Others include Pascal, C, and Ada.

From (2), I see the following source code:

     result = []
     i = 0
 start:
     numPeople = length(people)
     if i >= numPeople goto finished
     p = people[i]
     nameLength = length(p.name)
     if nameLength <= 5 goto nextOne
     upperName = toUpper(p.name)
     addToList(result, upperName)
 nextOne:
     i = i + 1
     goto start
 finished:
     return sort(result)

Looking at the above code, my personal assumption is that Pascal, C, and Ada are not purely imperative languages. They are mainly structured languages that support imperative coding.

When I check the source code of FORTRAN 77, it seems to me that this is not much different than that of C. So, I am confused.

Which programming language can I use to achieve this?

Is Assembly Language imperative?

user366312
  • 16,949
  • 65
  • 235
  • 452
  • *A commonly used synonym to imperative programming is procedural programming.* By this definition, COBOL is an imperative language. To answer your question, almost any language can be used to write procedures. Java, as one example, can be written with a static main method calling other static methods. – Gilbert Le Blanc Oct 08 '20 at 20:41
  • *A commonly used synonym to imperative programming is procedural programming.* --- According to [this](https://cs.lmu.edu/~ray/notes/paradigms/) link, it seems not true. – user366312 Oct 08 '20 at 20:43
  • No, that link supports it. “ Procedural: Imperative programming with procedure calls”... and all modern languages support procedure calls. – Sneftel Oct 08 '20 at 20:57

1 Answers1

1

There’s no such thing as a “purely imperative language”. It’s not clear what that would even mean. Even assembly language includes addressing modes that are arguably function evaluation. When people talk about “imperative programming” they are contrasting with programming that is explicitly non-imperative, like pure functional programming. Virtually all programming that is done, including virtually all “procedural” and “object-oriented” programming, is imperative.

Sneftel
  • 40,271
  • 12
  • 71
  • 104