Beginner OOP questions

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.


That depends a lot on the actual algorithm you're trying to implement, and on the compiler (those have gotten very smart in the past years). The compiled code definitely won't be byte-for-byte identical, and it may be even completely different (again, depends on the algorithm you're implementing). In reality, it doesn't matter.

The difference in speed of the program will be negligible in most cases - unless you're doing something grossly inefficient in one form or the other (and this will be most likely related to your business logic and the algorithms you'll use to implement it, not to programming paradigm), this won't be a concern.

The other, often neglected but crucial, speed difference lies in maintainability: computer time is, in most cases, cheap; programmer time is expensive. (That's not to say "write bloatware", but rather "don't waste a week figuring out how it works when somebody else needs to update the logic, three years from now")


All languages produce the same code, like ASM (machine code), except languages that produces bytecode (ex: Java) or interpreted languages (ex: Python, PHP)