What is the difference between compiled programs & interpreted programs ?What can we do in python Compilation or interpretation? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What is the difference between compiled programs & interpreted programs ?What can we do in python Compilation or interpretation?

4th Jun 2020, 2:03 PM
Rajan K
Rajan K - avatar
2 Answers
+ 2
#2 First off, interpreted/compiled is not a property of the language but a property of the implementation. For most languages, most if not all implementations fall in one category, so one might save a few words saying the language is interpreted/compiled too, but it's still an important distinction, both because it aids understanding and because there are quite a few languages with usable implementations of both kinds (mostly in the realm of functional languages, see Haskell and ML). In addition, there are C interpreters and projects that attempt to compile a subset of Python to C or C++ code (and subsequently to machine code). Second, compilation is not restricted to ahead-of-time compilation to native machine code. A compiler is, more generally, a program that converts a program in one programming language into a program in another programming language (arguably, you can even have a compiler with the same input and output language if significant transformations are applied).
4th Jun 2020, 2:18 PM
Abdulsalam Al-Ashwal
Abdulsalam Al-Ashwal - avatar
+ 2
The difference is not in the language; it is in the implementation. Having got that out of my system, here's an answer: In a compiled implementation, the original program is translated into native machine instructions, which are executed directly by the hardware. In an interpreted implementation, the original program is translated into something else. Another program, called "the interpreter", then examines "something else" and performs whatever actions are called for. Depending on the language and its implementation, there are a variety of forms of "something else". From more popular to less popular, "something else" might be Binary instructions for a virtual machine, often called bytecode, as is done in Lua, Python, Ruby, Smalltalk, and many other systems (the approach was popularized in the 1970s by the UCSD P-system and UCSD Pascal) A tree-like representation of the original program, such as an abstract-syntax tree, as is done for many prototype or educational interpreters A tokenized representation
4th Jun 2020, 2:13 PM
Abdulsalam Al-Ashwal
Abdulsalam Al-Ashwal - avatar