Is Object Oriented Programming bullshit...

Is Object Oriented Programming bullshit? I'm about to start my second year of a CS degree but I've been coding for years, and I started reading about OOP since I'm taking a class on it next semester. And it looks like "OOP" means that you couple all data structures and functions into "classes", all the time, no matter what. It sounded kind of like dogmatic bullshit, so I searched around and found that there's disagreement about if OOP is a good idea or not.

Is there some good reason to use OOP that I don't grasp yet? Or is this one of those times where something that's bad or counterproductive somehow became mainstream (like VHS)?

Attached: oop.png (1126x622, 24K)

all paradigms are bullshit if you think about it but they're mostly there to make your code readable for the other codemonkeys on your team. easier to know where things are in code if the code has to follow guidelines.

yes, you don't need it at all

Learn CLOS.

It has uses, but if you overuse it, you end in pajeetland.
The main advantage is that the local variables can make your code cleaner.
For example:
void addvec(int enid){
enemy[enid].x+=enemy[enid].vx;
enemy[enid].y+=enemy[enid].vy;
}

Turns into:
void enemy::addvec(){
x+=vx;
y+=vy;
}

So you use it when it makes the code better, but you don't do stupid dog tricks with infininheritance or you will be doing the equivalent to the BASIC stupid goto tricks.

This. Also smalltalk.

It's good for big projects with multiple programmers, since everything is a black box and you only need to know how your own code works. At least, that's the theory.

>I've been coding for years
>never heard of OOP
Changing Minecraft config files is not "coding"

>it looks like "OOP" means that you couple all data structures and functions into "classes", all the time, no matter what.
This is where people fuck up hard with oop. Just treat c++ like regular ass c unless a specific task benefits from an oop approach and then do it in classes. Oop is a tool, but all because you have a hammer not every problem should be viewed as a nail.

Technically it is 'coding', but not 'programming'.

