3 ms·
Object-Oriented Programming Is Bad
- robomartin 5y agoI could not agree more with the points being made in this presentation. It pains me to see just how ingrained OO has become --due to it being taught in school almost as the only way to program. I have seen the results of this in open source libraries with insanely complex object structures that can often be reduced down to very few lines of procedural code. The most extreme case of this I have seen was a serial communications library for Arduino. I showed this to my son, who, at the time, was in the middle of his CS degree journey. After understanding what the library did, I rewrote it in four lines of code. The other aspect of this issue is performance. Being that quite a bit of my work for over 30 years has been focused around real-time hardware, embedded systems and robotics, performance has always been at the top of my list. OO can be absolutely horrific in this regard. I remember writing an iOS application back in iPhone 3 days, which meant Objective-C. I used all of the native object data types and kept it to Objective-C. The performance was absolutely horrible and unusable. The application was based around a genetic solver. It needed to run thousands of generations fast, as fast as the user clicked on a button. Well, that wasn't happening at all. I re-coded the entire thing procedurally and got rid of every single object data type and calls to encapsulated object functionality. The genetic solver ran nearly 400 times faster with a marked reduction in resources. Of course, my journey through programming has been very different from what students experience today. I started with machine language, then moved to assembler, C, Forth, LISP, APL and beyond. C++ came into my life after these languages had been part of my work for years. Exploding a codebase into nearly incomprehensible hierarchies of inheritance and polymorphism-laden classes made little sense to me at the time. Yet, I dutifully jumped on the bandwagon and adopted the cult at the time. It didn't take long for me to privately think "this is bullshit" and, eventually, express the opinion in a more public form. I can't remember the last time procedural programming has prevented a project to be completed on time and with the requisite functionality. This spans consumer to industrial and aerospace projects. I will use OO when absolutely necessary and justified. If you are using Django and have to create class-based views, well, enjoy. On embedded systems? Not necessarily. I know this is likely to be controversial. When you have a whole generation of people for whom the first thing they type on a fresh source file after some imports is "class", well, they might just not be equipped to understand they don't have to. That's just reality.
- kgbcia 5y agoi like oop for namespaces. if only c had them. I recently went back to php after JavaScript. Js has a string object, so if you want any string function you know where to look. Php has a bunch of functions with str prefixes which could lead to namespace collision. I like oop because of custom types. Awhile back I had to create a vector class in python. Since Python support type hints, vscode automatically warned me if I pass the wrong object.
- bluenose69 5y agoThe speaker raises key points in a remarkably clear and engaging way. I end up watching many lectures at 1.5 or 2.0 speed, because they so often have low information density. Not so, in this case. If you're interested in programming, you owe it to yourself to spend 3/4 hour on this. You may also find yourself pausing the video from time to time, to sit back and appreciate the elegance of the exposition. A lot of nails are hit precisely on the head in this lecture.
- karmakaze 5y agoIt doesn't seem to be a very historically accurate or cover modern examples where OOP works well. The original OOP was Simula 67 used for simulation that doesn't use the definition of OOP in the video. I have no idea where that one comes from. I'd say maybe 50% of application code I see (not write) are web UI/clients. Something like React with OOP components work very well. Same goes for mobile or UI's in general. The argument would be more persuasive if it used a more common definition of OOP and concrete examples of both good and bad applications to show which kinds of cases fit and which don't.
- akhmatova 5y agoThis is silly. Yes, the cult of OO (and overuse of OO) is bad. But at the end of the day it helps people get stuff done. Even if it may be "flawed" in concept. So in that category it's just like ... Unix, TCP/IP, or ... ASCII, or ... just about any large-scale programming language you can think of. Just another variant in the "Why the 'else' statement is bad" genre, this video.
- deleted 5y ago[deleted]
- JaceLightning 5y agoSpeaker seems like he has never worked on a large project nor understands OOP. He mentions Single responsibility principal but then seems to understand its usage or effectiveness, saying that your logic is scattered all over the code base. It's not if you do OOP right.