Live data from Hacker News

Classes Considered Harmful [pdf]

web.cecs.pdx.edu

1–10 of 129 posts

Re: Classes Considered Harmful [pdf]

#2
Having used C++, Java, C#, Python, Ruby, NewtonScript, Dylan, Scheme, and various other languages "in anger" I can say that in general I agree with the author's frustrations. My favorite (as in most flexible, least boilerplate) approaches to object-oriented programming have been:

- NewtonScript's frames with prototype inheritance. Allows "objects" to consist of very small data structures that point to ROM objects and only use RAM for slots that actually vary, using copy-on-write. The actual implementation had some issues and of course that platform is dead, but the concept was great.

- Dylan's adaptation of generic functions, with multiple inheritance. There are classes but they don't have methods "inside" them. The class hierarchy describes the dispatch for the generic functions. Allows some really nice styles of programming (dispatching on multiple parameters) that are perhaps possible but absolutely hideous in C++.

- Qt's method. The use of a separate preprocessor step and generated code for dispatch was a hack to get around limitations of C++, but although you don't want to look too closely at that generated code if you value your sanity, at a practical level it works pretty well.

In summary, I'd just add that it is a deep and abiding shame of my industry that people wind up in silos learning one model of object-oriented programming and never consider other models that are different and can be cleaner and far simpler to think about.

Re: Classes Considered Harmful [pdf]

#3
For what it's worth, the footer reads, "Submission to NOOL / 2015/10/12".

NOOL seems to stand for "New Object-Oriented Languages", a workshop of the ACM SIGPLAN conference on Systems, Programming, Languages and Applications: Software for Humanity (SPLASH).

http://2016.splashcon.org/home

http://2016.splashcon.org/track/nool2016

Re: Classes Considered Harmful [pdf]

#4
There seems to be a common fixation on objects "modeling the real world" with the counter argument for classes being that they don't model the real world. True, there isn't a physical chair class in real life(philosophically, there aren't even chairs), but there is a common abstract idea of what would describe the function and attributes of a chair. Granted, it differs a little from person to person, but objects themselves are all different in some way. As far as I can tell, in most OO languages, there's no reason why classes must use inheritance, though I am certainly willing to be schooled in that regard.

Re: Classes Considered Harmful [pdf]

#6
Although he spends quite some time on exploring the alternatives, the only reason the author specifically states where classes are harmful is because they are premature optimization. That's it?

I guess "Classes considered a PITA" just didn't make a good title.

Re: Classes Considered Harmful [pdf]

#7
post #3

For what it's worth, the footer reads, "Submission to NOOL / 2015/10/12". NOOL seems to stand for "New Object-Oriented Languages", a workshop of the ACM SIGPLAN conference on Systems, Programming, Languages and Applications: Software for Humanity (SPLASH). http://2016.splashcon.org/home http://2016.splashcon.org/track/nool2016

And the paper does appear in the program of NOOL 2015(!), so it has been accepted.

http://2015.splashcon.org/track/nool2015#program

Re: Classes Considered Harmful [pdf]

#8
Most eye-opening moment in my software engineering class was when the professor asked, of four core OO features (don't recall the precise list now), which was superfluous.

The answer, of course, was inheritance, and once the question was asked it wasn't hard to see how much better life could be without it. I've been on an anti-inheritance kick ever since.

Now I see how much better life can be without OO entirely, but that's a different discussion.

Re: Classes Considered Harmful [pdf]

#9

There seems to be a common fixation on objects "modeling the real world" with the counter argument for classes being that they don't model the real world. True, there isn't a physical chair class in real life(philosophically, there aren't even chairs), but there is a common abstract idea of what would describe the function and attributes of a chair. Granted, it differs a little from person to person, but objects them…

> As far as I can tell, in most OO languages, there's no reason why classes must use inheritance, though I am certainly willing to be schooled in that regard.

That there is no precise definition of what a class is and isn't, and that the traditional notion of a class conflates several independent concepts, is precisely the big criticism! To my mind "traditional classes" means inheritance, and recent languages without inheritance (Rust or Go) have tended to not use the term "class".

Post reply on HN