Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Object-Oriented Programming in Interpreted languages (i.e, PHP) efficient? [closed]

I was just wondering whether it would be worth sticking to non-OOP code for the sake of speed. Also, In commercial web-applications, is OOP generally used or avoided? Which is the standard?

Many Thanks,

Ed

like image 433
Edward Avatar asked Nov 18 '12 00:11

Edward


People also ask

Is object-oriented programming efficient?

Object-oriented programming (OOP) is a way of thinking about and organizing code for maximum reusability. With this type of programming, a program comprises objects that can interact with the user, other objects, or other programs. This makes programs more efficient and easier to understand.

Is PHP considered object oriented language?

The PHP language itself is not object oriented. The Ruby language is object oriented, so is Java with exception of the primitive types. PHP is a hybrid language capable of objects creation, so is Delphi. There is a big semantic difference between a hybrid language and a object oriented language.

Is PHP functional or object-oriented?

Again, PHP is an example of an object oriented language and we can compare its procedural operations with its OOP implementations of the same functions; taking a mysqli prepared statement, for example.


2 Answers

The standard is to favor readable code over efficiency, because most of the time "more efficient code" runs faster by a single millisecond. Object-oriented programming is generally more readable than a non-object-oriented counterpart.

See also this question: Why are so many web languages interpreted rather than compiled?. The majority of a page's load time is spent sending and receiving data or doing database things.

like image 196
Waleed Khan Avatar answered Sep 18 '22 23:09

Waleed Khan


OOP is generally used in commercial webapps, and is turning to be the standard. The reason for it is not efficiency - it's code re-usability, code readability, easy documentation, structure, and more importantly modularity!

like image 29
Sébastien Renauld Avatar answered Sep 19 '22 23:09

Sébastien Renauld