Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Unless you are the most fervent single-dispatch OO cultist, there is no expectation that a function F(FILE, DIR) need to belong to a specific object (otherwise you could literally not have anything but unary function). And with multiple dispatch (a feature for example of CLOS), it can in practice belong to both).

FILE is definitely OO object flavored: it is an opaque handle that encapsulates state and behavior through a generic runtime-dispatched interface. The biggest issue is that it is not open to user extension (except for the nonstandard fopencookie).

As an aside, you can of course have the moral equivalent of base classes in C. See for example the POSIX sockaddr class "hierarchy".

edit: to be clear, I'm in no way claiming that OO invented this stuff. I'm sure people where building the moral equivalent of vtables before Simula. OO just gave us a language to discuss this sort of features, which is useful. It also came with a lot of philosophical baggage and design guidelines (Everything is an object!), which IMHO are less so.



I suspect that, rather than give us a language to discuss these features, OO hijacked the programmer jargon with its own terminology and heavily marketed it to become the default.

To the point where FILE is called an object, even though it's just an opaque pointer hiding the implementation. It can be phrased in OO terms but this irks me because it sounds as if OO invented it (I know you're not claiming this), and anything non-OO ("procedural, yuck") is bad. Which leads to the "everything must be an object" mindset that so many programmers exhibit today.

Which is why it bothers me to see "OOP with ANSI C". To me, those are just more or less normal patterns in C, why call it OOP when it's normal procedural code :) that's just me. Rant over.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: