In: Computer Science
Interpreter and compiler are two methods to convert high level languages to machine language. How Python and C++ language works?
Compiler and Interpreter both are used to convert the high level languages into machine languages.
The python uses both compiler and interpreter. After writing the source code (.py files)at first compiler will convert the source code into byte code. In python it is simply a translation. The byte codes generated by the compiler are in lower-level format and platform independent.
After compilation it will generate a file (.pyc) where the byte codes are stored. Unlike JAVA after convertion into .pyc file the content of this file i.e/ byte codes will load into python runtime environment , where this will be interpreted by python virtual machine. In this state he byte code will read line by line and the codes will be executed. The bytecodes will execute automatically .
C++
In C++ first the source code will be compiled and the compiled instructions are stored in an object file(.obj). The first step of the compiler is to run the preprocessors with source code. Header files are not compiled rather these are included from the source files. Each and every header files are open during the compilation time(those are related with source file only.) . The preprocessor will create a translation unit by inserting the contents. After completion of preprocessor compiler will start its work and convert the lines into object codes to form the object code file. After creation of object code file then it will create an executable file to execute the codes.Now the .exe file will execute the codes.