第7章高水準プログラミング言語
Programming with Scripting Languagesスクリプト言語によるプログラミング
Scripting languages have their roots in shell scripting, originally referred to as stringing together a group of commands to perform tasks on the user interfaces of various operating systems such as pre-GUI, Unix DOS, and CPM. Modern OSs still provide this facility in such programs as Windows PowerShell. You could string together a group of commands to perform tasks, either directly on the terminal or more effectively in batch files that the shells could execute. Batch files are created in a text editor to contain the script. They usually have a file extension that the shell can recognize, such as backup.bat, which might contain commands to backup an MS-DOS computer. These languages are interpreted at runtime and are not compiled.
英語のヒント
スクリプト言語は、シェルスクリプトを起源とする。もともとは、GUI以前の環境やUnix、DOS、CPMなど、さまざまなオペレーティングシステムのユーザーインターフェースで作業を行うために、一連のコマンドをつなげることを指していた。現代のOSも、Windows PowerShellのようなプログラムで、この機能を提供している。コマンドをつなぎ合わせて作業を行うことは、端末上で直接行うことも、より効果的に、シェルが実行できるバッチファイル内で行うこともできる。バッチファイルは、スクリプトを収めるためにテキストエディターで作成する。通常は、シェルが認識できるファイル拡張子を持つ。たとえばbackup.batには、MS-DOSのコンピューターをバックアップするコマンドを入れられる。これらの言語は実行時に解釈され、コンパイルはされない。
Early scripting languages include the following:
初期のスクリプト言語には、次のものがある。
• MS-DOS command interpreter
• MS-DOSコマンドインタープリター。
• Unix: the standard command line interpreter when running the Unix Bourne shell
• Unix:UnixのBourneシェルを動かす際の、標準的なコマンドラインインタープリター。
• Microsoft PowerShell: used for automation and configuration management on Windows systems
英語のヒント
• Microsoft PowerShell:Windowsシステムの自動化と構成管理に使われる。
Most of our HLL scripting languages used today evolved from these, particularly for programming the Web. Figure 7.23 also illustrates some of these languages.
英語のヒント
現在使われている高水準のスクリプト言語の多くは、特にWebをプログラムするために、これらから発展した。図7.23にも、そのような言語の一部を示す。
• Perl is an older scripting language primarily used for web scripting that uses the Common Gateway Interface (CGI), an industry specification for web server communication with web browsers. The two different entities need rules by which to “talk” to each other, known as protocols such as HTTP. Perl has mostly been replaced by PHP, ASP.NET, and other web server scripting languages.
英語のヒント
• Perlは古くからあるスクリプト言語で、主にCommon Gateway Interface(CGI)を利用したWebスクリプトに使われる。CGIは、WebサーバーとWebブラウザーの通信に関する業界仕様である。異なる二つの主体が互いに「話す」には規則が必要であり、その規則をプロトコルと呼ぶ。HTTPなどがその例である。Perlの大部分は、PHP、ASP.NET、そのほかのWebサーバー用スクリプト言語に置き換えられている。
• Python is a general purpose HLL for both core and web programming.
英語のヒント
• Pythonは、中核部分のプログラミングにもWebプログラミングにも使える、汎用の高水準言語である。
• JavaScript is a general purpose web scripting language that is almost universal. It originally focused on front-end web browsers and now takes a great amount of market share on backend servers with the newer ES6 version.
英語のヒント
• JavaScriptは、ほぼ普遍的に使われる汎用のWebスクリプト言語である。当初はフロントエンドのWebブラウザーを中心としていたが、新しいES6版では、バックエンドのサーバーでも大きな市場シェアを占めるようになっている。
• PHP is a very high-level scripting language for web servers that is platform independent.
英語のヒント
• PHPは、プラットフォームに依存しない、Webサーバー向けの非常に高水準なスクリプト言語である。

attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license · CC BY 4.0 · Source出典
Figure 7.23 Scripting languages can be further categorized by whether they are on the client side or the server side. (attribution: Copyright Rice University, OpenStax, under CC BY 4.0 license)
図7.23 スクリプト言語は、クライアント側にあるかサーバー側にあるかによって、さらに分類できる。(出典:著作権 Rice University、OpenStax、CC BY 4.0ライセンス)
Common Gateway Interface scripts are the original mechanism for server-side web scripting. A Common Gateway Interface (CGI) script is an executable program residing in a special directory known to the web server management program. When a client requests a web address known as a Uniform Resource Indicator (URI), the server executes the program and outputs HTML to a screen that is readable by the browser, which renders it to a user. For example, when you make an online purchase, the web server launches multiple scripts behind the scenes to gather product information, images, and pricing. Most websites use loading screens to allow for one or more scripting languages. Though widely used, CGI scripts have several disadvantages, with the main one being slow loading times by web pages due to having to launch each script as a separate program.
英語のヒント
Common Gateway Interfaceのスクリプトは、サーバー側のWebスクリプトを実行するための、もともとの仕組みである。Common Gateway Interface(CGI)スクリプトは、Webサーバー管理プログラムが把握している特別なディレクトリーに置かれた実行可能プログラムである。クライアントが、Uniform Resource Indicator(URI)と呼ばれるWebアドレスを要求すると、サーバーはプログラムを実行し、ブラウザーが読み取れる画面へHTMLを出力する。ブラウザーは、それを利用者に表示する。たとえばオンラインで買い物をするとき、Webサーバーは舞台裏で複数のスクリプトを起動し、商品情報、画像、価格を集める。ほとんどのWebサイトは、読み込み画面を使って、一つ以上のスクリプト言語に対応している。CGIスクリプトは広く使われているが、欠点がいくつかある。主なものは、スクリプトごとに別のプログラムとして起動する必要があるため、Webページの読み込みが遅くなることである。
A server-side script runs on a server in a web designer’s domain and generally is faster than a CGI script due to its ability to compile in real time; therefore, in PHP, Python, Ruby, and backend JavaScript ES6, the client only sees the standard HTML.
英語のヒント
サーバー側スクリプトは、Web制作者のドメイン内のサーバーで動き、リアルタイムにコンパイルできるため、一般にCGIスクリプトより速い。そのため、PHP、Python、Ruby、バックエンドのJavaScript ES6では、クライアントに見えるのは標準的なHTMLだけである。
A client-side script runs on a client computer, usually under the control of a web browser and needs an interpreter on the client’s machine. Client-side scripts often use an embedded script in which one language is embedded inside another. A frequent example is JavaScript embedded within HTML. JavaScript for interactive features on a web page is almost the universal standard. Microsoft produces a language called TypeScript which is a superset of JavaScript. It is a compiled language which generates JavaScript. It has the advantages of being strongly typed and has stronger OOP features. It can be used on the front end and back end, although it is not as popular as JavaScript ES6 on the server side.
英語のヒント
クライアント側スクリプトは、通常はWebブラウザーの制御下でクライアントのコンピューター上を動き、そのマシンにインタープリターを必要とする。クライアント側のスクリプトでは、一つの言語を別の言語の中へ埋め込む、埋め込みスクリプトを使うことが多い。よくある例が、HTML内に埋め込んだJavaScriptである。Webページの対話的な機能には、JavaScriptがほぼ共通の標準となっている。Microsoftは、JavaScriptの上位集合であるTypeScriptという言語を開発している。これは、JavaScriptを生成するコンパイル型の言語である。強い型付けがあり、OOPの機能もより強いという利点がある。フロントエンドとバックエンドの両方で使えるが、サーバー側ではJavaScript ES6ほど普及していない。
Both client-side and server-side languages like JavaScript and PHP can be embedded into HTML code with embedded elements. An embedded element is a program designed to run inside some other program like HTML. On the client side, we embed JavaScript into HTML <script> elements and a browser calls the JavaScript interpreter when it encounters one. On the server side, we can embed PHP the same way with some rules. The script must be installed on the server and must have a file extension of .php.
英語のヒント
JavaScriptやPHPのようなクライアント側・サーバー側の言語は、どちらも埋め込み要素によってHTMLコード内に埋め込める。埋め込み要素とは、HTMLのような別のプログラムの中で動くように設計されたプログラムである。クライアント側では、JavaScriptをHTMLの<script>要素に埋め込み、ブラウザーがその要素に出会うと、JavaScriptインタープリターを呼び出す。サーバー側でも、いくつかの規則に従えば、同じようにPHPを埋め込める。スクリプトはサーバーに配置する必要があり、ファイル拡張子は.phpでなければならない。