Thoughts of an IT professional

August 16, 2006

C programming is not OOP

Filed under: Development

You are probably familiar to the chorus of C programmers saying "We were doing OOP in C and we were doing a good job of it", if you are not here is an article about how to program in C using OOP concepts. The article addresses only encapsulation, inheritance and polymorphism are left to better-suited languages like Smalltalk.
They probably did use some OOP constructs in C. However, what they were doing was a process which could not scale. The object-oriented C that was produced was a twisted mangle of code that had a pretty high entry barrier: it was very complex and, I would assume, poorly documented. I assume that it was poorly documented because it was some sort of a hack which was known only among a small group of luminaries at a time when documentation was not considered crucial to the development process. As I said, this process could not scale, it is obvious. Implementing it across a large developer base would have required error-proof coding practices, it would have required strict enforcementes of these practices, and this would have been very costly. At the end of it the developer would have been turned into a human compiler who would have spent most of its time making sure that is procedural code was also object-oriented. The sheer complexity of this task would have prevented mass adoption and ultimately stop the "object-oriented" C’s growth: how could you have implemented more exotic uses of OOP if you had to constantly juggle functions passed as pointers, crazy typedefs and so on? Another roadblock to its success would have been the various conflicts that would have emerged between various groups if this object-oriented C was successful. Various OOP frameworks would have emerged each with its vocal set of fans and dissenters.
Then Bjarne Stroustrup came along with C++. C++ put the house in order and formalized the language to the extent that development could scale meaningfully. The OOP hack known among 5-10 programmers in a team was suddenly released to the world at large. The workforce could adapt to a standard that was not going to change according to the moods of some gurus. This was a process that could scale and that scaled very well: dozens of thousands of developers used C++ for over a decade developing very complex systems.
The group claiming that they were developing in "object-oriented" C suffer from seeing the world thru glasses tinted according to their beliefs. I get the same feeling anytime I hear people abusing the buzzword du jour: "We were doing SOA for years". Not really, sending messages over a CORBA-talking pipe is not SOA.