第7章高水準プログラミング言語
Review Questions確認問題
Exercises 1–5練習問題 1–5
1. Which HLL was developed first? a. COBOL b. C c. Java d. Fortran
1. 最初に開発された高水準言語はどれか。a. COBOL b. C c. Java d. Fortran
2. What is the term used to describe the most accepted style and structure of code that can be used to ensure proper software development? a. paradigm b. best practice c. model d. abstraction
2. 適切なソフトウェア開発を確保するために使える、最も広く受け入れられたコードの書き方と構造を表す用語はどれか。a. パラダイム b. ベストプラクティス c. モデル d. 抽象化
3. Which abbreviation refers to a library shipped with the language which contains objects and useful functions for the tasks for which the language is purposed? a. UX b. GUI c. API d. UI
3. 言語に同梱され、その言語が対象とする作業に役立つオブジェクトや関数を含むライブラリーを指す略語はどれか。a. UX b. GUI c. API d. UI
4. Why are various HLLs related to each other and/or part of the same history?
4. さまざまな高水準言語が互いに関係したり、同じ歴史の一部となったりするのは、なぜか。
5. What is event-driven programming?
5. イベント駆動型プログラミングとは何か。
Exercises 6–10練習問題 6–10
6. What are the names of some different programming paradigms?
6. 異なるプログラミングパラダイムの名前を、いくつか挙げなさい。
7. What is the difference between a compiled and an interpreted HLL?
7. コンパイル型とインタープリター型の高水準言語には、どのような違いがあるか。
8. What are the typical constituent parts of an HLL development environment or IDE?
英語のヒント
8. 高水準言語の開発環境またはIDEの、典型的な構成要素は何か。
9. What is weak typing? What is strong typing? What is the difference between them?
9. 弱い型付けとは何か。強い型付けとは何か。両者の違いは何か。
10. What are the equivalents of dynamic and static typing?
10. 動的型付けと静的型付けに、それぞれ相当するものは何か。
Exercises 11–15練習問題 11–15
11. What is an example of a data type that is always primitive? a. string b. array c. number d. object
11. 必ず基本型となるデータ型の例はどれか。a. 文字列 b. 配列 c. 数値 d. オブジェクト
12. What best defines a function interface? a. parameter b. return c. code block d. signature
12. 関数のインターフェースを最もよく定義するものはどれか。a. 引数 b. return c. コードブロック d. シグネチャー
13. What type of operator has only a single operand? a. logical b. relational c. unary d. Boolean
13. オペランドが一つだけの演算子は、どの種類か。a. 論理 b. 関係 c. 単項 d. ブール
14. What is “short circuiting” in the context of HLL expressions evaluation?
14. 高水準言語の式の評価における「短絡評価」とは何か。
15. What is the difference between variable passing by value versus passing by references?
15. 変数の値渡しと参照渡しには、どのような違いがあるか。
Exercises 16–20練習問題 16–20
16. What is the difference between integer data types and floating-point data types?
16. 整数型と浮動小数点型には、どのような違いがあるか。
17. What are composite types?
17. 合成型とは何か。
18. What is the difference between subroutines and modules?
18. サブルーチンとモジュールには、どのような違いがあるか。
19. What term represents a feature in OOP? a. synchronization b. polymorphism c. mutual exclusion d. Parallelism
19. OOPの特徴を表す用語はどれか。a. 同期 b. ポリモーフィズム c. 相互排他 d. 並列性
20. What is the term for a process used to return memory that is no longer needed? a. instantiation b. polymorphism c. starvation d. garbage collection
20. 不要になったメモリを返すための処理を指す用語はどれか。a. インスタンス化 b. ポリモーフィズム c. 飢餓状態 d. ガベージコレクション
Exercises 21–25練習問題 21–25
21. What is a high-order function in a functional HLL?
21. 関数型の高水準言語における、高階関数とは何か。
22. What is typically the last statement of a recursive function?
22. 再帰関数の最後の文は、通常、何か。
23. Give the definition of a thread.
23. スレッドの定義を述べなさい。
24. Explain encapsulation, inheritance, and polymorphism in object-oriented HLLs.
24. オブジェクト指向の高水準言語における、カプセル化、継承、ポリモーフィズムを説明しなさい。
25. What is the difference between concurrency and parallelism?
25. 並行性と並列性には、どのような違いがあるか。
Exercises 26–30練習問題 26–30
26. Explain mechanisms that may be used to enable synchronization in concurrent programming.
26. 並行プログラミングで同期を可能にするために使える仕組みを、説明しなさい。
27. What types of problems are best solved by scripting HLLs?
27. スクリプト型の高水準言語が、解決に最も適するのは、どのような種類の問題か。
28. What is the name for software that scans and translates the source code one line at a time? a. interpreter b. compiler c. assembler d. linker
28. ソースコードを一行ずつ調べ、翻訳するソフトウェアの名前はどれか。a. インタープリター b. コンパイラー c. アセンブラー d. リンカー
29. The middle end stage of compilation is responsible for what task? a. lexical analysis b. optimization c. code generation d. assembly
29. コンパイルのミドルエンド段階は、どの作業を担当するか。a. 字句解析 b. 最適化 c. コード生成 d. アセンブル
30. Software that provides a complete program execution environment is the reproduction of which computer architecture? a. dynamic linker b. parser c. virtual machine d. static linker
30. 完全なプログラム実行環境を提供するソフトウェアは、どのコンピューターアーキテクチャーを再現したものか。a. 動的リンカー b. パーサー c. 仮想マシン d. 静的リンカー
Exercises 31–35練習問題 31–35
31. What is the difference between the front end, middle end, and back end compiler phases?
31. コンパイラーのフロントエンド、ミドルエンド、バックエンドの各段階は、どう違うか。
32. Explain the different phases of compilation.
32. コンパイルの各段階を説明しなさい。
33. What is the difference between static and dynamic linking?
33. 静的リンクと動的リンクには、どのような違いがあるか。
34. Explain late binding.
34. 遅延束縛を説明しなさい。
35. Explain the different phases of code improvement.
35. コード改善の各段階を説明しなさい。
Exercises 36練習問題 36
36. Why is there such a focus on loops improvement as part of code optimization?
36. コード最適化の一部として、ループの改善が特に重視されるのは、なぜか。
Conceptual Questions概念を考える問題
1. Should all languages be kept simple, small, and straightforward to avoid dangerous complexity? Support your opinion.
英語のヒント
1. 危険な複雑さを避けるため、すべての言語を、単純で小さく、分かりやすいものに保つべきだろうか。自分の意見を根拠とともに述べなさい。
2. Are HLLs purpose-driven? Give some examples of purpose-driven HLLs, expanding on the purpose of each.
英語のヒント
2. 高水準言語は、目的に基づいて作られるものか。目的を持って作られた高水準言語をいくつか挙げ、それぞれの目的を詳しく述べなさい。
3. Do you think that all high-level programming languages support abstraction? Give a few examples of languages that do, and list abstraction mechanisms that are used in each.
3. すべての高水準プログラミング言語が、抽象化を支えていると思うか。支えている言語をいくつか挙げ、それぞれで使われる抽象化の仕組みを列挙しなさい。
4. While a similar set of programming language constructs are applicable to all modern HLLs, can you explain why modern HLLs such as C, Java, Python, C++, C#, JavaScript, and PHP are so different?
英語のヒント
4. 現代のすべての高水準言語には、似通ったプログラミング言語の構成要素が当てはまる。それにもかかわらず、C、Java、Python、C++、C#、JavaScript、PHPといった現代の高水準言語が、これほど異なる理由を説明できるか。
5. Explain how HLLs that support specific programming models can be classified as imperative or declarative.
5. 特定のプログラミングモデルを支える高水準言語を、どのように命令型または宣言型へ分類できるか、説明しなさい。
6. Why is code optimization sometimes specific to a given HLL?
6. コード最適化が、特定の高水準言語に固有のものになる場合があるのは、なぜか。
Practice Exercises練習問題
Exercises 1–5練習問題 1–5
1. Research the data types of Java and C++. Write a summary outlining the differences and similarities between the two.
1. JavaとC++のデータ型を調べなさい。両者の違いと共通点の概要をまとめなさい。
2. Explain the differences between pure compilation, pure interpretation, and hybrids of the two. Give the advantages and disadvantages of each methodology.
2. 純粋なコンパイル、純粋な解釈実行、両者の混成方式の違いを説明しなさい。それぞれの方式の利点と欠点を挙げなさい。
3. Programming for iPhone and programming for Android require different purpose-driven HLLs. List the HLLs used for each and summarize some of the differences between them.
3. iPhone向けとAndroid向けのプログラミングには、それぞれの目的に合った異なる高水準言語が必要である。それぞれで使われる高水準言語を挙げ、その違いをいくつかまとめなさい。
4. What are some of the criteria for selecting among various HLLs? Describe these criteria.
4. さまざまな高水準言語の中から選ぶための基準には、どのようなものがあるか。それらを説明しなさい。
5. Describe the purpose of an API and explain how the use of APIs can lead to faster development, increased readability, and less complexity.
5. APIの目的を述べ、APIの利用が、どうして開発の高速化、読みやすさの向上、複雑さの軽減につながるのか、説明しなさい。
Exercises 6–10練習問題 6–10
6. The Python language controversially uses an indentation of a uniform number of spaces to construct code blocks in control statements and other structures. What are the arguments and pros and cons for using this technique instead of the usual curly braces? To illustrate your answer, please write a short program snippet that demonstrates the pros and cons of indentation (in Java) as compared to curly braces (in Python).
英語のヒント
6. Pythonは、制御文やほかの構造でコードブロックを作るために、一定数の空白による字下げを使っており、これについては議論がある。通常の波括弧ではなく、この方法を使うことについて、どのような主張や利点・欠点があるか。答えを具体的に示すために、字下げ(Javaでの)と波括弧(Pythonでの)を比べ、その利点と欠点を示す短いプログラムを書きなさい。
7. Write a conditional statement to determine if a variable is within a specific numerical boundary, and if so, multiply the number by 2, and if not, multiply the number by itself.
7. 変数が指定した数値の範囲内にあるかを判断する条件文を書きなさい。範囲内ならその数を2倍し、範囲外ならその数自身を掛けなさい。
8. Research what Fibonacci numbers are. Write a recursive program that finds the Nth number of the Fibonacci sequence.
8. フィボナッチ数とは何かを調べなさい。フィボナッチ数列のN番目の数を求める、再帰プログラムを書きなさい。
9. Interpret the following program snippet. What will the function return?
9. 次の短いプログラムを読み解きなさい。この関数は何を返すか。
int main() {
int x = 1;
int y = 7;
if (x == 1 && y > 10)
{
return 0;
}
else if (x < 0 || y == x)
{
return 1;
}
else if (x != 0 && y == x)
{
return 2;
}
else if (x > 0 && (x != y || y > x))
{
return 3;
}
else
{
return 4;
}
}10. Write a do while loop that will execute five times.
10. 5回実行するdo whileループを書きなさい。
Exercises 11–15練習問題 11–15
11. Encapsulation is one of the three fundamental components of object-oriented programming. Write a summary which defines the term and explains the advantages of it. Please provide a code snippet that demonstrates poor usage of encapsulation and improve it to highlight the advantages of proper encapsulation.
11. カプセル化は、オブジェクト指向プログラミングの三つの基本的な構成要素の一つである。用語の定義と利点をまとめなさい。カプセル化のよくない使い方を示す短いコードを書き、適切なカプセル化の利点が分かるように、そのコードを改善しなさい。
12. Write a short program in JavaScript that asks the user to input the base and height of a triangle. Calculate the area of the triangle and print it back out.
12. 利用者に三角形の底辺と高さの入力を求める、短いJavaScriptプログラムを書きなさい。三角形の面積を計算し、表示しなさい。
13. One of the key features of OOP is inheritance. Research multiple inheritance and how Java and C++ differ when it comes to multiple inheritance. Why would restricting multiple inheritance be a good idea?
英語のヒント
13. 継承は、OOPの主要な特徴の一つである。多重継承とは何かを調べ、多重継承に関してJavaとC++がどう違うかを調べなさい。多重継承を制限することが、よい考えとなりうるのはなぜか。
14. Research the synchronized keyword in Java. Implement a critical section of code in Java by using the synchronized keyword.
14. Javaのsynchronizedキーワードを調べなさい。これを使って、Javaでコードのクリティカルセクションを実装しなさい。
15. The back end of a conventional compiler differs from that of a JIT compiler. List the ways that they are different. Does their design add to their differences?
英語のヒント
15. 従来のコンパイラーのバックエンドは、JITコンパイラーのものとは異なる。違いを列挙しなさい。両者の設計も、その違いを生む要因となっているか。