Programming Paradigms: Imperative Programming

Programming Paradigms: Imperative Programming


In our last video, we found out that an
an Imperative programming language is used to produce the final result of our
declarative instructions. Now let’s take a closer look at the Imperative paradigm. Imperative programming doesn’t need to rely on Declarative languages in order
to create programs. And while Imperative languages often work with Declarative languages, Imperative languages can be, and are often, used independently. The essential aspects of imperative programming are – sequenced instructions and mutable data. A sequence of instructions represents the tasks that a program needs to carry out in order to do whatever it was designed to do. As with declarative programming, the instructions are represented as lines of code. The lines of code are executed one at a time from top to bottom. But the difference with imperative programming is the ability to apply logic and decision-making within these instructions. In imperative programming, this sequence of instructions is referred to as an algorithm. An algorithm often uses data as part of its execution. Data that can change over the duration of a program is called mutable data. The values of the data tell us the current state of a program. And as the data changes over the program duration, the state can also change. Data is stored in named containers called
variables. Let’s go back to a restaurant analogy again. The state of our sandwich
changes over time as data – the ingredients – are added and mixed. The initial state might be an empty plate The final state is a prepared sandwich
ready to be eaten. And this is all done according to the sequenced instructions –
the recipe – and the mutable data – which is the composition of the sandwich. So what we just learned? Well, we discovered that the core aspects of Imperative programming are – sequenced instructions in the form of algorithms and mutable data. That is data that can change over the course of the running of a program Next, we look at how imperative programming languages make decisions

Leave a Reply

Your email address will not be published. Required fields are marked *