第7章高水準プログラミング言語
7.1 Programming Language Foundations7.1 プログラミング言語の基礎
Learning Objectives学習目標
By the end of this section, you will be able to:
この節を終えると、次のことができるようになる。
• Describe what HLLs are
• HLLとは何かを説明する。
• Summarize choosing appropriate HLLs
• 適切なHLLの選び方をまとめる。
• Outline the history of HLLs
• HLLの歴史を概説する。
• Describe the implementation of HLLs
• HLLの実装を説明する。
A high-level programming language is designed to be easy for humans to read, write, and understand. It abstracts away most of the complexities of the underlying hardware and machine code, allowing programmers to focus on solving problems and designing software without needing to manage the low-level details of the computer’s architecture.
英語のヒント
高水準プログラミング言語は、人間が読み、書き、理解しやすいように設計されている。基盤となるハードウェアや機械語の複雑さの大部分を抽象化して隠し、コンピューターのアーキテクチャーの低い水準の細部を管理しなくても、プログラマーが問題解決やソフトウェア設計に集中できるようにする。
What Are HLLs?HLLとは何か
High-level programming languages give humans the ability to direct computers to perform tasks and applications. There are many HLLs to choose from. Java is a popular choice for its ability to run on various operating systems (i.e., Windows, macOS, Linux) and mobile platforms (Android). This is called cross-platform compatibility. For development specifically targeting Windows systems, C# is another strong option. Additionally, to create the visual elements of a website, programmers can utilize HTML and CSS. HTML provides the structure and content of the web page, while CSS controls how web pages are styled and presented. Over time, many HLLs have evolved into a mature set of tools that are used to create modern applications (Figure 7.2).
英語のヒント
高水準プログラミング言語は、人間がコンピューターに指示を出し、タスクやアプリケーションを実行させられるようにする。選べるHLLは数多くある。Javaは、さまざまなOS、つまりWindows、macOS、Linuxや、モバイルプラットフォームのAndroidで動くことから、よく選ばれる。これをクロスプラットフォーム互換性という。特にWindowsシステムを対象にした開発では、C#も有力な選択肢である。さらに、ウェブサイトの視覚的な要素を作るには、HTMLとCSSを使える。HTMLはウェブページの構造と内容を提供し、CSSはその装飾や表示方法を制御する。多くのHLLは、時間とともに、現代のアプリケーションを作るための成熟した道具群へと発展してきた(図7.2)。

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 7.2 High-level programming languages have advanced from the foundational languages in the middle of the 20th century to more than 2500 HLLs that exist today. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図7.2 高水準プログラミング言語は、20世紀半ばの基礎となった言語から発展し、今日では2500を超えるHLLが存在する。(出典:著作権 Rice University、OpenStax。CC BY 4.0ライセンス)
LINK TO LEARNING学習リンク
There is a possibility that the widespread use of a variety of HLLs to develop networked and mobile applications at a global scale creates potential cybersecurity issues. Some HLLs are considered more secure than others. Read this article on the most secure programming languages (https://openstax.org/r/ 76ProgLanguages) for further information about the security—or lack thereof—of these languages.
英語のヒント
ネットワークにつながるアプリケーションやモバイルアプリケーションを、さまざまなHLLを広く使って世界規模で開発することで、潜在的なサイバーセキュリティー問題が生じる可能性がある。ほかより安全性が高いとみなされるHLLもある。これらの言語の安全性、またはその不足について詳しく知るには、最も安全なプログラミング言語についての記事(https://openstax.org/r/76ProgLanguages)を読もう。
Learning Motivations学ぶ動機
Studying the fundamental concepts provided by various HLLs is necessary to choose them correctly, employ them effectively, and program efficiently. From a user point of view, examining HLL concepts helps the user get better at thinking and expressing algorithms. From an implementor’s point of view, understanding HLL concepts helps programmers abstract away from (virtual) machines and become better at specifying what they want the hardware to do without getting down into the bits. In the end, studying HLL concepts helps programmers make better use of whatever HLL they use.
英語のヒント
さまざまなHLLの基本概念を学ぶことは、言語を正しく選び、有効に使い、効率よくプログラムを書くために必要である。利用者の視点では、HLLの概念を調べることで、アルゴリズムを考え、表現する力が高まる。実装者の視点では、HLLの概念を理解すると、仮想マシンを含むマシンから抽象化し、ビットの細部へ立ち入らずに、ハードウェアへ何をさせたいかを、より上手に指定できるようになる。結局、HLLの概念を学ぶことは、どのHLLを使う場合でも、その使い方を改善するのに役立つ。
Implementing Abstraction抽象化の実装
One way to relate to abstraction is as a way of thinking and expressing algorithms to indicate what the programmer wants the hardware to do. For example, the following statement represents one form of abstraction in the Java programming language:
英語のヒント
抽象化を捉える方法の一つは、プログラマーがハードウェアに何をさせたいかを示すために、アルゴリズムを考え、表現する方法として見ることである。たとえば、次の文は、Javaプログラミング言語における抽象化の一つの形を表す。
System.out.println("Hello world!");It tells the computer’s operating system at a high-level of abstraction to output a string of characters, which practically consists of moving the pixels that form characters one by one to a hardware device.
英語のヒント
この文は、高い抽象化水準でコンピューターのOSに文字列の出力を指示する。実際には、文字を構成するピクセルを一つずつ、ハードウェア装置へ移すことである。
Implementing a high level of tasks would be impossible without abstraction. For example, you would not want to program an invoicing application in 1s and 0s (machine language); abstraction allows a programmer to build it in an English-like syntax.
英語のヒント
抽象化なしに高い水準のタスクを実装することは不可能である。たとえば、請求書作成アプリケーションを、1と0、つまり機械語で書きたいとは思わないだろう。抽象化によって、英語に似た構文で作れるようになる。
Abstraction may be taken to much higher levels. It is one of three central principles (along with encapsulation and inheritance) in such object-oriented HLLs as C++, Java, C#, and Python. Various programming paradigms were introduced in Chapter 4 Linguistic Realization of Algorithms: Low-Level Programming Languages, particularly the mechanisms of object-oriented programming (OOP) and its standards, perspectives, or sets of ideas that may be used to describe the structure and methodologies of an HLL. Object-oriented HLLs help organize software design around data, or objects, rather than functions and logic, as we will discuss in Alternative Programming Models.
英語のヒント
抽象化は、さらに高い水準へ引き上げられる。C++、Java、C#、Pythonなどのオブジェクト指向HLLでは、カプセル化、継承と並ぶ三つの中心原則の一つである。第4章「アルゴリズムの言語による実現:低水準プログラミング言語」では、さまざまなプログラミングパラダイムを紹介した。特に、HLLの構造や方法論を説明するために使える、オブジェクト指向プログラミング(OOP)の仕組みと、その標準、見方、考え方の集合を取り上げた。「別のプログラミングモデル」で説明するように、オブジェクト指向HLLは、関数や論理ではなく、データ、つまりオブジェクトを中心にソフトウェア設計を構成するのに役立つ。
Choosing Appropriate HLLs適切なHLLを選ぶ
Studying and understanding HLL concepts allows us to make most efficient use of them by becoming familiar with various criteria that may be used to evaluate them, which helps us choose the most appropriate language for a project. Some of these criteria are listed in Table 7.1, which also shows how they are related to the characteristics of an HLL. These criteria are as follows:
英語のヒント
HLLの概念を学び、理解すると、評価に使えるさまざまな基準に詳しくなり、言語を最も効率よく使えるようになる。これは、プロジェクトに最適な言語を選ぶ助けとなる。基準の一部を表7.1に挙げ、HLLの特性との関係も示す。これらの基準は次のとおりである。
• readability: measures how easily an HLL can be read and understood
• 読みやすさ:HLLをどれだけ容易に読んで理解できるかを測る。
• writability: measures how easily an HLL can be used to create and modify programs
• 書きやすさ:HLLを使って、どれだけ容易にプログラムを作成・変更できるかを測る。
• reliability: measures conformance to specifications
英語のヒント
• 信頼性:仕様にどれだけ適合しているかを測る。
There are many other criteria including scalability, cost, flexibility, efficiency, portability, and maintainability. These can be used to identify which HLL is best suited for a given task.
英語のヒント
ほかにも、拡張性、費用、柔軟性、効率、移植性、保守性など、多くの基準がある。これらを使い、特定の仕事に最も適したHLLを見極められる。
Characteristic 特性 | Readability 読みやすさ | Writability 書きやすさ | Reliability 信頼性 |
|---|---|---|---|
Simplicity: a manageable set of features and constructs 単純さ:扱いやすい規模の機能と構文の集合。 | • | • | • |
Orthogonality: a relatively small set of primitive constructs can be combined in a relatively small number of ways 直交性:比較的少数の基本構文を、比較的少数の方法で組み合わせられること。 | • | • | • |
Data types: adequate predefined constructs to hold data データ型:データを保持するための、十分な定義済みの構造。 | • | • | • |
Syntax design: form and meaning via self-descriptive constructs and meaningful keywords 構文設計:意味が自明な構文や、意味のあるキーワードによって、形式と意味を表すこと。 | • | • | • |
Supports abstraction: hides all but the relevant data about an object in order to reduce complexity and increase efficiency 抽象化への対応:複雑さを減らし、効率を高めるために、対象について関連するデータ以外を隠すこと。 | • | • | |
Expressivity: relatively convenient ways of specifying operations 表現力:操作を比較的容易に指定できる方法。 | • | • | |
Type checking: built-in testing for type mismatches 型検査:型の不一致を調べる組み込みの検査。 | • |
Table 7.1 Criteria for Measuring Characteristics of HLLs
表7.1 HLLの特性を測る基準
Characteristic 特性 | Readability 読みやすさ | Writability 書きやすさ | Reliability 信頼性 |
|---|---|---|---|
Exception handling: support for catching run-time errors and specifying corrective measures 例外処理:実行時エラーを捕捉し、修正措置を指定するための機能。 | • | ||
Restricted aliasing: presence of two or more distinct referencing methods for the same memory location 制限されたエイリアシング:同じメモリ位置に対して、二つ以上の異なる参照方法が存在すること。 | • |
Table 7.1 Criteria for Measuring Characteristics of HLLs
表7.1 HLLの特性を測る基準