Why does Holla Forums think that OO programming is bad?

i'm starting to learn Java and the beginner book that i'm learning with circle jerks all around about how OO is a god send for programming, pic related is the "example" it uses to demonstrate that. (tl;dr, OOP code is easier to change around later in case the project goals change, and procedural is just a filthy mess), the comparison makes sense for a beginner like me, and does make OO seems better, so why do you guys hate OO programming with a passion?

Other urls found in this thread:

pyvideo.org/pycon-us-2012/stop-writing-classes.html
archive.is/P63q0
harmful.cat-v.org/software/OO_programming/
yosefk.com/c fqa/class.html#fqa-7.5
pastebin.com/K9b4SiFf
youtube.com/watch?v=QM1iUe6IofM
pastebin.com/W7fh7sVB
blogs.msdn.microsoft.com/oldnewthing/20040209-00/?p=40713
refspecs.linuxfoundation.org/cxxabi-1.86.html#member-pointers
twitter.com/NSFWRedditImage

I think object-oriented programming is great when you're working with actual objects. Things that can be represented properly as data types with associated methods and possibly some inheritance along the way.

It becomes an issue in languages like Java and certain ways of writing programs in other languages, where everything is forced into the object-oriented programming mold. It's not the proper solution for every problem, but there's an unfortunate tendency to present it as if it is, which becomes a real problem because there's usually a way to force object-oriented programming into a solution even when it's unnecessary and unhelpful.

This video might help you understand:
pyvideo.org/pycon-us-2012/stop-writing-classes.html

kek, what the fuck is that pic from? literally "that man's name? albert einstein" tier.

It appears to be from the "Head First" series, (probably "Head First Java"), which contains much more unfunny useless humor and meaningless diagrams than actual programming knowledge The pure stupidity contained in this series is what's being taught in schools today.

www.smashcompany.com/technology/object-oriented-programming-is-an-expensive-disaster-which-must-end
archive.is/P63q0

Because they try to apply a metaphor to places where it doesn't work. They use a fork to eat soup then complain about how much forks suck.

OO is the "it just werks" of computer programming. Good luck figuring out that amoeba.playSound() does something totally different than dicks.playSound().

...

...

...

this term is bastardized and used improperly.
Java has nothing to do with OO.
Erlang, for example, is not marketed as OO language yet it's actually closer to being OO than Java.

OO (as in real OO) is useful for some tasks. Not for all tasks.
Bastardized OO like found in Java solves nothing and exists just because fuck you.

C++ is the perfect compromise, because you can use OOP where it's reasonable to do so, and not when it's not.

I do not hate OO, but if I had to do it professionally I would probably hate all bureaucratic shit that has to be added like tons of boilerplate code that is written but never used, ObjectBuilderFactoryBuilderFactory() kind of abstraction instead of simply creating Object and 'everything needs to be pattern' meme.

If you restrict yourself to a sane subset of its features, maybe you have an argument.

That's funny. Joe Armstrong thinks the exact opposite about Erlang.
Can you elaborate?

Well, yeah, that's a given. If you have the discipline to write it in C++, you're doing yourself a big favor, because you have every tool you'd need. Shitty programmers who can't evaluate their problems end up using components of the language wrong.

true OO is about message passing and extreme late binding.
both of these things are no.1 priorities in Erlang.

do you even know what is OO though?

Wow, this is actually pretty accurate.

Apparently the creator of the language you're praising doesn't.

It seems that your definition of OOP strongly conflicts with the ones used by most of the rest of the world, which means that it's not a useful definition, even if the style it describes is great. I do like Erlang's way of doing things.

this is unrelated to OO, even the bastardized one.

this is just simple run-time polymorphic call, the same as what we have in C when calling a function pointer.

He probably just talked about the pseudo-OO, like found in Java, C#, and similar crap. Because otherwise pajeets won't understand the message.
Erlang author clearly isn't stupid.


If everyone jumps off the bridge, would you follow?
The definition I mentioned is in fact the very real one, from the author of the OO concept, Alan Kay IIRC. Should we forget it and cater for pajeets?

