[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


Why does everyone hate object oriented programming?

I've seen people complain about it all the time. The past month I've been trying to learn Python, I finally got to oop sections and it's actually comfy as fuck. So much easier and maneagble than writing dictionaries and all that.
>>
>>106934620
wait until you learn about functional programming
>>
Let's turn a 1ms function call into 26ms because nigger.method() is comfier than method(nigger).
>>
>>106934802
If you're just writing scripts this difference is virtually irrelevant. Can your eyes notice if an program runs 20ms slower? It does make a difference if you're building low-level systems, in which case you don't use a scripting language.
>>
>>106934620
OOP in itself isn't that bad. it may have some negative performance characteristics, but for the majority of applications the overhead caused by OOP is unnoticeable or doesn't exist due to, for example, optimising compilers
it's retards creating object hierarchies 50 links deep that give it a bad name. lots of programmers overuse inheritance over composition. also you have to remember that for a long time java was the standard programming language and it took "everything is an object" to an extreme. it's a lot better nowadays especially if you use a JVM language like kotlin instead of java itself, but even "plain" java is a lot more palatable than it used to be
another negative thing that people associate with OOP is that there are a lot of insanely obtuse patterns like spring boot's dependency injection or other frameworks' annotation-based DI which don't really exist in non-OOP contexts (not in the same way, anyway. it's usually a lot simpler)
ultimately you have to consider the complaints about OOP in the context of its history
>>
>>106934620
don't mind methods, I just have inheritance
>>
>>106934802
>lets turn a 200ns (nanosecond) call into a 400ns call because nigger.method() is comfier than method(nigger)
FTFY
>>
>>106934802
the most primitive class is a struct with function pointers for methods and normal vars for methods
that shit aint gonna take 26x time that normal code execution is taking
>b-but oop is not using the most primitive implementation or implementations comparable in perfomance to it
then it means the language in question is utter overbloated shit with shitty optimizations and you're gonna use it only when necessary.
>>
>>106935169
>vars for methods
members
>>
>>106934620
>So much easier and maneagble than writing dictionaries and all that.
Objects in python are just syntactic sugar for dictionaries-
>>
>>106934620
>Why does everyone hate object oriented programming?
because it encourages you to waste your time developing elaborate class hierarchies and trying to side-step retarded limitations in the language and object model rather than focus on what the computer is actually doing
>a Labrador is a Dog
>a Dog is a Mammal
>a Mammal is an Animal
>an Animal is a LivingThing
>a LivingThing is a PhysicalObject
works great, but then you get to
>a Cabinet is a Furniture
>a Cabinet is also a Container
>a Cabinet is also a Room (if large enough??? but what if it's not large enough)
>a Furniture and a Container is both a PhysicalObject
>now you've caused code bloat because of your stupid abstraction
>>
>>106934620
Cute!
>So much easier and maneagble than writing dictionaries and all that.
These are not the same. Keep learning and you might find out why OOP is garbage.
>>
oop is mostly a naming convention. the program gets structured differently, but the control flow is pretty much identical. some people hate it for that reason and i think that is valid, most of the complaints are pretty stupid.
#include <iostream>

struct S {
int v_;
S(const int& val) : v_(val) { }
};

int add(S* s, const int& val)
{
return s->v_ + val;
}

class C {
private:
int v_; /// note this is private
public:
C(const int& val) : v_(val) { }
int add(const int& val) const;
};

int C::add(const int& val) const
{
return v_ + val;
}

int main()
{
S s(10);
C c(10);
std::cout << add(&s, 20) << "\n" << c.add(20) << "\n";
return 0;
}
>>
>>106935954
This is not OOP
>>
>>106934620
>>106934802
>>106935163
>>106935169
The OOP slow bloat problem is inheritance, not syntax.
Yes, inheritance is a necessary requirement for OOP. C structs are not OOP.
>>
>>106936007
this is actually exactly what oop is. a struct with member functions and private data. the class becomes essentially a namespace for the member function, and a pointer to itself is available inside the member function. i understand that there is polymorphism, multiple inheritance, final, pure virtual classes etc, but these are nothing more than semantics to reduce code and provide rigidity. just because its not the "human" is derived from "animal" doesn't mean this is not oop.
>>
>>106936069
just to give a new perspective the original c++ compilers actually transpiled the code to C because it was easier than writing a compiler or compiler front end.
>>
>>106934620
I write in python and I write every function like I do in C. Never in my life have I used any OOP concept in python. There simply is no reason to complicate the code when it can be simple and majestic.
>>
>>106934802
All code is basically instantaneous. Any time is network calls to the outside web or actually processing something that is reliant on your hardware not code (i.e. transcoding videos with ffmpeg).
>>
File: 1732366235882361.png (250 KB, 718x588)
250 KB
250 KB PNG
>>106934620
No, we just hate python as it a nocoder lingo no sane developer would ever use.
>>
>>106934620
oop was designed for managing big projects, expecially for collaborations, handovers and maintenance easily. if you're programming alone, there is no point of oop, even it would cause performance degradation
>>
>>106935954
Disgusting
>>
>>106936546
You are a fucking idiot.
>>106936069
No, is not. You moron.
>>106936007
Wrong, you stupid piece of shit.
>>
>>106934620
Most of the OOP bad reputation comes from retards creating unnecessary problems to have a sorry ass excuse to use their favorite design pattern or language feature.
>>
>len(obj) actually just calls obj.__len__()
Weird language, and there's bunch of these functions that simply call an object method with a pre-determined name. Why the abstraction?
>>
>>106934620
OOP is shit, it makes you organize code in ways that have nothing to do with the computer and only as conceptual ideas

anyone who promotes OOP is midwit who learned C++/Java and now everything is a nail to hit with their hammer

the reason that software is slow is because Silicon Valley thought it would be a good idea to hire jeets who are only smart enough to use libraries and frameworks and dont question authority

real programmers work real programming jobs and use real programming languages, none of which are C++, Java, C#, Python

they use C, Rust, Julia, Javascript, Ruby

https://www.youtube.com/watch?v=ToBF_mLxEcI
>>
File: i like tits.jpg (2.57 MB, 2718x2508)
2.57 MB
2.57 MB JPG
>So much easier and maneagble than writing dictionaries and all that.
????
you... you're actually writing algorithms and programs, right? don't be a fool
>where i give it credit
It lends itself nicely towards simulation.
Sometimes, the most elegant way to do things is just to define the interfaces and have them work together. For what I'm working on currently, having functionality packaged like this is almost natural.
>where i strongly dislike it
I've yet to be convinced that information hiding isn't completely dumb.
With people who don't know better, it is extremely easy to end up with enormous classes implementing every hammer and saw, and every object lugging that toolbox along. Numerous classes sputtered about with huge type hierarchies going nowhere in particular. Classes need to be defined carefully, as themselves without too much reliance on inheritance, and kept as small and flat as possible.
While presenting zero evidence, I will state that most things really are just functional or procedural and most elegantly expressed that way. Data is to be defined separately, as it is in the computer.
This one is a very particular personal fashionfaggotry, and maybe you could not give a shit, but my preference nowadays is really with minimalistic languages, and almost every OOP-heavy language seems to have an enormous amount of supporting baggage and sugar invested in this one convention. Sometimes it stalks you and soaks every convention, like with C++ and Java. Sometimes, like with Python, it's tucked away until you peek behind the curtain.
As a sidenote, Go is Python done right, honestly.
>>
>>106936546
>All code is basically instantaneous
I'm not that other idiot, but don't you think this is kind of an insane statement to make?
Program design can be the difference between a task taking minutes or days, even on current hardware.
>>
File: object.jpg (363 KB, 2048x1536)
363 KB
363 KB JPG
>>106934620
OOP is fine if you use it where it's actually appropriate. Which most people don't.
Used where it isn't necessary, it makes the code much more messy and slow.
Of course people deride it when your average OOP project looks little better than this: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
>>
File: 1760620068235781.jpg (73 KB, 424x536)
73 KB
73 KB JPG
>>106937477
>image
What book?
>>
>>106934620
it's fine if you avoid class inheritance and only use classes for when you have state. functional for everything else.
the main benefit of oop is that it allows you to enforce stronger invariants for your state by limiting access to it via the class interface. everything else is just for convenience to make this work more nicely.
don't get sucked into the idea that classes are somehow the canonical tool to model "real" things or you'll write lots of bad code with unnecessary state.

t. one of the developers of a certain popular purely functional programming language
>>
Every oop shill has a different pet definition of what oop is. You have some people who claim stack allocated structs that have functions which act upon said structs is oop, you have some people who claim that it must be a compile time hierarchy of objects which is used to structure a program. Because oop lovers can't even come to a consensus definition of what oop is, it is pointless even trying to argue with them because they themselves do not have a solid grasp of what it is and thus it is a completely different thing person to person. In my opinion The best definition of what oop is and why it is bad comes from these 2 videos - and yes, the concept is so convoluted and all over the place that you have to watch hours of videos just to get a definition.
https://www.youtube.com/watch?v=wo84LFzx5nI&t
https://www.youtube.com/watch?v=QM1iUe6IofM
>>
>>106937559
Ocaml?
>>
>>106934620
>Why does everyone hate object oriented programming?
Because it's shit. If you believe otherwise, you're just repeating what you heard in school and never actually write code yourself.
>>
>>106934802
Even if it had no performance impact (it generally doesn't in non-virtual functions in Sepples for instance), it's just a pointless syntactic irregularity that doesn't make the language any more expressive or powerful.

Record classes, since they were introduced in Simula, have been a solution looking for a problem.
>>
>>106937571
>Every oop shill has a different pet definition of what oop is.
This.
It's impossible to criticize OOP because no matter which arguments you bring to the table, they will just arbitrarily change the definition.

https://medium.com/@jacobfriedman/object-oriented-programming-is-an-expensive-disaster-which-must-end-2cbf3ea4f89d
>>
>>106934620
>Why does everyone hate object oriented programming?
false. try leaving this echo chamber once in a while.
>>
>>106936942
Definitely not because that size of codebase is not something a single person here will ever produce even if given 20 years. Computers are too fast now... If one of my programs skips actual intense work like FFmpeg or network call wait times, it finishes in about 1 second for IIRC 36K lines of code.
>>
File: 1754159283947901.jpg (25 KB, 341x339)
25 KB
25 KB JPG
>>106937477
>https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
Holy fuck this is amazing
>>
>>106936712
Braindamage
>>
What's the redpill on python?
>>
>>106934620
Some people can't into organizing their sloppy shit so they make a bunch of "helpers" and "util" classes full of disconnected bullshit and complain they can't test their shit after they shipped it.
Some people are traumatized by trying to use Java Enterprise patterns (unironically) where all they really needed was a shell script or perl.
Other people then take those experiences and apply them to all object modeling and use it to shill lisp derivatives to brainlets and coffee-drinking macbook wielding hipster fucks who learned how to start Dreamweaver or Microsoft Frontpage once.
Fuck them and their mothers with a polymorphic overloaded instance method on my dick.
Python is also shit, but it's fine. Mostly it's causing an even bigger code quality decline because if semicolons and braces were the thing stopping someone from coding they aren't going to make anything half decent without training wheels.
>>
>>106934620
it's one of those "good enough to sneak past testing but sets prod on fire". fine for simple things like datetime but then people start trying to wrap real life concepts with that and end up with cross cutting concerns.
>>
>>106937754
>>106937571
Schools indoctrinate you into OOP. It's hard to avoid. I never finished my degree, but i found myself struggling to think differently once they hammered it into my head. The downsides of OOP are very apparent, but getting out of that mindset is hard. I ended up switching majors.
>>
>>106934620
Same here, am learning JavaScript and got to the oop section as well and I quite enjoy it
>>
>>106935562
What's wrong with this?
PhysicalObject can implement move(Newton force) which compares force to the mass attribute PhysicalObject has (and maybe gravity and friction details if needed) and performs a change in the spatial coordinates if the force is large enough.
Or throws an ImmovableObjectException which is probably a checked exception.
That's exactly what OOP is good for.
Now if you have a BoxCar which extends from RailroadWagon which also implements Train.Consist you can overload move(Newton force) to check for a reference to Rail and respond appropriately if the BoxCar is moved along the rail or against it (as in derail / hulk smash). And Train.Consist could interrogate each object in its consist in turn with move to see if the train can move when Train.accelerate() is invoked.
>>
>>106938241
>ImmovableObjectException
what if the argument is an UnstoppableForce
>>
>>106938241
You jest but this exact scenario pops up all the time, just with different labels.
>>
>>106938134
>What's the redpill on python?
its a hacked together language that was never fixed

the very first scripting language was Perl in 1987, before that there were only shell languages. Python came out in 1991 and the syntax was entirely a ripoff of the ABC language, but a lot worse because it was just hacked together adhoc by a guy who used Perl a lot. Things like having to use double underscore function names is something that should have been removed early on but never did because the language quickly became popular because of the pretty syntax that was very uncommon at the time, especially for scripting languages. The packaging system is a complete joke, have to create environments in a file. I honestly cant believe this never got replaced by any sane package managing system especially considering how much Python is used in the scientific community. The only good thing about Python is the imperative syntax ripped off from ABC, the OO is a joke. Functional programming features are mostly non-existent. The only way to fix Python is to make a new language from scratch which obviously can never happen
>>
>>106938342
I'm not even jesting.
I model objects like that in most of my Python stuff too, and my main gripe these days is you have to manually implement a demote to dict and promote to object from dict for most things because Python's libraries talk dict but my mutation methods are on object.
Thing.frob(args) instead of frob(Thing (as dict of strings), args).
Java doesn't have that problem but because its dictionary support is just Map<> and various flavors of JSON parsers doing small things with shitty nested webshit data is a pain in the arse.
>>
As I understand it, python is being used in ways that it shouldn't be, however when used as a scripting language it's fine for productivity benefits yet LUA is a better option for performance.
>>
>>106934802
What's with the nazi dogwhistle? It totally undermines the point you're trying to make.
>>
>>106938601
if isReich(3) {
for {
fmt.Printf("Heil\n")
}
}



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.