Python Is a Compiled Language(eddieantonio.ca)
eddieantonio.ca
Python Is a Compiled Language
https://eddieantonio.ca/blog/2023/10/25/python-is-a-compiled-language/
6 comments
I think a lot of people in the comments are hung up on defining compiler as "taking a source language and producing a binary". I personally know Eddie and I agree with his points. (Even though his title is a bit provocative and contradicts one of the points in the article "A language is not inherently compiled or interpreted; whether a language is compiled or interpreted (or both!) is an implementation detail.")
I perhaps have not had a long professional life working with compilers (5+ years), but to me the definition of "compiles to binary" is too restrictive. The main things I care for in my work are:
1. To be able to perform some sort of static analysis on the program 2. To be able to transform the program representation
To other commenters: in Python, we have two program representations. The human readable string representation and the bytecode representation. The syntactical errors are a kind of static analysis. To me, the maps between the Python string representation and the bytecode representation and the classes of errors we can catch without running the program is far more interesting than pigeon-holing Python in the "compiled" or "interpreted" hole.
I perhaps have not had a long professional life working with compilers (5+ years), but to me the definition of "compiles to binary" is too restrictive. The main things I care for in my work are:
1. To be able to perform some sort of static analysis on the program 2. To be able to transform the program representation
To other commenters: in Python, we have two program representations. The human readable string representation and the bytecode representation. The syntactical errors are a kind of static analysis. To me, the maps between the Python string representation and the bytecode representation and the classes of errors we can catch without running the program is far more interesting than pigeon-holing Python in the "compiled" or "interpreted" hole.
Not for any useful everyday definition of the term.
Yes I read the article.
When we talk about compiled languages, we're almost always talking about the transformation of source code into executable machine code, and the performance increases that this brings.
CPython having a preprocessing and compilation stage doesn't make it a compiled language any more than GCC/clang having constant folding optimizations make them interpreters.
Yes I read the article.
When we talk about compiled languages, we're almost always talking about the transformation of source code into executable machine code, and the performance increases that this brings.
CPython having a preprocessing and compilation stage doesn't make it a compiled language any more than GCC/clang having constant folding optimizations make them interpreters.
Java has a compilation stage, as does Python, but it requires an interpreter to use. The compilation target is a virtual machine.
Python having a parsing and lexing stage does not make it a compiled language, not in the way that “compiled language” is commonly used.
When people say “compiled languages”, it’s as a synonym for “the compilation target is not a virtual machine”.
Python having a parsing and lexing stage does not make it a compiled language, not in the way that “compiled language” is commonly used.
When people say “compiled languages”, it’s as a synonym for “the compilation target is not a virtual machine”.
Nope. Please go and learn about the basics of interpreted and compiled languages.
You can blog once you’ve learnt the basics. It can wait.
You can blog once you’ve learnt the basics. It can wait.
Java compiles to binary in parallel with interpretation during its first runs, aka jitting. Does python do this?
I've built a scripting language with a full lexer and parser. It is capable of giving errors in both stages. It does not make it compiled or even interpreted. It is first when you execute the instructions of the language it becomes an interpreted language.
It is a good point that "compiled" is not a boolean property. A language like C# can be interpreted, JIT compiled and AOT compiled - it all depends on the toolchain used.
However, usually developers refer to compiled languages as those that gets translated down to machine instructions, and to my knowledge, CPython does not do that.