Cpp Review P01

帅哥带我学习Cpp -- P01

Posted by Sofia on April 6, 2021

Background

After university, I have completely moved to be a Java guy and it has been four years since then. As I found some fun stuffs in Computer Graphics recently which replies so much on Cpp, I think I should pick up everything I dropped to consolidate the foundation and continue my study on Computer Graphics. This is a series to review Cpp as a Java developer following The Cherno.

Cpp Compiler

Cpp compiler just convert codes into constant data and machine code, which are the .obj files. While in Java, codes are converted into bytecodes, which are .class files. Bytecodes cannot be understand by machine however, they will be converted again to become machine code by just-in-time (JIT) compiler in JVM during runtime.

It can be very helpful to check the pre-processing files through Visual Studio and learn if your code is of high quality from machine codes.

Cpp Linker

Linker uses generated .obj files and combine them into a single executable program. Besides .obj files, linker also link library files which specifies with #include; These library files are a collection of precompile code that has been packaged up for reuse in other programs. Cpp has an extensive library called C++ Standard Library, which provides additional functionality that you can use in programs.

C++ faster than JVM?

Generally speaking, Java uses more memory and it does not have good utilization of cache. We will get back to this topic and discuss more in the futures. Here is an answer that I think is makes good sense.

Reference

How the C++ Compiler Works

How the C++ Linker Works