Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am trying to expand my understanding the history and involvement of OOP.

Recently I have been looking into OOP in ANSI-C, which is described in Object-Oriented Programming With ANSI-C by Axel Schreiner. For a freely available PDF version visit http://www.cs.rit.edu/~ats/books/ooc.pdf.

A slightly different approach is used in the part of the Linux kernel dealing with file systems, visit http://lwn.net/Articles/444910/ for more info.

However, the common idea is to put function pointers in a struct in order to 'emulate' a class.

Historical context

From Wikipedia.org/wiki/Object-oriented_programming#History

Objects as a formal concept in programming were introduced in the 1960s in Simula 67

While Wikipedia.org/wiki/C_programming#K.26R_C states that

In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language.

I am curious to know whether this 'feature' enabling OOP in ANSI-C was a design choice or merely an 'undocumented feature' following from the design of C. The chronology seem to suggests that K&R must have been well aware of OOP.

Are there any sources where K&R have described or commented on this feature?

share|improve this question
3  
You had me until the last sentence. All you're really looking for are references to whether or no K&R had awareness of OOP? That you can put pointers into a struct is self-evident; it's part of the language design, and is not undocumented. I have a thick, theoretical book about Object Orientation at home that was written before OO was fully baked, and C predates that book, so I disagree with your assertion that K&R had OO in mind. – Robert Harvey Apr 29 at 14:30
But perhaps its a question of terms. Objects alone do not constitute object-oriented programming, as any veteran VB6 programmer will attest. – Robert Harvey Apr 29 at 14:43
1  
OO has been baking for a long time, it would be haphazard to call it done even now; 20 years from now there will be some new form of "OO" with books and languages and developers wondering if C# meant to be OO, or it was a happenstance of the way classes were implemented.. Though I don't suspect K&R had any intent towards OO when they made what was meant to be a portable assembler – Jimmy Hoffa Apr 29 at 15:09

closed as not a real question by JeffO, Robert Harvey, Kilian Foth, Bart van Ingen Schenau, GlenH7 Apr 29 at 15:45

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.

1 Answer

Short version: C was before OOP's time, so it wasn't a design choice.

Object oriented programming, OOP, is an old idea. But as a cultural phenomenon it only took off in the 80's and 90's. As someone born in the 80's I'd say it was C++ that launched the hype, set the trend, started the buzzword, or otherwise got OOP off the ground. That turned it from an academic pet project to something businesses looked for on resumes. And that's the sort of statement out of ignorance that will get the grey-beards to come out of the woodwork claiming that it was really Delphi or some other language that was the igniter. And they'll be countered by the historians that can show some Renaissance Italian first had the concept of oriented objects. And the whole thing ends in flames. But trust me, OOP really took off well after C was designed.

History aside, C is a low-level language and as such it can implement nearly anything that the higher level languages take for granted. You can implement a system that acts like C++'s inheritance. You can implement a system that acts like Java's reflection. Whatever crazy design patterns these young whippersnappers come up with in their fancy dancy new languages will probably be able to be implemented in C. Whether or not it's a good idea, is another issue.

share|improve this answer
2  
AFAIK, SmallTalk has the best claim to most accepted OO language prior to C++. But my beard isn't grey enough to really weigh in on that discourse. – GlenH7 Apr 29 at 15:55
Thank you for your answer. But as a cultural phenomenon it only took off in the 80's and 90's. was really what I was looking for. – user118058 Apr 30 at 15:23

Not the answer you're looking for? Browse other questions tagged or ask your own question.