DEV Community

Discussion on: Why doesn't/didn't C have classes?

Collapse
 
ahferroin7 profile image
Austin S. Hemmelgarn

Historically? C originated before OOP became a big enough mainstream thing to warrant major languages being built for OOP.

In modern times? Because it doesn’t need them. A class is just a structure and a group of associated functions. In other words, a struct with a bunch of function pointers in it. In fact, many big C projects do use OOP principles in their design just fine without any formal ‘class’ syntax. See the Linux kernel for a good example, a lot of the driver APIs are built in an OO manner.

It’s important to remember also that OOP is not the panacea that many make it out to be, it brings along plenty of it’s own issues, and should only be used when you either have no other option (because of the language itself not allowing you to do it any other way) or have properly evaluated it against other paradigms (a lot of things I see OOP designs get used for don’t need it at all and would be both faster and more memory efficient as simple procedural code).