Lesson 13: Procedural vs. Object-Oriented
In our previous lesson we discussed some of the common built-in functionality for Strings. In this lesson we are going to discuss the differences between Imperative, Procedural, and Object-Oriented programming.
What is Imperative Programming?
Imperative programming is the type of programming you do when you essentially just have a list of commands that work from the top down to the bottom, and then the program is complete. This means that it doesn’t have any functions or the like.
This type of programming is very simplistic, which makes it very difficult, time-consuming, and inefficient to do complex programs. This type of programming is often done in languages which have higher level functions only for very simple programs (most of the examples we’ve done are imperative).
There are no real programming “languages” which are strictly imperative without being procedural as well.
What is Procedural Programming?
Procedural programming is the type of programming you do when you make use of procedures (yet another synonym for functions, processes, and subroutines). This type of programming is higher-level than imperative and allows you to accomplish more complex programs. However, even procedural programming isn’t very effective when it comes to very large programs.
FORTRAN and C are two popular procedural programming languages.
What is Object-Oriented Programming (OOP)?
Object-oriented programming is the type of programming in which you make use of objects. Objects are essentially meant to be representative of a potentially physical object. Objects contain their own data and methods (another synonym for functions).
Object-oriented programming allows for the rapid development of larger scale programs. Instead of having to have all the commands in one location, you can break the code down into separate objects. This allows for much more manageable and readable code, which in turn allows for more efficient programming.
C++, Java, and PHP are popular object-oriented programming languages. You could consider Javascript to be an OOP language as well, though it doesn’t make use of the typical “class” as others do.
Which is Best?
Most computer programmers would immediately shout out “Object-oriented programming” when asked this question. However, a better answer is “It depends.”
As each language type progresses and becomes higher-level than the previous, there is also an inevitable addition of complexity as well as resource overhead (how much computer power the program needs to run).
Due to this addition of complexity and overhead, it is important to work with what is best. For example, the programs that power digital watches have to be very efficient because they run on very few resources. These would simply be too bogged down to work if it was done in an OO approach.
Likewise, say I wanted to test some input/output for a certain equation I’m considering using in a game. I could add a couple classes and functions to my game to force it to display this for me graphically, even though I’m going to just take it out a few minutes later. What is easier (and I often do), is just create a quick new program which just does this work for me in as simple terms as possible, and just outputs the results in text. I could do this in 5 minutes, whereas with the OO method it could take me an hour.
Now, I’m not saying OOP isn’t great. Quite the contrary, I love object-oriented programming and nearly everything substantial that I do is done in this manner. However, it’s important to realize that you shouldn’t needlessly over-complicate a very simple program.
OOP programs are best done for programs that meet one or more of these criteria:
- Are fairly large (more than a couple hundred lines of code) and will be run on general computers.
- Are fairly complex (more than just output simple data).
- Will be maintained and added to over a period of time.
There are other criteria and sometimes it’s a toss up. Most of the programs I do are OOP, but only if they warrant the extra complexity.
In this lesson we described and compared imperative, procedural, and object-oriented programming. In our previous lessons we have essentially covered all of the main points of procedural programming. In our next lesson we will begin to dive into object-oriented programming with the introduction of objects and classes.