I somewhat like Erlang's way too, if only it could have good performance for number crunching and hard-realtime too… this is too limiting for some of my personal use cases. Anyway, when I used it for work stuff it was fun enough.

Isn't it a direct consequence of late binding? You can have the same problem without OOP, but that doesn't mean OOP can't cause it.

Function pointers don't even require late binding.
What requires that is when you load some dynamic library and get a pointer to a function from there

and of course OOP can cause it, but it doesn't have to.
if we talk about "styles of coding" which can cause some shit, then the list is endless for every "style".
what's more important is which pitfalls are practically unavoidable. for example, in C and C++ undefined behavior is practically unavoidable, because we have a long and recurring history of examples where even the most talented programmers accidentally left UB in their C or C++ code. so, if somebody thinks "…but I am clever, this won't happen with me", they are just showing lack of wisdom.

This example is shit, polymorphism is not a concept unique to OOP as much as java niggers would like it to be. You can do polymorphism in any language where functions can be passed around and called indirectly at run time.

like in C, you might do:

typedef struct shape shape_t;struct shape { void (*rotate)( shape_t *s, double radians ); void (*play_sound)( shape_t *s );};void amoeba_rotate( shape_t *s, double radians ){ // ...}void amoeba_play_sound( shape_t *s ){ // ...}void othershit_rotate( shape_t *s, double radians ){ // ...}void othershit_play_sound( shape_t *s ){ // ...}shape_t amoeba_make( void ){ return (shape_t){ .rotate = amoeba_rotate, .play_sound = amoeba_play_sound, };}shape_t othershit_make( void ){ return (shape_t){ .rotate = othershit_rotate, .play_sound = othershit_play_sound, };}

which makes implementing a new 'amoeba' shape just as simple. The main difference is that you need to pass the struct as a parameter to the function, where OOP will hide this. That's it, that's the big difference between OOP and non-OOP, having datastructures with code state and an internal scope bound together. Templating, polymorphism, inheritance, etc are not unique to languages with OOP-specialized features, java-style OOP is a gimmick designed to sell textbooks and enterprise software.

one of problems for OO-as-in-Java is that the type system which expresses subtyping doesn't bring any worthy benefits (and OO "experts" even discourage inheritance, lol), but it really complicates the language implementation (implementing subtyping properly, with inference and generics, etc, is some hard shit).
and of course, extra complexity is bad when it's not justified.

if multiple inheritance is disallowed, then any usage of inheritance as means for code reuse is a doom waiting for the day when you have to borrow implementation from more than 1 "superclass". and it's even more showing that inheritance is useless.
nevertheless, some stupid APIs like Android rely on inheritance heavily, then if you have to use them, you are doomed to write extra convoluted boilerplate code.

if, on the other hand, even multiple inheritance is allowed, then it's another increase in language implementation complexity, and for ultimately little benefit, because in the end it all doesn't solve anything, one doesn't have to use fucking pseudo-OO in order to write modular code. well maybe pajeets have to, but sane people don't.

that's true. except that you are talking about pseudo-OOP.
Java is not even an OO language.

harmful.cat-v.org/software/OO_programming/

I learned to program on Java and have dabbled in various other languages mildly over the years. And I'm still not even sure what the fuck object-oriented programming is. There's too much inconsistent jargon in programming across different syntaxes for me to give a shit. Is object-oriented just when you split up everything into separate includes or something?

No.
real OO is Smalltalk
also, Erlang, but it has servers in place of objects.
OO code is also possible in any other language but it would be far less obvious how to write it. That includes Java — Java is not an OO language. (it's a horrid parody on OO)

yosefk.com/c fqa/class.html#fqa-7.5

When you need multiple instances and encapsulation in C, you use a forward declaration of a struct in the header file, and define it in the implementation file. That's actually better encapsulation than C++ classes - there's still no run-time encapsulation (memory can be accidentally/maliciously overwritten), but at least there's compile-time encapsulation (you don't have to recompile the code using the interface when you change the implementation).

The fact that a crude C technique for approximating classes is better than the support for classes built into the C++ language is really shameful. Apparently so shameful that the FAQ had to distort the facts in an attempt to save face (or else the readers would wonder whether there's any point to C++ classes at all).

C++ helps with the tradeoff of safety vs. usability by eliminating both.

"There is no value in code being some kind of model or map of an imaginary world. I don't know why this one is so compelling for some programmers, but it is extremely popular. If there's a rocket in the game, rest assured that there is a "Rocket" class (Assuming the code is C++) which contains data for exactly one rocket and does rockety stuff. With no regard at all for what data tranformation is really being done, or for the layout of the data. Or for that matter, without the basic understanding that where there's one thing, there's probably more than one.
Though there are a lot of performance penalties for this kind of design, the most significant one is that it doesn't scale. At all. One hundred rockets costs one hundred times as much as one rocket. And it's extremely likely it costs even more than that! Even to a non-programmer, that shouldn't make any sense. Economy of scale. If you have more of something, it should get cheaper, not more expensive. And the way to do that is to design the data properly and group things by similar transformations."

t. Mike Acton

It has to do with complexity. A lot of the "features" of OO are worthless because they induce coupling and reduce cohesion and encapsulation, making clumsy, fragile, rotting code.

When people use OO they often go nuts for all the awesomeeee features like polymorphism and multiple inheritance and make a big mess.

OO is a spice like cinnamon or cilantro. A little goes a long way and it's much better to err on the side of just a bit.

Read Code Complete 2nd Ed for more info.

...

side status: obliterated

OP, OO is simply a way of organizing a program. The whole point of OO programming is allowing you to make changes to the program later without breaking things (ideally). You do this by specifying an interface to some sort of data structure, and then only interact with the data structure through that interface (doing otherwise would be "breaking the contract" so to speak). The practical benefit is that if the data structure needs to change, then you only change the implementation of the interface and _not_ the code that calls that implementation.

The people ITT claiming that OO is a particular programming language are either being disingenuous or just ignorant. You can do OO programming in any language (even assembly), though it is much easier in some languages than others due to special syntax for creating these interfaces (i.e. classes and methods). For example, even though C does not contain explicit syntax for creating an object, FILE pointers demonstrate how you can effectively create one in C.

TBH, most people who are shitting on OO are just trying to look smart. Most programs take advantage of OO in some way or another, particularly as the complexity increases. Of course OO is not appropriate for all situations (notably ones where the extra function call overhead is a problem), and of course you can create shit code with OO. That's true for all programming methodologies; they aren't silver bullets.

Probably the worst way of misusing OO is creating classes that wrap around other classes to hide flaws. The whole point of OO is that allows you to make fixes to an implementation; by creating wrappers like this you place even more code on unstable foundation. Even worse, the child class could become dependent on the parent class's bugs, making those bugs impossible to fix without breaking tons of stuff.

Finally, some fucking sense here. While I was always pretty sure the "OO is shit user" stuff here was a joke, I felt that some people (who obviously can't program for shit) fell for the meme and took it seriously.

Your post fucking nailed the definition of OO.

Whether someone likes a particular syntax or implementation of OO is a different question. Personally, I wish C++ member functions were accessible in both member forms object->my_function() and static forms MyClass::myFunction($instance)

This would solve the problem of setting callbacks in C.

Anyone know any reason this is not achievable?

Forgive my camelCase and snakeCase typo. I've been working with projects recently that use both, thus I am scattered.

There are class-methods and instance methods. What you described works for instance methods line
op.ban()op->ban()
but in order to call a class method you would need a "class object" for the class itself
user->sellUserData(true)

Yeah, I understand that portion of it.

I'm just wondering why C++ "Instance Methods" like void functionName(int param) didn't automatically translate to:

class MyClass { static void functionName(MyClass *instance, int param);}

... in the first place.

As in, why weren't "Instance Methods" just made as conveniences to the static version of the function? And if they were, why did C++ make the static version inaccessible?

The point is that for 99% of applications, the "features" of OO are antifeatures that encourage bad habits.

What the fuck am I looking at here? This is truly some fucking twilight zone shit. I'm scared. Are we now at a point where normalfags are so mindfucked that they actually let authors condescend them like this? Is smarmy snark the lingua franca of millennials? Where am I? What's happening? Berenstaein??

Why is there an amoeba on the screen? Who wrote Brad's playSound() ... was it Larry? Then why is Larry in his "cube" instead of being on the beach or at least facing to bloodshed?

AND WHAT THE FUCKING HELL IS A HIF FILE?????

Larry we need to talk.

That is not how you OO.

Languages that force OO are pushing for useless abstractions. Better to use a language that lets you decide.

what did he mean by this?

Want to know something funny? I was tapped for a java programming interview and I picked up this book to refresh on some basics. Mainly how in the fuck to conceptualize inheritance, polymorphism, and proper use of objects.

I created a shitty little ATM program with a ton of bugs to stretch my coding legs a bit. I went to school for accounting so don't bully pls.

I would like some input as to where I could improve. A feeling I had so far is that my code as it stands is mostly in the main method when I should be doing more method calls instead. I would appreciate any feedback and suggestions, aside from the usual "HOLY SHIT WHAT AN IDIOT" posts.

Oops I guess it's too big for a code block here.

pastebin.com/K9b4SiFf

HOLY SHIT WHAT AN IDIOT

You should rotate the amoeba more.

You take that back

This looks like a functional program. Where is the OO?
I would expect you create a class ATM and instantiate that then call methods on that object.
Instead everything lives within the scope of your "class" making it a functional program.

So you mean having class ATM{} and then making the methods public and calling them like that? Most of my coding experience is C and it shows because my code always comes out functional as you said. The OO-ness of the program comes from the manipulation of the user object and the manipulation of loginTokens I thought, but like I said it's probably garbage bin pajeet code tier at this point.

No.

t. Larry

Using your example, I could take the method printing out of the main() and put it into its own method and call it in.

public void menuCall(){ System.out.println("Please make a selection: "); System.out.println("1 - Register"); System.out.println("2 - Login"); System.out.println("3 - Deposit"); System.out.println("4 - Withdraw"); System.out.println("5 - Check Balance"); System.out.println("6 - Log Out");}

And then just put menuCall() in the main() at the top of the loop.

something like this
class ATM{public: int give_me_money(int amount); void take_my_money(int amount);private: int money;};main(abracadabra){ ATM my_money_laundering_machine = new ATM(); int cashmoney = my_money_laundering_machine.give_me_money(100); if (cashmoney == =) { print "poorfag"; }}

In this example, when would there be interaction with the private money variable?

You're declaring 'int give_me_my_money(int amount)', that's a method within class ATM that you're passing the value in your cashmoney initialization?

Stop being dense, obviously the functions manipulate the private variable of the class.
The code was omitted because i thought that was obvious.

Like I said, I was an accountant not a programmer. The place I'm applying at is a good software house but they like me as a person more than they like my coding knowledge. I'm guessing they're going to put me through some sort of coding bootcamp. So yeah, forgive my ignorance, it's been like 3 years since I touched java before three days ago.

If you are gonna get schooled by them anyways then why embarass yourself beforehand by posting shit code online?

I'm not embarassed, just thought people might want to contribute a bit instead of the usual stroking it about their favorite browser/DE. I already admitted I'm a shit programmer. I want to not be shit, but you're being unrealistic about expecting me to know things I haven't come across in ages. I think I see what you mean about the private variable behind the scenes though. I was worried about not being able to print the value, but I could make it its own method to 'Check Balance' and interact with it.

There you go, you are finally catching on.
Well done user you are now an honorary pajeet.

Would it be more prudent to put the method to check balance within the same class as user? That would make me have to do something like user.checkBalance(int input) right?

more like user.check_balance(account u_acct)
so we can have another class for maximum OO
gotta think big user

Larry's getting triggered here, bro. Triggered I tell you. This thread should be carved on a stone plate so future generations can understand and be warned of why our civilization fell.

Sorry larry, let me refactor real quick
user = UserFactory(CreateNewUserObjectFromInputData(Input.InputData(UserClass.User));account = GetAccountDataFromDatabaseHandlerObject(Onput.ToString(User.Name));user.CheckBalanceOnCloudAccount(account);
I can already feel the rupees flowing in

Damn you gave it a really long meme name, I can tell you're good at programming and have good taste

wow you must be fun at parties

...

...

yes it is. he's talking about the code being a map of objects.

It has its place but you should always think about if it's actually helping you or making things worse. Programming games in an OO way for example is a nightmare and its much faster and more fun to do it with a component-entity architecture.

this. it's from head first java. and the entire series are written by shitty san fran coders. books in this series always have 700+ pages that could be condensed to < 150 pages if all the off topic bullshit and shitty diagrams were taken out. to give you an idea of the bloat in this series, head first html spends an entire chapter, 56 pages, covering the tag, when 1 page would have sufficed.

because hardware is not OO you fuckin faggot

OO helps you make things worse.

That example is very condescending and that sort of mentality is why people have come to hate OOP. There is nothing wrong with OOP in principle, but languages like Java treat OOP like a panacea, not realising that they have turned the medicine into poison, forcing everything into OOP creates more problems than it solves.

In theory is sounds nice and clean: cats and dogs are pets, pets and humans are animals, really cute. In practice however it will never be this simple, it will be like pic related in

This video explains the fundamental problems of OOP well:
youtube.com/watch?v=QM1iUe6IofM

It really takes a special kind of skill to pad out books like this.

Hey me again. I redid my program with more method and object manipulation. I took your advice about the private instance variables in my user class.

pastebin.com/W7fh7sVB

Still a bit functional but closer

Your functions still don't belong to an object aka a class

...

I don't get what you mean. Are you talking about polymorphsed functions? I am calling in userArray[x].function pretty regularly throughout. Unless you're talking about me implementing interfaces...well I'm not there yet.

Every game developer does that and implements it with classes. If you meant something different, elaborate.

I don't know if this is what you're getting at, however, I notice that the writer is attempting to use an imperative approach yet uses multiple classes, almost in an OOP fashion.
Note to the writer, if you're going to have User as a class like that (with fields and all), then it'd be more suited as an object. I.e., no need for createUser, just have a constructor User. If you're attempting to use procedural, I leave it to someone else to describe a better format (personally I would separate methods acting on a user and acting on an ATM into separate files, however, maybe, the OOP indoctrination from school has gotten to me such that I can't think of a good way to write it without OOP).

This is where I'm lost. What do you mean by this?

This is why you get a decent book on the subject.
Anyways: Suppose you have an object defined by a class. The fields (i.e. the variables outside of any method) are like the attributes of the object. You then have methods, these methods act on the object. As for the constructor in particular, a constructor is just the method whose name is precisely the class name. This name is used to first create the object and usually involves initializing the fields of the object. E.g., public class Hello { } would have a constructor public void Hello(). Of course, you can have parameters passed in, but, to be the constructor (i.e. the method you call when you do: object = new method();) it must have the name of the class/object.

What did he mean by this?

Bumping this as I'd genuinely like to know.

Why is it that Member Functions were not simply shorthand to writing static versions of the function?

// Why wasn'tvoid functionName(int param);// ... just used as shorthand forstatic void functionName(ThisClass *instance, int param);

This would've made certain things in C++ way easier.

Because of virtual member functions, member functions of objects with multiple inheritance, and member functions of virtual base classes. The standard left the implementation of the class system as undefined since there's multiple good solutions. Microsoft explains their system at blogs.msdn.microsoft.com/oldnewthing/20040209-00/?p=40713 and the Itanium C++ ABI (which GCC and Clang use) explains it at refspecs.linuxfoundation.org/cxxabi-1.86.html#member-pointers

Because that would literally make it not an "instance" method.


What would this offer over a non-static member function?

Are you retarded? Do you not see the "ThisClass *instance"

Are you retarded? Why would you use the static keyword in the first place, then pass it a pointer to use it as a non-static method?

Shut the fuck up Pajeet