If I can do everything with structural programming, why did you create object-oriented?

Asked

Viewed 229 times

7

In the question about - Everything I can do in POO I can do in PE? - the answer accepted and better voted says:

Yes, any programming language can do anything. Now, each paradigm has its own way of organizing, so you can’t always do it the same way. Moreover, with some languages and use of certain paradigms it is possible that specific tasks are easier to do in one paradigm than in another.

That is, it states that it is possible, and that any programming language can do everything, whether structural or object-oriented.

Thinking about it, I would like to know: if "any programming language can do everything",

  • Why they created object orientation?
  • Was it a need to increase the language / improve it? Or was it simply to follow the "modinha"?

P.S.: More general views of languages, to my point of view can be answered, but I would like to know specifically the language PHP.

  • 4

    "it is possible that specific tasks are easier to do in one paradigm than in another" no longer answers that question?

  • 2

    Long story short: OO focuses a lot on encapsulation and can even be used in C; OO support in the language allows you to use the good things of OO in a leaner syntax

  • 3

    For the same reason that with horses you would go anywhere, but still there were those who wanted to invent cars and trains.

2 answers

13


To organize better codes complexes, to better handle extended domains. Yes, do OOP in scripts, Fleeting, simple, not advantageous applications. But luckily many people don’t do OOP on these things, even though they say they do.

OOP is fashionable if you consider that people use where they shouldn’t. Modinha is not something fleeting, it is something that is only being used because people use it, without a clear reason. It is not modinha when used where it is useful. It’s very modinha when the person says what is doing and is not even, she just wants to be part of the group that’s "pumping". And as I said in previous answer, is teen sex.

The creation of OOP has nothing of modinha. Most of the technologies are not modinhas. The same cannot be said of various methodologies that were even created to meet a need, but fail to deliver.

It is like carrying a gun, just to take an example. It is useful, but to defend that everyone should be able to have a gun is modinha. Doesn’t meet a real need, but a made-up one.

In PHP in general it is modinha. Has case that is not, but it is rare. And honestly when it’s appropriate, it’s usually the wrong language for that problem. PHP is more languages than script that exists, until the way of naming variable indicates it. Putting OOP in PHP was and is still modinha. Of course the most accurate definition of this is survival. Today few things need scripts (or even has several, but that you create in a snap of fingers and encloses, does not generate work), the thick of the development are on top of complex things. Without OOP the language would define a very small niche, which happened with Perl. But then the language became inconsistent.

OOP is much harder to understand and do right, so much so that almost everyone does wrong. It’s very common for people to complicate their design to try to be OOP without bringing any advantage.

OOP is great in these cases of many relationships between objects, when objects are very complex, when there are subtype relations, hierarchies. GUI benefits greatly from this. Games often benefit, some types of business, but far more rare. Frameworks and more complex libraries can benefit greatly.

I stress that the answer says that OOP and PE are very different things. I would like everyone to read the links there to understand a little more about OOP (I know I didn’t fully respond) and understand that structured programming is something very simple and focuses on another aspect of programming that OOP doesn’t focus on. Structured programming is not about code organization, it’s about algorithm flow.

2

Each type of programming paradigm serves a purpose, but as you said, structural can make the functions of an Object-Oriented, but when it comes solely and exclusively to Objects, the POO languages are much easier to work and manage (mostly) memory in a better way for that purpose.

POO has concepts of inheritance, Abstract classes (Java) and encapsulation, which is the focus of this paradigm, which saves the programmer from many lines of code.

If we were to follow the logic that a single language is fundamental we would be programming in Assembly today, or even in Binary, which doesn’t seem very inviting, right?

So the answer to why other languages are created is simple: Each one serves a purpose, but with natural evolution the language comes encompassing greater content.

Is worth reading from Programming paradigms and its differences

  • 2

    The impression I had that was not what was asked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.