官术网_书友最值得收藏!

  • Extreme C
  • Kamran Amini
  • 358字
  • 2021-03-26 16:15:44

C is not object-oriented, but why?

C is not object-oriented, but not because of its age. If age was a reason, we could have found a way to make it object-oriented by now. But, as you will see in Chapter 12, The Most Recent C, the latest standard of the C programming language, C18, doesn't try to make C an object-oriented language.

On the other hand, we have C++, which is the result of all efforts to have an OOP language based on C. If the fate of C was for it to be replaced by an object-oriented language, then there wouldn't be any demand for C today, mainly because of C++ – but the current demand for C engineers shows that this is not the case.

A human thinks in an object-oriented way, but a CPU executes machine-level instructions which are procedural. A CPU just executes a set of instructions one by one, and from time to time, it has to jump, fetch, and execute other instructions from a different address in memory; quite similar to function calls in a program written using a procedural programming language like C.

C cannot be object-oriented because it is located on the barrier between object orientation and procedural programming. Object orientation is the human understanding of a problem and procedural execution is what a CPU can do. Therefore, we need something to be in this position and make this barrier. Otherwise high-level programs, which are usually written in an object-oriented way, cannot be translated directly into procedural instructions to be fed into the CPU.

If you look at high-level programming languages like Java, JavaScript, Python, Ruby, and so on, they have a component or layer within their architecture which bridges between their environment and the actual C library found inside the operating system (the Standard C Library in Unix-like systems and Win32 API in Windows systems). For instance, Java Virtual Machine (JVM) does that in a Java platform. While not all these environments are necessarily object-oriented (for example JavaScript or Python can be both procedural and object-oriented), they need this layer to translate their high-level logic to low-level procedural instructions.

主站蜘蛛池模板: 大邑县| 雷山县| 大庆市| 大丰市| 钟山县| 昌邑市| 沾益县| 阜新| 溧阳市| 渝中区| 黄冈市| 鄯善县| 房产| 五常市| 凤城市| 延庆县| 原平市| 乌拉特前旗| 黄冈市| 永登县| 商洛市| 宁国市| 伊金霍洛旗| 英超| 南木林县| 隆昌县| 榆树市| 都安| 什邡市| 玉环县| 育儿| 马山县| 双鸭山市| 肇源县| 和硕县| 积石山| 崇州市| 融水| 朝阳县| 连江县| 滕州市|