プリンキピア

第7章高水準プログラミング言語

Middle-End Compiler Structureコンパイラーのミドルエンドの構造
The main job of the middle-end stage of compilation is optimization, producing what will be needed to generate the fastest and most efficiently running code as possible. The attributes which are usually optimized are execution time and space (memory usage). Figure 7.24 outlines this process.
英語のヒント
コンパイルのミドルエンド段階の主な仕事は最適化であり、できるだけ速く効率的に動くコードを生成するために必要なものを作り出す。通常、最適化する特性は、実行時間と領域(メモリ使用量)である。図7.24に、この処理の概要を示す。
Figure 7.24

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 7.24 Code optimization is the phase between the front end and back end of the compilation process. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図7.24 コード最適化は、コンパイル処理のフロントエンドとバックエンドの間にある段階である。(出典:著作権 Rice University、OpenStax、CC BY 4.0ライセンス)
Intermediate Form中間形式
The result created after semantic analysis when the program passes all checks is called intermediate form (IF). The nature of the IF is often chosen for machine independence and ease of optimization. IFs usually resemble the machine code for some imaginary idealized machine. An example is managed code which is targeted to run under a particular runtime environment. This is true of C# and other Microsoft.net languages. They are designed to run under its CLR, which manages the execution of Microsoft’s .NET languages. In this case, the purpose is to allow code from the different languages to work well together at execution time.
英語のヒント
プログラムがすべての検査に合格し、意味解析を終えた後に作られるものを、中間形式(IF)という。中間形式の性質は、機械に依存しないことと、最適化しやすいことを重視して選ぶ場合が多い。中間形式は、一般に、仮想的な理想化された機械の機械語コードに似ている。例として、特定の実行環境で動くように作られた、マネージコードがある。C#や、ほかのMicrosoft .NET言語がこれに当てはまる。これらは、Microsoftの.NET言語の実行を管理するCLRのもとで動くように設計されている。この場合の目的は、異なる言語のコードが、実行時にうまく連携できるようにすることである。
TECHNOLOGY IN EVERYDAY LIFE日常生活の中の技術
HLLs and Big Data高水準言語とビッグデータ
There is a growing need to process massive amounts of “big” data to gather insights in real time about the best way a business can serve their customers. This is called data analytics, the systematic computational analysis of data or statistics. Netflix uses this technique as a means with which to plan its targeted advertising. Basically, Netflix monitors which types of movies its customers typically watch and collects related data that it uses to bring in new movies and advertise them to its customers. This has led to an increased use of concurrent/parallel processing frameworks that allow concurrent programming. The popularity has caused languages like Python to get a lot of attention for big data analysis. Do some research on Python and provide a well-documented opinion on the features of Python that support this.
英語のヒント
企業が顧客に最適な形でサービスを提供する方法を、リアルタイムで見いだすために、大量の「ビッグ」データを処理する必要性が高まっている。これは、データや統計を体系的に計算によって分析する、データアナリティクスと呼ばれる。Netflixは、対象を絞った広告を計画する手段として、この手法を使っている。基本的には、顧客が普段どの種類の映画を見るかを監視し、関連するデータを集め、それを新しい映画の導入や顧客への宣伝に利用している。これによって、並行プログラミングを可能にする、並行・並列処理フレームワークの利用が増えている。その普及により、ビッグデータ解析のためのPythonなどの言語が、多くの注目を集めるようになった。Pythonについて調べ、これを支えるPythonの特徴について、十分な資料に裏付けられた意見を述べなさい。
Back-End Compiler Structureコンパイラーのバックエンドの構造
The back-end process is known as code generation, the transformation of the code to the target or object language. It uses the intermediate form of the code in combination with the symbol table to carry this out. As previously stated, the final produced code is not necessarily machine language. In hybrid implementations, such as in Java and others, the code will still be a type of intermediate form and it is left for another process to turn it into machine code, usually at runtime.
英語のヒント
バックエンドの処理は、コードを目的言語、またはオブジェクト言語へ変換する、コード生成として知られる。そのために、中間形式のコードと記号表を組み合わせて使う。前に述べたように、最後に生成されるコードは、必ずしも機械語ではない。Javaなどの混成実装では、コードはまだ中間形式の一種であり、通常は実行時に、別の処理で機械語へ変換される。
Pure compilation code generation generally produces this phase (and all compile phases) while also relying on the symbol table, which is the structure responsible for following identifiers within a program and tracking the work of the compiler. Once compilation is complete, the debugger may retain the symbol table.
英語のヒント
純粋なコンパイルによるコード生成では、一般に、この段階、そしてコンパイルのすべての段階で、記号表も頼りにする。記号表は、プログラム内の識別子を追跡し、コンパイラーの仕事を記録する構造である。コンパイルが完了すると、デバッガーが記号表を保持する場合がある。
The back-end phase of the compiler may also perform machine-independent code generation. The purpose of this is to allow a piece of source code to generate instructions that will run on different platforms without change such as Windows and Android. Java is a great example of this, as referenced in Figure 7.25.
英語のヒント
コンパイラーのバックエンド段階では、機械に依存しないコード生成を行うこともある。その目的は、一つのソースコードから、WindowsやAndroidなど、異なるプラットフォームで変更せずに動く命令を生成できるようにすることである。図7.25に示すJavaは、そのよい例である。
Figure 7.25

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典

