- Learn Programming in Python with Cody Jackson
- Cody Jackson
- 493字
- 2021-06-10 19:06:05
Interpreted versus compiled
Python is classified as a scripting language, because it doesn't require a compiler to generate machine code. It actually uses an interpreter to create byte-code, which is cross-platform, and, therefore, any system that has Python installed should be able to run the code. (There are caveats to this, which will be addressed later in the book.)
Byte-code is common among higher-level languages, such as Java, because it makes it easy to write software that runs in many different environments. Languages that use byte-code have a language-specific virtual machine; that is, the virtual machine's sole purpose is to translate the byte-code into something the host computer's operating system can understand. Any OS that has a language-specific virtual machine can process and use the byte-code, thus making an interpreted programming language system agnostic. The programmer doesn't have to do anything special prior to releasing the software.
Machine code is basically the opposite. It is compiled from the raw source code for a particular computer system; this is more common for low-level languages like C++ and Go. The code is portable between systems, but has to be recompiled for each system; it cannot be run immediately like it can with byte-code. Thus, a programmer must either generate the compiled code for each target OS, or has to provide the source code so an end user can perform that compilation step.
Compiled languages tend to operate faster than interpreted languages because the code has already been optimized for the environment. The compiler also finds many errors before the code is actually executed (the "runtime"). However, compilers can take minutes or even hours to compile the source code, depending on various factors. When errors occur, the programmer has to fix them and rerun the compiler; this compile-fix-compile process continues until the compiler returns no errors.
Compilers can't identify all errors, so the final product must be tested. If problems are found, the code must be fixed, leading to another round of compile-fix-compile, as the fixes to the runtime errors may introduce new errors during compilation.
Working with interpreted languages can be quicker, as there is no compilation step. The code can be run as often as necessary while fixing errors, so the development process is much faster. For many products, developer time is more important than computer time, so having a programmer who can quickly write a program is more desirable than a program that is quicker to run.
In addition, utilizing interpreted languages also allows software developers to provide a scripting interface to the end user; the user can manipulate the program without having to dive into the source code itself. Referring to the previous Jython example, a program written in Java could allow the user to manipulate the data or the actions performed by writing a simple Jython script, essentially adjusting on the fly how the results are generated. This type of customization is commonly found in video games, such as modding communities.
- 流量的秘密:Google Analytics網站分析與優化技巧(第2版)
- 編程的修煉
- Mastering Python Scripting for System Administrators
- 64位匯編語言的編程藝術
- Oracle Database 12c Security Cookbook
- Learning Concurrent Programming in Scala
- HTML5與CSS3基礎教程(第8版)
- PHP 8從入門到精通(視頻教學版)
- AI自動化測試:技術原理、平臺搭建與工程實踐
- Build Your Own PaaS with Docker
- 陪孩子像搭積木一樣學編程:Python真好玩+Scratch趣味編程(全2冊)
- Building an E-Commerce Application with MEAN
- Python3從入門到實戰
- 軟件定義存儲:原理、實踐與生態
- Ajax與jQuery程序設計