The focus of procedural programming is to break down a programming task into a collection of variables, data structures, and subroutines, whereas in object-oriented programming it is to break down a programming task into objects that expose behavior (methods) and data (members or attributes) using interfaces. The most important distinction is that while procedural programming uses procedures to operate on data structures, object-oriented programming bundles the two together, so an “object”, which is an instance of a class, operates on its “own” data structure.
The principles of modularity and code reuse in practical functional languages are fundamentally the same as in procedural languages, since they both stem from structured programming. So for example:
- Procedures correspond to functions. Both allow the reuse of the same code in various parts of the programs, and at various points of its execution.
- By the same token, procedure calls correspond to function application.
- Functions and their invocations are modularly separated from each other in the same manner, by the use of function arguments, return values and variable scopes.
The main difference between the styles is that functional programming languages remove or at least deemphasize the imperative elements of procedural programming. The feature set of functional languages is therefore designed to support writing programs as much as possible in terms of pure functions:
Many functional languages, however, are in fact impurely functional and offer imperative/procedural constructs that allow the programmer to write programs in procedural style, or in a combination of both styles. It is common for input/output code in functional languages to be written in a procedural style.
The interesting bit for me are how in a way, functional programming is an evolution of procedural programming. And in an impure functional language like Clojure, it really is that Clojure is a procedural language with additional features (like closures, first class functions, hof, macros, etc.) and an emphasis on pure functions and immutable data.
And also how I feel people who favour procedural languages such as C, Pascal, Go, Rust?, etc. tend to not like OO, in a similar vein and with same criticism as those who prefer functional programming, mostly that bundling methods and data they operate over instead of having functions (or procedures) operate over one or more data structures is just limiting.