General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Lepi Doptera
Programming with Mosh
comments
Comments by "Lepi Doptera" (@lepidoptera9337) on "Programming with Mosh" channel.
Yes, you are thinking about it in the right way. OOP was originally invented to allow automatic code reuse by the compiler on machines with very small memory (typically 16kWords). The chosen granularity at the function level does, however, lead to the opposite. If a child class wants to change just one line of a hundred in the parent's member function, it has to either fork the entire function (welcome to code duplication debugging hell!) or it has to decompose the original member function at the level of the parent into three parts (beginning, middle, end) to change the line in middle(). Sounds like a fun game a rational programmer will play, doesn't it? Just kidding. ;-)
2
What is happening here is that the compiler moves some stuff that you would do without OOP at runtime (like type checking) into the compile time domain. That can occasionally save you a few bytes of executable and a few ten ns of execution time. Other than that you are buying a world of hurt, which you won't notice until you are working on a large OOP project. At the end of the day you have to understand that there is no such thing as an OOP executable. By the time the compiler is done, absolutely everything that you wrote in OOP style has disappeared. In other words... OOP is basically just a documentation style.
2
There is no big difference. OOP is basically a syntactically nicer form of typedef for structures that also contain function pointers. Much of what you can do with one you can also do with the other. The compiler will handle name spaces and access rights for you, which leads to a perception of more "security" in statically typed languages. In dynamic languages like Python you don't even get that.
1
He isn't teaching, kid. He is raking up YouTube views with a misleading title. ;-)
1
What does that have to do with C++? :-)
1
In procedural programming things that belong together are inside of libraries with well defined interfaces. You sound like an amateur who knows nothing about any programming style. Or you are just a troll. Can't tell which, yet. ;-)
1
You need to get help. ;-)
1
@zackakai5173 Functional programming lies in the foothills of Mount Stupid, though. It is just another ideology that doesn't give a shit about the real world.
1
@TheProphetofLogic Yes, you need to get serious help with that. I was a physicist who worked for CERN, by the way, and some of the programming that is being done at CERN is among the worst you can find in the entire world. ;-)
1
@TheProphetofLogic Respect has to be earned, kid. What you really NEED is tolerance. Without tolerance life turns to hell. But then, you didn't pay attention in history class, either... :-) When I say that you need help I mean it. I want you to become your best. Right now you are close to rock bottom.
1
@TheProphetofLogic You didn't do anything to be born. Your Mom did most of the work. You Dad may or may not have had fun while he made his two minute contribution. Are you kidding me??? I should respect you for what your Mom did? If that is what you think, then your Mom and Dad did not do a good job raising you, either. Anyway, if this is what you think about reality, then your do-over medal and participation trophy are in the mail. You clearly need and deserve them. ;-) And, no, you didn't make that lovely Spanish fish restaurant, either. That atmosphere is the achievement of the owner and his employees. Neither did you make your phone or the battery or the charge in the battery. You are basically just leeching off other people's work, but you expect me to admire you for that. Dude. Seriously. Just how old are you? ;-) OK, this is getting real fun now. I love talking to immature folks on the internet.
1
@TheProphetofLogic Are you back to demand even more respect for an even larger pile of bullshit? ;-)
1
@TheProphetofLogic And why are you feeling so sorry for yourself, anyway? Didn't you say you wanted to be respected as a bullshitter? ;-)
1
@TheProphetofLogic So what you are saying is that it is very important to you that I take you seriously. :-)
1
@TheProphetofLogic Now you are catching on. I love feeding trolls. ;-)
1
@TheProphetofLogic Everything we call real is the result of an irreversible energy transfer. That's second year undergrad physics, kid. ;-)
1
@TheProphetofLogic I already realized in high school that there are two kinds of students: those who are paying attention in physics class and then there are the losers. ;-)
1
But that's pretty much what it does... and that is NOT a good thing. Switch statements are much, much, much more versatile than polymorphism. If there is one thing you should become really good at as a programmer it is the creative use of switch statements. For one thing they can reduce your call tree from a jumbled mess to a small number of extremely well defined state machines. If you have anything to do with architecture, then you should learn that state machines are inherently safe and provable, while random function calls are the exact opposite.
1
It's a little more than that because of inheritance. If you want, you can simulate inheritance by hand with namespaces, but it's tedious. An OOP language keeps all of that in compiler tables for you. OTOH... the general recommendation is NOT to use inheritance to begin with because it leads to a lot of problems down the road (endless restructuring if you got it wrong in the beginning).
1
Anybody who screams "side effect" in the theater has just given away that they are absolutely clueless about computing. ;-)
1
@tigrankhachaturian8983 All of computing is about generating side effects (a result). The functional approach in CS was invented as a mathematical proof technique. It has absolutely no use for actual computation and is physically impossible (every computer generates heat as a completely unavoidable side effect).
1
Did you manage to program pong, yet? ;-)
1
Except that doctors are actually helping people, are being respected and they are being paid way more. :-)
1
At least that's the theory. In practice it leads to either endless restructuring or to creative workarounds. Redundant code was a great argument in the deep past when OOP was invented (the 1960s). At that time your computer had 32kWords of memory, so you really, really wanted to squeeze the last byte out of your code. Today your computer has 16GBytes or more and there is absolutely no significance to code size optimization. You will NEVER write that much code to begin with. Almost all of your memory contains data and not code.
1
That's because it's a very naive take on what OOP is. It tells you the theoretical structure but not the actual repercussions if you try to do this, which will only become clear once you develop a project in an OOP style and you start running into a lot of problems with it. The examples that you are being shown on the internet are typically unrealistic. In this case employee information is typically stored in databases and things like wage calculations are much, much more complicated because you have to pay taxes for your employees. You will never encounter a problem like this in the wild for those reasons alone. The sole domain in which I have found OOP somewhat useful are graphical user interface widget libraries. Everywhere else it seems to be getting more in the way of what you are trying to do than that it's helping.
1
OMG, you have created an age calculator! You CS Nobel is in the mail. ;-)
1
Say Hi, but I am not giving money. ;-)
1