プリンキピア

第4章アルゴリズムの言語による実現:低水準プログラミング言語

LINK TO LEARNING学習リンク
Assembly language has been used in high-profile, high-budget projects, such as Apollo 11, the NASA spaceflight that first landed humans on the moon. You can examine the assembly code for the embedded computers (https://openstax.org/r/76AssemblyCode) in the space vehicles, which has been released publicly. Notice how it is quite low-level, perhaps difficult to follow, and reflects an immense amount of fastidious work.
英語のヒント
アセンブリ言語は、人類を初めて月面に着陸させたNASAのアポロ11号など、注目度と予算の高い事業に使われてきた。公開されている、宇宙機の組込みコンピューター用アセンブリコード(https://openstax.org/r/76AssemblyCode)を調べてみよう。非常に低水準で、おそらく追いかけにくく、膨大で細心の作業の積み重ねが見て取れることに注意してほしい。

Middle-Level and High-Level Programming中水準・高水準プログラミング

As the name implies, a middle-level programming language is at a level of abstraction in between low-level and high-level language, and allows for direct hardware access. The C programming language is a middle-level language that has been in wide use since the 1970s. The C++ programming language is a middle-level object-oriented language based on C. In general, the trade-off between low-level and high-level languages is that writing low-level code is laborious and error-prone, but the finished code executes very quickly; high-level code is faster, easier, and safer to write but does not run quite as quickly. Middle-level code is a compromise that executes nearly as fast as low-level code yet has some of the productivity benefits of high-level code. Like low-level languages, middle-level languages allow direct access to computer hardware, making it possible to write hardware-specific programs such as operating systems and device drivers. An operating system is the software that provides a platform for applications and manages hardware components. A device driver is a piece of code responsible for connecting to a hardware component, such as a video card or keyboard. Figure 4.8 summarizes the trade-offs between low-level, middle-level, and high-level programming languages.
英語のヒント
名前が示すように、中水準プログラミング言語は、低水準と高水準の中間の抽象化の水準を持ち、ハードウェアへの直接アクセスを可能にする。Cは1970年代から広く使われている中水準言語であり、C++はCに基づく中水準のオブジェクト指向言語である。一般に、低水準と高水準のトレードオフは、低水準コードは書くのに手間がかかり、誤りが生じやすいが、完成すれば非常に速く動くのに対し、高水準コードは速く簡単に、より安全に書けるが、実行はそれほど速くないということである。中水準コードは、その折衷である。低水準とほぼ同じ速度で実行しつつ、高水準の生産性の利点を一部備える。低水準言語と同様に、中水準言語はハードウェアへ直接アクセスできるため、オペレーティングシステムやデバイスドライバーなど、ハードウェア固有のプログラムを書ける。オペレーティングシステムは、アプリケーションの基盤を提供し、ハードウェアの構成要素を管理するソフトウェアである。デバイスドライバーは、ビデオカードやキーボードなどのハードウェア部品との接続を担うコードである。図4.8に、低水準、中水準、高水準言語のトレードオフをまとめる。
Figure 4.8

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

Figure 4.8 As a rule, high-level languages are less laborious to write, and slower to execute, than low-level languages. High-level languages typically do not support direct hardware control. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図4.8 一般に、高水準言語は低水準言語より、書く手間は少ないが、実行は遅い。通常、ハードウェアの直接制御は提供しない。(出典表記:著作権者 Rice University、OpenStax、CC BY 4.0ライセンス)
Middle-level languages are ideally suited to writing systems software, programs that provide infrastructure and platforms that other programs rely upon. The core part of an operating system that is responsible for managing and interfacing with hardware components is called the kernel. Kernels need direct hardware access, so high-level languages are inadequate. Practically all widespread kernels are written in C and/or C++ (such as Windows, MacOS, Linux, iOS, Android, Xbox, and PlayStation). Compilers for high-level languages, such as Python, Java, and C#, are themselves implemented in middle-level languages such as C.
英語のヒント
中水準言語は、ほかのプログラムが頼る基盤やプラットフォームを提供する、システムソフトウェアを書くのに最も適している。オペレーティングシステムの中心部分で、ハードウェアの管理や接続を担うものをカーネルという。カーネルにはハードウェアへの直接アクセスが必要なため、高水準言語では不十分である。広く使われているカーネルは、事実上すべてCやC++で書かれている(Windows、MacOS、Linux、iOS、Android、Xbox、PlayStationなど)。Python、Java、C#など、高水準言語のコンパイラーも、それ自体はCなどの中水準言語で実装されている。
Figure 4.9 summarizes the various types of programming languages and how middle-level languages overlap with low-level and high-level programming languages.
図4.9に、プログラミング言語のさまざまな種類と、中水準言語が低水準・高水準言語とどう重なるかをまとめる。
Figure 4.9

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

Figure 4.9 Computation models fit onto a spectrum from low- to high-level. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図4.9 計算モデルは、低水準から高水準への連続的な範囲に位置付けられる。(出典表記:著作権者 Rice University、OpenStax、CC BY 4.0ライセンス)
A high-level language is farther from a hardware model, and closer to an abstract model. Source code in a high-level language does not address low-level details, and instead focuses on how an algorithm proceeds, such as “visit every item in a list.” A high-level language is like viewing Earth at a high altitude, revealing large features such as the contours of rivers and highways, whereas a low-level language is like viewing Earth at ground level, which allows for focusing on fine details such as the activity of individual people and animals.
英語のヒント
高水準言語は、ハードウェアモデルから遠く、抽象モデルに近い。ソースコードは低水準の細部を扱わず、「リスト内の各項目を訪れる」など、アルゴリズムがどう進むかに注目する。高水準言語は、高い高度から地球を見て、川や道路の輪郭のような大きな特徴を捉えることに似ている。低水準言語は、地上から地球を見て、人や動物それぞれの動きのような細かな点に注目することに似ている。
Web application frameworks (e.g., React, Node) are written in high-level languages, principally JavaScript. A web framework is a special tool for building and managing web applications. Some common ones used in web clients are HTML5, CSS, and JavaScript. Native Android apps are primarily written in the high-level language Java, and iOS apps are primarily written in the high-level language Swift.
英語のヒント
ReactやNodeなどのウェブアプリケーションフレームワークは、高水準言語、主にJavaScriptで書かれている。ウェブフレームワークは、ウェブアプリケーションを作り、管理するための専用ツールである。ウェブのクライアントで使われる代表的なものには、HTML5、CSS、JavaScriptがある。Androidのネイティブアプリは主に高水準言語Javaで、iOSアプリは主に高水準言語Swiftで書かれる。

Programming Language Paradigmsプログラミング言語のパラダイム

So far, we have categorized programming languages according to their level of abstraction into low-level, middle-level, and high-level languages. A different approach is to categorize languages into paradigms. A programming language paradigm is a philosophy and approach for organizing code, the ideas in a program, and the layout of its source code. Real-world programs involve many thousands of lines of source code, which is too much for a human to digest without some kind of organizational structure. Computer scientists have developed several different paradigms for creating this structure.
英語のヒント
ここまでは、抽象化の水準によって、低水準、中水準、高水準に分類してきた。別の方法は、パラダイムによる分類である。プログラミング言語のパラダイムとは、コード、プログラムに含まれる考え、そのソースコードの配置を整理するための思想と方法である。現実のプログラムは何千行ものソースコードを含み、何らかの構成がなければ、人間には理解しきれない。コンピューター科学者は、その構造を作るために、複数の異なるパラダイムを開発してきた。
Unlike level of abstraction, paradigms do not fall on a spectrum. Instead, a particular programming language either adheres to the philosophy of a paradigm, or it does not. For example, C is a structured procedural language and not an object-oriented language. Without getting into too many details, C is procedural because it allows programmers to place code in functions that can be called from various places in a program. However, C is not object-oriented because C does not allow, like Java does, the creation of objects that are instances of classes. We will broadly explore these different types of paradigms later in this section, but the chapter on Chapter 7 High-Level Programming Languages elaborates on these and other paradigms in more detail.
英語のヒント
抽象化の水準とは異なり、パラダイムは連続的な範囲のどこかに位置するものではない。ある言語は、特定のパラダイムの思想に従うか、従わないかのいずれかである。たとえばCは構造化された手続き型言語であり、オブジェクト指向言語ではない。詳しく立ち入らずに述べれば、Cが手続き型なのは、プログラムのさまざまな場所から呼べる関数に、コードをまとめられるためである。しかし、Javaのように、クラスのインスタンスであるオブジェクトを作れないので、オブジェクト指向ではない。この節の後半で各種のパラダイムを広く見るが、第7章「高水準プログラミング言語」では、これらやほかのパラダイムをさらに詳しく説明する。