Figure 7.25 The Java compiler generates byte code from source code. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図7.25 Javaコンパイラーは、ソースコードからバイトコードを生成する。(出典:著作権 Rice University、OpenStax、CC BY 4.0ライセンス)
This can then be run in any environment for which a JVM has been built.
こうして生成されたものは、JVMが用意されたどの環境でも実行できる。
Compilation of Interpreted Languagesインタープリター言語のコンパイル
In some languages, compilers are present, but they aren’t pure and only perform a selective compilation of pieces, or pre-processing, of the remaining source. Occasionally the compiler generates code that builds expectations around decisions that won’t be completed until runtime. If these assumptions are sound, the code runs very fast. If not, a dynamic check reverts to the interpreter.
英語のヒント
言語によってはコンパイラーが存在するが、純粋なコンパイラーではなく、一部だけを選択的にコンパイルしたり、残りのソースを前処理したりする。実行時まで確定しない判断について、予測を組み込んだコードを生成する場合もある。この仮定が妥当なら、コードは非常に速く動く。妥当でなければ、動的な検査によってインタープリターへ戻る。
Dynamic and Just-in-Time Compilation動的コンパイルと実行時コンパイル
Sometimes a program delays compilation until the last minute. In Java, a bytecode is a set of instructions for a virtual machine. The process of just-in-time (JIT) compilation is when intermediate code, which is the language translation phase that produces a code level between the source code and the object code, gets its final compilation (or usually interpretation) phase right at the start of runtime. Bytecode is the standard format for distribution of Java programs to any runtime platform such as Windows, macOS, and Linux. The bytecode is interpreted by a Java virtual machine (JVM) that has been implemented by the producer specifically for their platform. Since there is a JVM for macOS but not for Mac IOS, Java is incompatible with iPhones.
英語のヒント
プログラムがコンパイルを最後の瞬間まで遅らせる場合もある。Javaのバイトコードは、仮想マシン向けの命令の集合である。ジャストインタイム(JIT)コンパイルとは、中間コードが、実行開始の直前に、最後のコンパイル段階(通常は解釈実行)を受ける処理である。中間コードは、ソースコードとオブジェクトコードの間の水準のコードを作り出す、言語の翻訳段階である。バイトコードは、Windows、macOS、Linuxなど、任意の実行プラットフォームへJavaプログラムを配布する標準形式である。バイトコードは、製造元がそのプラットフォーム向けに実装したJava仮想マシン(JVM)によって解釈される。macOSにはJVMがあるがMac IOSにはないため、JavaはiPhoneと互換性がない。