Object Oriented Programming vs Procedural Programm

2019-12-16 20:42发布

问题:

Can we use Procedural Programming to solve any problem that can be solved using Object Oriented Programming Concepts? My problem is are there some particular problems which can only be solved using OOP concepts.

Please help me understand this.

回答1:

Yes. Anything that can be solved using OOP can be solved using procedural programming. In the end the compiler just turns your OOP code into assembly, which is procedural.

It all comes down to what the combination of the CPU/RAM etc in your computer can do. Since your computer is Turing Complete it can solve any problem that be solved by any other language or machine that is also Turing Complete.



回答2:

Nearly all programming languages are "Turing complete". That means programs written in one paradigm (say the functional one) can always be converted to another one (say the logical one). A compiler is just a tool that translates code from one language/paradigm to another. Thus the moment a language is Turing complete, you can solve anything in that language you can in any other, although the performance and elegance of the code might vary.

Currently on the hardware level, the only implemented paradigm is the procedural one (there have been some experiments with the functional and logical one and even OO has already been implemented on a CPU).