Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Beginner OOP questions

I just want to ask two quick questions about OOP.

First, is the code actually produced by OOP language compiler any different from procedural language compiler? I mean, is OOP just about how you write the code, or is the actual compiled code different from procedural? More accurate, procedural languages like C basically produce code like it would be written in ASM. But is OOP code any different?

And second, if OOP code uses different approach in its machine code form, is it slower or faster than procedural? Thanks.

like image 499
B.Gen.Jack.O.Neill Avatar asked Aug 26 '10 15:08

B.Gen.Jack.O.Neill


People also ask

What are the 4 basics of OOP?

Abstraction, encapsulation, inheritance, and polymorphism are four of the main principles of object-oriented programming.

How do you explain OOPs for beginners?

Object oriented programming (or OOP) is a collection of objects (data) and patterns of their interactions around data, or objects, rather than functions and logic.


1 Answers

First, no. For languages that are compiled to native machine code, this is certainly true. After all, assembly and machine code have no notion of objects.

For languages which run in a virtual machine like Java or C# this is partially true. Here, the VM may support some object-specific features.

It is possible to write OOP in non-object-oriented languages, and the other way around. OOP is mainly useful for the programmer, and the restrictions it imposes (that you can not access private methods from another class, for example) are checked by the compiler but not passed on in the output.

Second, there is no performance difference for OOP or procedural. It is just that the code and the data are located in different places in the code.

like image 139
Sjoerd Avatar answered Oct 13 '22 03:10

Sjoerd