Live data from Hacker News

Classes Considered Harmful [pdf]

web.cecs.pdx.edu

11–20 of 129 posts

Re: Classes Considered Harmful [pdf]

#11

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…

Plato would argue that there is such a thing as a chair. In fact, he'd argue there is an ideal of a chair which all chairs strive to achieve. The idea of Platonic Form (and the allegory of the cave) are very relevant to programming because western philosophy has shaped how we view the world, and thus how we program. That being said, I don't think most people I know are familiar with platonic forms, or the allegory of the cave, so perhaps a programming language based around that idea isn't very strong.

In my experience, the vast majority of people who program are doing so not as their full-time job, but out of necessity. This includes scientists, analysts, academics, accountants, etc. If I had to guess, these individuals write way more code as a whole than full-time developers. Adherence to the ideals object-oriented programming is extremely uncommon from what I've seen. I see a lot of copy-and-pasted code in one gigantic class, and a mish-mash of programming styles from wherever they stole their code from. Testing is completely unknown to them.

I think a lot of these considered harmful discussions are carried along by the impact GOTO Considered Harmful had on the programming world, but I don't think they actually address concerns that affect the vast majority of people writing code. They are of obvious interest to Hacker News readers because people here are trying to maximize their productivity and are extremely tech savvy already, but if you are trying to write a language which minimizes the impact that mistakes make on the world I think you should look at where the vast majority of code is being written. The biggest players already have the knowledge to program effectively, it's about creating ways of coding that make good programming more intuitive, and I don't think OO is the problem there.

Re: Classes Considered Harmful [pdf]

#13
post #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 reminded me of Bob Martin on "object oriented C" - https://youtu.be/t86v3N4OshQ?t=1120

Re: Classes Considered Harmful [pdf]

#14
post #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…

I think that inheritance can have a place. It makes a lot of sense when writing //small variations// on an otherwise rich inner class. Small variations might include layering on a different input or output mechanism, or possibly handling 'extra' data that the object stores but previously did not modify.

Re: Classes Considered Harmful [pdf]

#15

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…

I, being one of the few people on HN that like OOP, dont find anything you mentioned that organized, clean or simplified like oop.

No copy is available in rust. Overloading a generic function seems like we are talking about interfaces. A preprocessor step again is similar to rust.

But only the second has anything to do with writing in oop

Re: Classes Considered Harmful [pdf]

#18
The premise is the introduction is wrong.

"so before we have written a single program in our language, before we know whether shared behaviour will be important in the applications that will be written in it"

read the POODR book, or watch this

https://youtu.be/OMPfEXIlTVE?list=PL5s3t9kPeAN6aDxaSywIbeFJO...

it explains how shared behavior works without code duplication and why people tend to mess it up.

Re: Classes Considered Harmful [pdf]

#19

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…

Well I'm a lover of scala and I dislike deep inheritence.

That's actually why I love the model of golang and rust. They model the real world more closely.

When you look at a desk, how do you define it?

Well if it's a wooden desk it's actually the type Wood and it porbably has 4 table legs and probably a desk size of x*x. So this is way easier to represent with Subtyping, since a Desk can be made of wooden, but doesn't need to, so with structual inheritance that would mean a lot of boilerplate if you would need to define all type's of desks while in rust you would just add the impl trait to any of the base struct's, etc.

Also deep inheritance can be nasty to debug, even Scala will probably move to a more flat level in their collections library.

Re: Classes Considered Harmful [pdf]

#20
post #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…

Eh, inheritance is a subset of composition. One of the issues is that the subset is ambiguous and different languages create a different contract for it, but there's nothing theoretically wrong with inheritance.
Post reply on HN