18

University, first year. I went to my Java/OOP teacher's office to about the course (I had started programming C++ ~5 years ago).

I wanted to discuss the fact that some parts of the course seemed too theoretical for beginners in my opinion. Rookie mistake : do not criticize the cursus of an academic if you are in your first year, even when you are right. I learned it the hard way...

The teacher started to tell me that I was just a first-year student, I had no experience yada yada...

To that I replied "I'm doing C++ for 5 years. This is OOP so yeah I do know a little more than you think".

I will never forget his reply "LOL C++ is not Object-Oriented !"

I never went to his course after that. I learned a few years later that the teacher was a well-known a**hole along his peers and got fired by the University...

Comments
  • 5
    Well, he is not entirely wrong. C++ isn't entirely OOP oriented. You can use it almost in any way you'd like
  • 11
    Not saying the teacher in question isn't an arsehole, but you'd be shocked at the number of first year students who come in complaining about courses, saying they know best, they've got more years of experience than they've been alive, etc. It *really* wears a little thin after a while.

    Introductory programming is something every man and his dog seems to have an opinion on, and everyone thinks their opinion is the only right one.
  • 3
    While the teacher was certainly a bit of a douche, I kind of have to agree with his opinion tbh.

    It may certainly depend on how you define "object oriented", and there is a surprising variety of definitions depending on who you ask, so maybe C++ meets SOME OOP criteria.

    C++ itself claims to be multi-paradigm, which in reality seems to mean that you can mimic certain paradigms, without being able to take full advantages of them.

    OOP without garbage collection in my opinion is not OOP.

    C++ lambda expressions are mere anonymous functions and not lambda expressions. You can argue that functional programming is possible in C++, but without real lambda expressions and lazy evaluation, I would not dare to call C++ a functional programming language.
  • 8
    @DirtEffect how garbage collection is even remotely related to object oriented programming? It's a way of organizing code.
  • 1
    @DirtEffect garbage collection is completely orthogonal to OOP....

    C++ is about as OO as Java, at least if you use it how I've normally seen it used (classes everywhere).
  • 1
    @YADU C++ does not impose class structure upon user at all. Unlike Java.
  • 0
    @iiii I agree, but in practice, every C++ codebase I've seen has made extensive use of classes, to the point where it might as well be enforced
  • 0
    @iiii well if you dont have it, the problem of ownership arises, which makes OOP much more complex.

    I grant you that with std::unique_ptr and std::shared_ptr they have made this part a little less terrible.

    At least I could not name any object oriented programming languages that don't have garbage collection.
  • 1
    @YADU In that logic I can take any old-ass C code, rename all `struct` to `class` and I have created an object oriented program. Nice.
  • 1
    @DirtEffect no.

    I'm not saying any possible C++ program is OOP, I'm saying:

    (1) C++ provides the features needed to easily write OOP code
    (2) most C++ code that people write in the real world is OOP.

    Obviously if you just compile old C code as C++ that doesn't apply
  • 0
    @DirtEffectmodern oop is just a poor design, that is why it often needs crooks like garbage collection.
  • 0
    @YADU Well.

    ad 1: So does C if you know what you're doing.

    ad 2: Depends on what is your "real world". UI people probably. In the field I am working in, there seems to be a clear trend to get away from OO design principles. C++ is mostly used for its template mechanism, which doesn't really fit the object oriented paradigm.

    Look at the most influencial C++ library: boost. That library hardly fits the idea of object oriented programming, does it?
  • 0
    @iiii it IS damn convenient tho
  • 0
    @DirtEffect it's not. It's just mainstream.
  • 0
    @iiii let me guess: just graduated?
  • 0
    @DirtEffect quite the opposite.
  • 1
    @iiii Oh. Not graduated yet.
  • 3
    @DirtEffect @iiii is correct (also, he's a working programmer). OOP says that you enforce that your program decomposes into objects that have well-defined interactions (originally expressed in terms of sending messages but usually seen as calling methods in most mainstream languages). Garbage collection is an implementation detail.

    For that matter classes are also one style of OOP (the dominant style, but still), with prototyping being another way. In general OOP doesn't require language level support (though it does help to have it if you want to do it *well*).
  • 0
    @RememberMe Yes I know and I agree mostly, also with @iiii.

    Don't get me wrong I just wanted to make fun of his normative statement.

    The thing is I think you are kind of making my point there. If you accept THIS definition of OOP, then I would be challenged to find a language that ISN'T an object oriented programming language, in which case the whole notion becomes irrelevant.

    When I look at common OOP design patterns, then of course they are possible to implement in C++, but the question of ownership as well as the requirement to explicitly mark virtual methods, usually complicates things a lot. If you learn OOP through one of the major OOP languages (Java, C#, ...), you will have to adapt quite a bit to doing OOP in C++.

    Further, the anecdote given in the beginning sounds like it has happened quite a while ago. Maybe the instructor was talking about C++98 back then, which didn't even have reasonable smart pointer support. So yeah. I see where he's coming from.
  • 3
    The lack of knowledge about what makes OOP is astounding in this thread.

    Garbage collection is memory management and has literally not a single goddamn thing to do with OOP.

    For a language to be OOP, it needs to support the four principles of OOP: polymorphism, encapsulation, inheritance, and abstraction.

    All languages can be used in an object-oriented manner, but the degree to which the language itself supports these four items is what makes it "OOP" or not.

    C++ is object oriented. That's what distinguishes it from c: it has built-in items to support all of the above (private member variables, classes and inheritance, etc)

    Java makes use of OOP principles in the generic flow of it's usage. It forces you to write your base application as a class. Everything is an object (with the exception of primitives, IE, anything you can't use in a template)

    This professor is retarded.
  • 0
    I want to point out that garbage collection and no memory management at all are not the only two options.
    There is also manual and automatic reference counting. Like in Objective-C and Swift.
    Garbage collection really does have nothing to do with OOP.
    But Java really does try to be as object oriented as possible. To the point where it becomes annoying because not everything should be object oriented.
  • 0
    @Lensflare reference counting doesn't work because circular references will remain in memory even if the memory is no longer in scope or otherwise useful to the program.
  • 0
    @AlgoRythm "The lack of knowledge about what makes OOP is astounding in this thread."

    Astounding is also the amount of prick waving in this thread, my friend.
  • 0
    @DirtEffect you're the one assuming @iiii is a junior dev just because he slightly disagrees with your frankly misinformed argument. You're actually the biggest ass in the room.

    You're trying to discuss OOP and c++, then you go off onto the topic of garbage collection and smart pointers, both of which are entirely memory management/lifecycle and not OOP related in the slughtest? And then you tell another dev that HE'S the junior? I would apologize.
  • 0
    Okay guys I take back the statement:

    "OOP without garbage collection is not OOP"

    I just wanted to express my opinion that OOP without garbage collection is no fun.

    (And I am absolutely somebody will lose his or her shit even about that sentence)

    I mean COME ON what is this here? Twitter?
  • 1
    @AlgoRythm Dude honestly. I have NOT made a misinformed argument, I OBVIOUSLY expressed an opinion. I tried to clarify later, but i4 and the other trigglypuffs need to brush their egos up by lecturing me on a point I did not even want to make.

    I never assumed this guy to be junior dev, I just wanted to mock his attitude.
  • 2
    @DirtEffect I think you communicated very ineffectively. I would have never interpreted your "Garbage Collection" comment in the way you meant it, because I really think the words you used to actually say it mean something entirely different.

    Your very first comment sort of set me off because I could tell you were talking out your ass. "Maybe it meets SOME of the criteria", "depending on how you define OOP". The criteria are standard, OOP is well-defined. Languages almost never force a single paradigm. Even in c, you can accomplish the main four parts of OOP. Ask Fast-Nop, he worked on a real-time OS that was written with c using OOP principles. Even x11 does this to a certain degree, despite c being recognized as rather non-OOP.

    When the conversation returned to pointers I was just like... what is happening. And then you instuled iiii's experience level and I was like... this is exactly what the rant is about.

    And don't go all "aww shucks twitter" on me just because you acted up!
  • 0
    And just in case there was any doubt about the original post, here's an excerpt from the first few pages of "The C++ Programming Language", famously written by Stroustrup himself...

    Source:

    https://github.com/boydfd/books/...
  • 1
    @AlgoRythm Call it inefficient if you like, but I was trying to sketch where the statement of the teacher might have come from. I am a bit surprised about the backlash on that particular statement because I have used it several times through the years in conversations and was hardly ever misunderstood.

    I mean I KNOW (as stated above) that C++ has object oriented concepts built into the language. And OF COURSE I KNOW that OOP and memory management are orthogonal. As somebody who writes C++ for a living, I just find it totally annoying that they did not put some care-free memory management into the language, which would make a lot of things a lot easier.

    Same goes for the lambdas, as stated above. It sometimes feels like C++ tries to support everything, but nothing very well.

    The "SOME criteria" sentence struck the wrong tone, I agree.
  • 1
    @DirtEffect I completely agree that hands-off memory management is way more convenient in the long run. My experience with it is:

    Issues caused by manual memory management are usually simple and easily fixed. Forgot to de-reference, forgot to free, forgot to initialize to NULL, etc. But the general case requires much more care.

    Issues caused by automatic memory management are convoluted and often actually impossible to fix as you can't really tell the GC what to do in many cases (such as Java). In contrast to manual, the general case requires little to no care at all.

    It's a pick-your-poison. Just about everything we do as programmers is.
  • 0
    @AlgoRythm as for @iiii's expertise: I have heared statements like "Oh this is just mainstream" so many times, and almost exclusively from know-all students and the University who have not gone beyond writing "Hello World" in Haskell and think they are the next Donald Knuth.

    I really just wanted to mock the attitude of that statement.

    I do stand with the twitter comment tho, cuz it felt like hardly anyone read far past the OOP and GC comment and any further clarification was swallowed in the initial outrage.
  • 1
    @DirtEffect Understandable. That comment of his is also a bit asinine, but I think the tone of the thread was already there at that point. I would say it's arrogant to simply dismiss something as mainstream when clearly it has had a very serious influence on the way we write programs today.
  • 1
    @AlgoRythm True. Java is a particularly bad example for memory management (we have it in our software and it is a huge source of problems).

    Other languages seem to have way better GC. Did some larger projects in Python (of all languages) and did not have comparable problems.

    I liked the approach that D took, where the struct is (broadly speaking) what you find in C++ and the class is on the heap and garbage collected.
  • 2
    @DirtEffect I praise Java for popularizing many things, such as bytecode execution and VMs, highly-object-oriented style, cross-platform mindset, and automatic memory management.

    But I will always be disappointed in it's evolution, or more accurately, lack thereof
  • 0
    @AlgoRythm reference counting does work. Yes, you need to be careful with cycles but there are ways to break them up with weak and unowned references. It’s not a problem when you get used to it.
    Garbage collection is more convenient but it comes with the cost of poor performance and indeterminism.
  • 1
    @DirtEffect @AlgoRythm I do think that oop is overrated and is treated as somewhat of a silver bullet. It has its merit as much as procedural programming has. And, IMO, that influence you've mentioned is blown out of proportion.
  • 0
    @iiii Most major languages today are garbage collected (especially if you go by usage statistics), I think my statement is perfectly within proportion.
  • 0
    @AlgoRythm did Java invent garbage collection?
    Edit: Ok it might have popularized automatic memory management.
  • 0
    @AlgoRythm if something is mainstream, does not mean it's correct or good. Garbage collection is mainstream, but it's not better than actually instructing a machine to not waste resources. Garbage collection is only mainstream because our dumb computers are so fast that even slow and wasteful memory management is fast enough to be tolerable.
  • 0
    @AlgoRythm I also meant that oop had more influence on industry than it should have had.
Add Comment