When I look at numerous websites. Some use object-oriented programming and imperative programming interchangeably whilst others say that they are different.
I would like to know what is the difference between object-oriented and imperative and how these paradigms differ. Or if their is no difference at all.
This is a tough one because the terms involved often mean different things to different people.
Roughly speaking (although some would say "strictly speaking") imperative is the opposite of declarative.
Strict OO proponents would likely say that OO is declarative. See the "Object Thinking" style of OO in David West's book of that name and this blog: http://www.yegor256.com/.
OO as it is commonly practiced often "devolves" (again, others will sharply disagree) into a very procedural and imperative style where you start telling the computer what to do rather than describing and modeling the real world (in some sense) with your objects.
(Here's a video that might be useful. It contrasts procedural programming and OO, and for our purposes here "procedural" is roughly a synonym for "imperative".)
I know that's not a great answer, but maybe it's useful.
Coming from top to down, there are two main subtypes of imperative languages.
Procedural languages (e.g. BASIC, FORTRAN) - where code and data are treated as completely separate, and have a simple code-operates-on-data paradigm.
Object-oriented (OO) languages - where data and code (in the form of methods) are bundled together into objects. In OO languages, additional structure is imposed to a greater or lesser degree by metadata (such as class information).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With