第7章高水準プログラミング言語
Learning New HLLs新しいHLLを学ぶ
Studying the concepts of HLLs makes it easier to learn new HLLs since most have similarities in syntax, structure, and semantics. There are also several best practices that apply to different HLLs. A best practice is the most accepted style and structure of code that can be used to ensure proper software development, which makes it possible to learn new languages easily once a programmer has mastered a given one. The HLLs that are most used as teaching languages today are Java, C++, and Python. Java and C++ are languages that take a significant amount of study to master, while Python is considered a much simpler language to learn.
英語のヒント
HLLの概念を学ぶと、新しいHLLを学びやすくなる。ほとんどの言語は、構文、構造、意味論に共通点があるからである。異なるHLLに適用できる、いくつかのベストプラクティスもある。ベストプラクティスは、適切なソフトウェア開発を確保するために使える、最も広く受け入れられたコードの書き方や構造である。そのため、一つの言語を習得すると、新しい言語も学びやすくなる。今日、教育用として最もよく使われるHLLは、Java、C++、Pythonである。JavaとC++を習得するには、かなりの学習が必要である。一方、Pythonは、はるかに学びやすい言語だと考えられている。
LINK TO LEARNING学習リンク
HTML and CSS are markup languages and not exactly programming languages like Java or Python. The official HTML and CSS standards (https://openstax.org/r/76HTMLCSSStds) are available at World Wide Web Consortium (W3C).
英語のヒント
HTMLとCSSはマークアップ言語であり、厳密にはJavaやPythonのようなプログラミング言語ではない。HTMLとCSSの公式標準(https://openstax.org/r/76HTMLCSSStds)は、World Wide Web Consortium(W3C)で公開されている。
Best Use of HLLsHLLを最もよく使う
Programmers have to figure out how HLLs support certain features. For example, a variable gives a name to a memory location that is used in any HLL to hold a value. However, different languages use variables differently. Java is a strongly typed language, meaning that a variable may only contain a value of one of the language’s defined data types for its entire existence. Therefore, a variable that is a number cannot become a string of text. JavaScript is weakly typed so a variable may at different times hold values of any of the language data types. It may be storing a number, then later, the same variable may store a string of characters.
英語のヒント
プログラマーは、HLLが特定の機能をどのように支えるかを理解しなければならない。たとえば、変数は、どのHLLでも値を保持するために使うメモリ位置に、名前を与える。しかし、言語によって変数の扱い方は異なる。Javaは強い型付けの言語であり、変数は、存在する間ずっと、その言語が定義する一つのデータ型の値しか持てない。そのため、数値の変数が文字列になることはできない。JavaScriptは弱い型付けなので、変数は、時点によって異なる、言語の任意のデータ型の値を持てる。あるときは数値を保存し、後で同じ変数に文字列を保存することがある。
Another example is the use of pointers in C and C++. As visible in Figure 7.3, the pointer is the variable that holds actual computer memory addresses, but they do not exist in Java. However, understanding how C handles memory makes it easier to understand how data is passed from one place to another in Java or C#.
英語のヒント
別の例は、CとC++のポインターである。図7.3のように、ポインターは、コンピューターの実際のメモリアドレスを保持する変数だが、Javaには存在しない。しかし、Cのメモリの扱い方を理解すると、JavaやC#で、データをある場所から別の場所へどう渡すかを理解しやすくなる。

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 7.3 A C pointer variable “a” holds the memory address of the “b” variable. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図7.3 Cのポインター変数「a」は、変数「b」のメモリアドレスを保持する。(出典:著作権 Rice University、OpenStax。CC BY 4.0ライセンス)
Languages Are Purpose Driven言語は目的に応じて作られる
Let’s again contrast C/C++ and JavaScript. Much of the syntax and grammar are the same, as are the flow of control structures of the language.
英語のヒント
もう一度、C/C++とJavaScriptを比較しよう。構文や文法の多くは同じであり、言語の制御フロー構造も同様である。
LINK TO LEARNING学習リンク
You can review the current C/C++ standard (https://openstax.org/r/76C++Standard) to dig deeper into a syntax comparison.
英語のヒント
構文の比較をさらに掘り下げるには、現行のC/C++標準(https://openstax.org/r/76C++Standard)を確認できる。
So why pick one over the other? The answer is that languages are designed to fulfill certain purposes. C/C++ is a general-purpose programming language. As such, it is powerful for applications that include both systems programming and object-oriented graphical user interface (GUI) programming, JavaScript is intended for web programming.
英語のヒント
では、一方より他方を選ぶのはなぜだろうか。答えは、言語は特定の目的を果たすように設計されているからである。C/C++は汎用のプログラミング言語である。そのため、システムプログラミングと、オブジェクト指向のグラフィカルユーザーインターフェース(GUI)プログラミングの両方を含む用途に強い。JavaScriptは、ウェブのプログラミングを目的としている。
Although programming languages differ in syntax, they all have libraries or packages that are installed as part of the language development environment. These libraries expose various functions via an application programming interface (API). These functions support the tasks for which the language is purposed while not requiring additional coding. The following illustrates the use of a C++ library function that prints a string to the screen:
英語のヒント
プログラミング言語は構文が異なるものの、どれも、言語の開発環境の一部としてインストールされるライブラリーやパッケージを持つ。これらのライブラリーは、アプリケーションプログラミングインターフェース(API)を通じて、さまざまな関数を提供する。その関数は、追加のコードを書かずに、言語が対象とする仕事を行えるようにする。以下は、画面に文字列を表示するC++のライブラリー関数の使用例である。
cout << "Hello world!";JavaScript’s API contains a comprehensive set of features that enable the manipulation and dynamic behavior of web pages. A JavaScript API function that prints to the web page:
英語のヒント
JavaScriptのAPIには、ウェブページの操作や動的な振る舞いを可能にする、包括的な機能群がある。ウェブページへ表示を行うJavaScriptのAPI関数は、次のとおりである。
document.write("Hello world!");TECHNOLOGY IN EVERYDAY LIFE日常生活の中の技術
Using Map APIs to Navigate Your World地図APIで身の回りを案内する
APIs are toolkits for programmers. They provide building blocks that make it easier to create software applications. API functionality can also help people with everyday life situations. For example, Google provides a JavaScript Maps API for customizing map content to display on web pages. Imagine you are planning a road trip. You can then use the Maps API to create a customer map with your planned route, stops, and estimated travel times. Now imagine you own a coffee shop. The Maps API can then help you display your location and operating hours on a map, making it easier for customers to find you. Want to learn more about building apps with APIs? Check out the Maps JavaScript API (https://openstax.org/r/ 76MapJavaAPI) resource.
英語のヒント
APIは、プログラマーのための道具箱であり、ソフトウェアアプリケーションを作りやすくする部品を提供する。APIの機能は、日常生活のさまざまな場面でも役立つ。たとえばGoogleは、ウェブページに表示する地図の内容を自分用に調整する、JavaScriptのMaps APIを提供している。車で旅行する計画を立てているとしよう。Maps APIで、予定する経路、立ち寄る場所、予想所要時間を入れた、利用者向けの地図を作れる。次は、コーヒー店を持っているとしよう。Maps APIで場所と営業時間を地図に表示すれば、お客が店を見つけやすくなる。APIを使ったアプリ開発について、さらに知りたければ、Maps JavaScript APIの資料(https://openstax.org/r/76MapJavaAPI)を見よう。
Google the APIs for an HLL that we have mentioned and find some functionality that applies to everyday life. Think of an app you use every day. How do you think it might use APIs? Provide a couple of scenarios to explain your choice.
英語のヒント
ここまでに挙げたHLLのAPIをGoogleで検索し、日常生活に関わる機能を探そう。毎日使うアプリを一つ考え、そのアプリがAPIをどのように使っていそうか考えよう。二つほどの場面を挙げ、選んだ理由を説明しよう。