Live data from Hacker News

Object-Oriented Programming in C (2019) [pdf]

state-machine.com

81–90 of 95 posts

Re: Object-Oriented Programming in C (2019) [pdf]

#81

The paper does not specify message passing or reflection, both of which are essential to OOP. I think OOP lost its way as soon as C++ reinterpreted it in terms of only encapsulation, inheritance, and polymorphism. According to Alan Kay (one of the creators of Smalltalk, the first OOP), message passing is more important to OOP than inheritance. If you listen to his old speeches, what he is describing sounds a lot more…

The first OOP language was Simula. Smalltalk and C++ both adopted ideas from Simula, independently. Bjarne Stroustrup was a student in Nygaard's lab, so it is absurd to suggest that C++ "reinterpreted" something. If anything, C++'s is the more pure expression of the original idea.

Alan Kay gets credit for the name "object-oriented", not the concept. His own definition has varied radically over the years, insisting only lately on any importance of message passing, as such. Smalltalk-72 was not OO. Smalltalk gained OO features over the time from 1972 to 1980. (Message passing has anyway always been isomorphic to function calls.)

Reflection was never described as essential to OOP. It is a feature of many languages, equally useful in all.

Re: Object-Oriented Programming in C (2019) [pdf]

#82
post #80
post #38

Earlier quoted context omitted.

https://microsoft.github.io/microsoft-ui-xaml > WinUI is powered by a highly optimized C++ core that delivers blistering performance, long battery life, and responsive interactivity that professional developers demand. Its lower system utilization allows it to run on a wider range of hardware, ensuring your sophisticated workloads run with ease. Apparently Microsoft does care about OOP in C++. As does Apple, https://…

I wasted time looking in those links. The WinUI page does not mention base classes (or prototypes), inheritance, or any sort of runtime binding. A "highly-optimized C++ core", in particular, does not imply OO. The std::ranges view_interface template is not OO; it uses concrete inheritance purely as a notational convenience. Likewise the others, with one exception. The Apple driverkit page does mention base classes. F…

WinUI uses COM/WinRT, COM is an OOP ABI, and WinRT is basically COM v2, with TLB libraries replaced with .NET type system and types must support IInspectable in addition to IUnknown. Are you going to argue .NET isn't OOP?

As for the rest, OOP doesn't imply inheritance, BETA and SELF are good examples of OOP without inheritance.

Re: Object-Oriented Programming in C (2019) [pdf]

#83

Earlier quoted context omitted.

Really? Linux kernel uses extensive OOP/C.

I haven't looked at how the kernel is written. But Linus has a problem using a more powerful language - if Linux adopted one just for OOP, then it will become impossible to hold back contributors from using every last feature of that language. I can understand the reluctance to deal with that.

Well he already has plenty of GCC extensions to chose from.

Re: Object-Oriented Programming in C (2019) [pdf]

#84
post #37

Earlier quoted context omitted.

This pattern goes back to pre-Version-7 UNIX kernels, with only minor syntactic updates. That it long predates OO demonstrates it is not OO. That does not make it any less effective, or less useful.

It does not predate OO. The first OO language, SIMULA-67 became public knowledge before the start of even the PDP-7 UNIX, which is extremely unlikely to have used such a pattern, which probably appeared only when UNIX was rewritten in C, starting in 1973. Even Smalltalk-72 predated the C-version of UNIX. However, it is likely that this pattern was chosen in UNIX independently of the previous OO languages.

Also what many usually forget, C++ was also born on the same building as UNIX.

Hence why C++ got so fast adopted across UNIXes and C compiler vendors on other platforms.

Re: Object-Oriented Programming in C (2019) [pdf]

#85

Earlier quoted context omitted.

There's usually a formal definition of something and a common definition of something, and most languages that get traction follow the common definition. For example, the formal definition of the Liskov Substitution Principal: > Let ϕ(x) be a property provable about objects x of type T. Then ϕ(y) should be true for objects y of type S where S is a subtype of T. This doesn't allow any change in behavior when subclassi…

> This doesn't allow any change in behavior when subclassing. Generally correct, but that's why you should only be "subclassing" abstract interfaces in the first place. Subclassing concrete object methods is a footgun, precisely because you have no way of enforcing which of these "properties" any code will actually be relying on, either at any given point in time or in the future. (Including code that's itself part o…

I don't disagree at all. I tend to advocate for very shallow hierarchies in the 5-10% of code that I think benefits from an object oriented style.

But the point of the comment is the formal/common divide rather than the specific example.

Re: Object-Oriented Programming in C (2019) [pdf]

#87
post #82
post #80

Earlier quoted context omitted.

I wasted time looking in those links. The WinUI page does not mention base classes (or prototypes), inheritance, or any sort of runtime binding. A "highly-optimized C++ core", in particular, does not imply OO. The std::ranges view_interface template is not OO; it uses concrete inheritance purely as a notational convenience. Likewise the others, with one exception. The Apple driverkit page does mention base classes. F…

WinUI uses COM/WinRT, COM is an OOP ABI, and WinRT is basically COM v2, with TLB libraries replaced with .NET type system and types must support IInspectable in addition to IUnknown. Are you going to argue .NET isn't OOP? As for the rest, OOP doesn't imply inheritance, BETA and SELF are good examples of OOP without inheritance.

Nobody uses Beta or Self. And, no matter how much alphabet soup MS throws at its long, rolling UI debacle, it demonstrates nothing about general programmers' current level of interest in OO.

Re: Object-Oriented Programming in C (2019) [pdf]

#88
post #27

Earlier quoted context omitted.

... is not, in fact, OO at all, by any meaningful definition. 1..4 is just programming. People have done it since long before there was any "OO" buzzword. There are formal definitions of OO. The above satisfy exactly none of them.

There's usually a formal definition of something and a common definition of something, and most languages that get traction follow the common definition. For example, the formal definition of the Liskov Substitution Principal: > Let ϕ(x) be a property provable about objects x of type T. Then ϕ(y) should be true for objects y of type S where S is a subtype of T. This doesn't allow any change in behavior when subclassi…

When there are, as in the case of OO, multiple formal definitions, it is because there is no consistent "common definition" to compare any given example against, and relying on anybody's "common definition" means there is no basis for discussion.

Failing to match any of the formal definitions, as here, is a sure way to fail to reach a level where discussion is worthwhile. So, it is not, and I leave it here.

Re: Object-Oriented Programming in C (2019) [pdf]

#89
post #84

Earlier quoted context omitted.

It does not predate OO. The first OO language, SIMULA-67 became public knowledge before the start of even the PDP-7 UNIX, which is extremely unlikely to have used such a pattern, which probably appeared only when UNIX was rewritten in C, starting in 1973. Even Smalltalk-72 predated the C-version of UNIX. However, it is likely that this pattern was chosen in UNIX independently of the previous OO languages.

Also what many usually forget, C++ was also born on the same building as UNIX. Hence why C++ got so fast adopted across UNIXes and C compiler vendors on other platforms.

That was not the reason.

But it was the reason that C, as standardized, adopted several C++ innovations first.

Re: Object-Oriented Programming in C (2019) [pdf]

#90
post #89
post #84

Earlier quoted context omitted.

Also what many usually forget, C++ was also born on the same building as UNIX. Hence why C++ got so fast adopted across UNIXes and C compiler vendors on other platforms.

That was not the reason. But it was the reason that C, as standardized, adopted several C++ innovations first.

It was definitly the reason, by 1992 it was impossible to buy a C compiler that also did not had a C++ one in the box.

Also why Apple moved from Object Pascal to C++ on MPW.

Post reply on HN