Seconded for Smalltalk.
Besides that take a look at Clojure and at some lectures by Rich Hickey (Clojure's writer) and Kevlin Henny (wrote a book on design patterns, so keep that in mind when he bashes OOP)

you should consider OOP a toolkit, and as such always using OOP would be like using a hammer for every job. learn what tools are available, when and how to use them, and perhaps more importantly when and how NOT to use them. the tools in OOP are alternatives to tools in the monolithic toolkit, but OOP as a whole is neither intended nor viable as a replacement for monolithic software as a whole.

here are a couple things you should learn about.
inheritance specifically: interface implementation vs class extension(interfaces mostly used when you need to have many classes with the same black box signature but different implementations, extension is used when you need to have multiple classes share implementation for whatever reason, large extension trees will hide implementation though so it's generally not a good idea to have a 10 class long inheritance line)
polymorphism is basically just referring to an inheritor/implementation by its superclass/interface it's used to make your program implementation independent, like instead of CryptorA.x() and CryptorB.x() you'd just call GenericCryptor.x() where both A and B would implement/override GenericCryptor. so you can do shit like store both types in one array or one variable(interchangeably)
encapsulation? is just putting shit into separate containers to help you not accidentally mess up other parts of your program by editing a line somewhere, both in the case of data/variables and functions.

No, it's realistic. As in, I do not give half a shit how or why your shitty library works, give me a nice interface. For instance, openssl's md5 has init(), update_context(), finalize(), etc, which is semantically wrong. You don't "init, update_context, finalize" an md5 sum. You give it a series of bytes and it gives you a 128bit output.

what the fuck an actually informative OOP thread on Jow Forums? how?

Attached: scary.jpg (496x442, 92K)

>all data structures and functions into "classes"
Untrue, you can do OOP with C if you wanted to. The entire dogma of OOP boils down to "Give me such a minimalistic, braindead-proof interface that I couldn't misuse if I tried." Make the compiler enforce the invariants of your code via errors and warnings by giving enough hints to it, this implies some boilerplate.

People who make everything OOP are idiots and don't know how to write efficient programs. Learn about OOP, study it, and then if you ever have a situation where you go "huh an object would make this a lot easier" go for it. I hate the OOP paradigm and stay away from Java, however there are times when objects are extremely useful if you limit your use of them and plan out your system carefully. Best of luck studying user.

Why is OOP inefficient?

OOP is a good idea in certain settings.
Not everything has to be OOP to be useful
And OOP can make things even detrimental in some cases.

But when used right, it's godlike and actually make programming simpler

> it looks like "OOP" means that you couple all data structures and functions into "classes", all the time, no matter what. It sounded kind of like dogmatic bullshit

Congratulations! You have your head on straight, are capable of critical thinking, and rightfully question norms you don't find virtue in. I don't mean to be patronizing, this genuinely puts you in a minority of the population. Well done.

Attached: 1548036414974.jpg (308x308, 40K)

OOP makes a lot of sense in big projects.
you don't have to use it for your small home projects if you don't want to but you should. once you get a feeling for it you'll see why it isn't a meme.

>This is where people fuck up hard with oop. Just treat c++ like regular ass c unless a specific task benefits from an oop approach and then do it in classes. Oop is a tool, but all because you have a hammer not every problem should be viewed as a nail.
No
no
no
nono no
This is why we end up with 1980s and 1970s codebases full of unreadable, buggy, messy code. C++ is a lightweight language for overhead-free abstractions. It's too easy nowadays do write modern C++.

Yes to this. Learn the tools, don't drink the koolaid. Especially if they're from people trying to sell you something (Ide/framework/language).

If there's one thing that's happening in programming languages right now is that people are finally figuring out that there is no one true programming paradigm. You're getting stuff like javascriptified Java (kotlin), javafied C++ (Rust) and javafied javascript (Typescript). And functional programming stuff is seeping in everywhere. Just learn what each one is good for and use the best one for the job.

This, its not functional vs oop, you can have both just learn when to use which.
Same with the languages.
You wanna know whats the best one? The one you're best at.

>this implies some boilerplate
Unless the compiler can prove that the constraints are always satisfied. If that's true, it can throw away the safety code.

>You wanna know whats the best one? The one you're best at
no. i'm using c and c++ at work. still i wouldnt use the language i'm "best at" if I wanted to start a private homepage or something. the best language depends on the project.

oop is unironically the greatest baradigm

>Classes
Bundles data and functions together. Sometimes useful but using it as the default unit of abstraction is ridiculous. Data and code should be separate most of the time.

>Information Hiding
Why would you want to hide information? State should be explicit and easily seen, or made to not matter. In OOP is adopts the worse possible stance which is to hide it and still have it be fundamental to everything.

>Polymorphism/Abstraction
Not something unique to OOP.

>Inheritance
Adds a bunch of implicit state, again a bad idea.

OOP is a meme. It is no surprise modern languages like Go/Rust have chosen explicitly to avoid the C++/Java/C# way of doing things.

One thing that I never understood:
It's always said that attributes should basically never be public or protected, but how do you read them, then? Using get and possibly set methods obviously, but what's the point when you could do that directly? Is it a debugging stack trace thing, or more relevant to huge projects so you can keep track of who does what?

The problem with C++ is that the compiler expects you to write C++ code, so to use write everything in classes. Otherwise you get worse performance than using straight C.
Or was it longer compile times?

it's so you can pick and choose which ones have get/set

This thread:
>I'm too dumb to understand OOP

The funny thing is that good C programmers have been using OOP since the 80's.

>Why would you want to hide information? State should be explicit and easily seen, or made to not matter. In OOP is adopts the worse possible stance which is to hide it and still have it be fundamental to everything.
brainlet detected
encapsulating state makes it possible to maintain useful and clear invariants for that state, though most oopsies don't exactly use it for that sensible purpose

Procedural programming is the answer

Attached: 2019-08-23-214126_1366x768_scrot.png (1366x768, 18K)

Encapsulation and information hiding are vital in correctly handling data. The author decides what you actually need to see, don't try to be clever. It doesn't work out well.

Jeez it's longer compile times and that's only if you use type deduction and templates. C++ is a strict superset of K&R C, it cannot be slower.

>You wanna know whats the best one? The one you're best at.
In some cases I agree that you'll probably get more out of a language you're familiar with, but some languages are objectively better for certain tasks like webservers or embedded systems or embedding into a separate program or whatever. You wouldn't use Python for an Arduino.

This isn't the 80s or 90s anymore user. You'll get the same performance either way.

it 'can be' inefficient if there is a long inheritance chain.

OOP is cancer if you go into AbstractPajeetFactoryInterfaceBuilder bullshit and overuse design patterns for no reason, but there is no harm in using classes.

Plenty of neat things can be done using classes, I wrote a math library for vector and matrix math with swizzle operations for vectors. It is lot neater to use than glm or dxmath. For instance I can do
float4 vec = {1, 2, 3, 4};
vec.xyz; // -> vec3:{1, 2, 3}
vec.xxzz; // -> {1, 1, 4, 4}
vec.xz += 1; // -> {2, 2, 4, 4}

getters/setters are methods (functions) so you can put more logic than just assigning a value to a field/variable

for example, you can return a copy of an object so the receiving code doesn't modify the original
or you can lazy-initialize stuff inside the getter method the data gets processed on first read (and doesn't if it's never read)

setters could include validation or propagate the set values further if needed

OOP is garbage. Using some of the tools and idea from OOP for your procedural programs? Good. Just like FP, it's great if you just take the useful and intuitive bits.

>Is Object Oriented Programming bullshit?
No, it's just a tool.
>"classes", all the time, no matter what.
No, that's just Java.

OOP is a good idea.
Dogmatic OOP where you ALWAYS use classes is bullshit.
Over engineered OOP (i.e. Java) is bullshit.
OOP by the typical average IQ codemonkey pajeet who can't into abstraction is super + bullshit.

Like everything else in programming, if a skilled high IQ engineer works with it the resulting code is a thing of beauty. If coder bootcamp mommy or Pajeet works with it, it's spaghetti.

OOP is useful and improves code legibility and organization, provided you don't go overboard with it

It's been a day or two people start to talk about actual Jow Forums stuff and not consumerism shit. Sadly threads don't last a long time

>Dogmatic OOP where you ALWAYS use classes is bullshit.
>Over engineered OOP (i.e. Java) is bullshit.
Java is not inherently over-engineered. Not being a hybrid of different paradigms like C++ actually makes it easy to work with.
"Everything is an object" isn't even true in Java, you can write 100% static code (though OOP is actually better most of the times)

I once worked for some small company. They did everything OOP. I started to take a look at the code : no comments, no documentation about the structure, it heavily relied on inheritance and polymorphism. This shit was impossible to maintain if you weren't the guy who made it. There were a shiton of issues with class A using class B, class B using class C but class C using class A and their solution were to make a virtual class D to link everything and have something working.
Most problem came from using OOP for everything even when not needed. Before me 5 devs decided to quit, i did too. What's impressive is that for those people it was perfectly fine and there were no problem at all with their code

You can make shit code without Oop too.

If you read Alan Kay's orig idea of what OOP was supposed to be it makes sense: a massive, distributed system where each server is running it's own 'algebra'. Your 'program' just sends out messages to this huge system and then is routed to interfaces.

The closest thing to real OOP we have is the Erlang/Elixir OTP libraries.

Another 'OOP' like abstraction is Homotopy Type Theory. Your program has 'paths', and they extend interfaces automatically but everything is functional in that there is no mutation.

The problem was a big design fuck up because of the OOP
But latter I found out I overused oop too, and nowadays I no longer use it at all. Only if I need to do some Qt stuff

Well try to read your own code without OOP after 1 month. It's unreadable. The whole point of a programming "language" is to say what a machine is suppose to do. That's why we don't develop in binary and we have compilers that make it readable for the machine. The whole point of OOP is that you make it readable for yourself.

Also
>I'm about to start my second year of a CS degree
>And it looks like "OOP" means that you couple all data structures and functions into "classes"

Putting quotation marks around "classes" means you really got bang for your buck from your """"""""""""degree"""""""""""". I'm glad I quit school a long time ago.

Or you can make various files, named properly, with simple functions that does their job and not produce some messy code. By reading the functions name and files name I'm able to say what each part of a program have to do.

The problem with not using OOP is that making unit tests for your code is nearly impossible. With OOP you can at least isolate classes and mock dependancies.

Checked.

But you're literally doing OOP by naming doing what you said.
You can just as well use namespaces and classes if you're at it.

As you will come to learn when you get a job
Most people, including programmers, are idiots.
Try and drill into them the merits of logical abstraction, small isolated units you can test or use as black boxes. You'll be met with blank stares like you're speaking a foreign language

It's easier to give up and just enforce a paradigm, and code review them.
Forcing people to make classes and objects is a way of making even a code monkey moron at least try and abstract something out of his code, even if they don't understand what they're doing and are just going through the motions cos they've been told to.

The most dangerous kind of idiot, is the one who is a mediocre or shit programmer, but *thinks* they're a good programmer. They eagerly eat up all the OOP stuff and start trying to apply "OOP patterns" they've seen before absolutely everywhere. That's how you end up with enterprise Java level tangled messes or pointless constructions that just obfuscate what's going on.

That's not doing OOP, that's called cleaning up your code. Not having to deal with classes, using proper structure, having them where you expect them to be and having the functions you actually needs. I was taught to program like that in C++, C, java.. OOP or not, to produce a clean code to anyone reading my shit.
To be honnest, i think oop or not, in the end, it doesn't matter. What matters is actually doing the job. But when you use a paradigm, juste make sure you can use it properly and not produce an abomination. I use OOP sometimes but still don't understand why some shit exists. I know some people use it and find them useful while I think it can be a loss of time

You can write good code without OOP for sure. You as in singular. You as a plural, collective of coders working on a project are probably a bunch of monkey slamming your hairy hands on keyboards and would murder eachother within a week if forced to work without some kind of abstraction like objects.

Seriously, just learn to live with it.

I don't understand and it's used by pajeets it therefore it's bullshit

yes, thats why banks backend run on java.

Yeah so using OOP makes that shit you wrote more readable. If you're not gonna use OOP, just write that shit in binary and install gentoo.