Programming Paradigms: Imperative Programming.

Programming Paradigms: Imperative Programming.


In our last video, we found out that 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 the carat of 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 represent the tasks that
the problem 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. What have we just learned. Well we discovered that
the core aspects of imperative programming are; sequenced instructions
in the form of algorithms and immutable data that is data that can change over
the course of the running of a program next we look at how imperative
programming languages will make decisions

Leave a Reply

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