I'm currently doing a lot of programming in C. I am an undergrad student. The first language we learned was Java and now I'm learning C.
In Java, we create a class and it's field variables (state) and a bunch of methods (or behaviours) for said instance of an object.
in C we have something very similar, we have a struct which contains our object (I guess, i consider this to be its 'state' or field variable or 'attrubutes') and we have functions that the object can be passed to to modify its behaviour.
In C I can achieve the same kind of 'encapsulation' and a form of 'inheritance' via data hiding or sharing via header files.
While I completely understand that Java and C go about achieving this in very different ways, I am confused as to why C is not really considered OOP but rather procedural.
I feel that I'm missing something important. Maybe I'm unclear of what procedural programming is? Or I'm just plan wrong or using C completely wrong. Would be good to know.
EDIT:
Rather than typing to each poster, I'll just add it here. Thank you all so much, I honestly thought I was missing some important concept. The posts you all made make sense and I feel like I have a better understanding. Thank you all very much for answering so quickly and taking the time to reply to this post.
Thanks again I really appreciate it!
You can do object-oriented programming in a procedural language (or almost any language), it's just harder, because you have to do more of the plumbing yourself.
Java is considered an OOP language (by most people) because it provides direct support for OOP concepts like encapsulation, inheritance, and polymorphism.
C isn't considered an OOP language because while you can do encapsulation, inheritance, and polymorphism with it, the language doesn't provide constructs to help you do so.
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