I can’t really wrap my head around OOP. Like I understand an array and a function and a variable, but I don’t understand what an object is. Why can’t we just use functions and variables everytime we need information or code to run? I code in Python and JS mainly, so objects are truly the most important thing, but I don’t really get it. Also, isn’t every program object orientated? Even C, does it not fit the definitions? If so, how is it any different from C++?
In: Technology
Object oriented programming (OOP) is an approach to programming that tries to mirror the way humans perceive the world around us – as things (objects) that have properties and can do things or have things done to them. At the core of it it’s as simple as that.
Using this approach to sort out how code should be grouped allows programmers to build very large and complex systems that can not only compose functions into more complex functions but can also reason about the entities those functions are tied to.
There’s usually more to it than that, but that will depend on what language you use and what philosophy you buy into. C++, Java and C# strongly encourage you to use class-based OOP with polymorphism, inheritance, encapsulation and other shenanigans that you’ll likely learn about in college. JS and Python use classes and objects but you won’t find traditional OOP techniques being used with them frequently. The language is only ever a part of the equation. Want to pull it off in C? Give [Object-oriented Programming with Ansi-C](http://www.freetechbooks.com/object-oriented-programming-with-ansi-c-t551.html) a read.
Latest Answers