r/ProgrammerHumor • • May 16 '21

StackOverflow in a nutshell.

Post image
14.8k Upvotes

675 comments sorted by

View all comments

Show parent comments

218

u/[deleted] May 16 '21

has anyone?

55

u/LesserPolymerBeasts May 16 '21

Yep. After reading all the examples, I know that all vehicles have wheels, but cars have a variable number of doors, whereas motorcycles don't have any.

Now, for step two, I just need to find a large automotive manufacturer that's completely brand new to the idea of software, and I'll be able to nail that interview...

20

u/Eji1700 May 17 '21

And cry yourself to sleep in 10 years when they roll out 2 door offroad unicycles.

49

u/A-Disgruntled-Snail May 16 '21

What’s an inheritance?

110

u/Last-Woodpecker May 16 '21

Isn't that thing that someone gets when their parents die?

48

u/[deleted] May 16 '21

If you're clever you can get it when other people's parents die. I think that might just be a combination of robbery and murder though.

0

u/[deleted] May 16 '21

[deleted]

→ More replies (1)

11

u/[deleted] May 16 '21

Other people have parents?

→ More replies (1)

21

u/kidsonfilms May 16 '21

Confirmed, Batman's Parents are Object Oriented Programming

15

u/[deleted] May 16 '21

No, that's a bat costume

→ More replies (1)

43

u/individual_throwaway May 16 '21

I am almost certain that in any given field, there is a subject that nobody really understands.

In physics, it's quantum mechanics. In programming, inheritance might be a hot contender, together with regular expressions.

33

u/bmw417 May 16 '21

Special appearances by P vs NP and the traveling salesman, those guys really know how to bring down a party

0

u/[deleted] May 16 '21

[deleted]

6

u/Tapeside210 May 16 '21

Did you just use the term ‘exponentially’? Let’s have a seat.

20

u/superluminary May 16 '21

It’s a funny joke. But there are some very real difficulties with classical inheritance, the main one being “what is a class”? If a class if an object, then it must necessarily have a class of it’s own, so what’s the class of Class? Logically, the class of Class is Class, so you have a circular inheritance loop at the top of your hierarchy.

Alternately you can say that a class is not an object, it is syntax. This creates a whole other set of problems. Where do you put your static methods? How do you manipulate classes? You need a whole introspection API.

JavaScript sidesteps all these issues with prototypical inheritance, which is way simpler.

9

u/10se1ucgo May 16 '21

One may even call it...a metaclass...

But then what is the class of a metaclass?

2

u/theScrapBook May 17 '21

In Python, type

8

u/cdreid May 16 '21

This is why i hated C++ when it came out (yes im that old) i came from c, forth, asm etc which were clear logical languages. Then he drops what my young self called "phiilosophical bullshit into the thing i loved. I eventually had to read a book on general OOP to get it. (I got mediocre..not good). Now im older and get why its incredibly useful in large and team encironments. Still be superhappy to point out its flaws. C++ is the one language you just might accidentally create General ai in by programming while stoned. And not have anyone including yourself able to understand what you did later. "Wait is that recursive inheritance between three classes?"

→ More replies (3)

10

u/patenteng May 16 '21

People do understand quantum mechanics. When Feynman said it he meant that QM is not intuitive to us. But guess what? There are a lot of things in classical physics that are not intuitive, e.g. diffraction.

→ More replies (4)
→ More replies (2)

2

u/alexanderpas May 16 '21

Jon Skeet has.

2

u/NameGiver0 May 16 '21

Yes. It's a trap.

2

u/lowleveldata May 16 '21

Should we tho? First I was told it's the one tool to save us from complexity and then they say no it adds more complexity just use composition

2

u/mekk1tos May 17 '21

Yeah. Isnt it useless? Makes classes tightly coupled, breaks encapsulation, maybe something else. For me,that's enough. Composition can give all benefits of the inheritance without introducing the downsides.

I figure inheritance is used only if theres no interfaces in the language but I doubt such languages exist at all.

Really, does anybody agree with me? I have never needed inheritance yet and have also refactored systems from inheritance to composition and the intent of code became so much clearer.

If anything, Im really interested in seeing where inheritance can be used and what profits does it have, because now I dont see any use for it at all.