The acts of the mind, wherein it exerts its power over simple ideas,
are chiefly these three: 1. Combining several simple ideas into one
compound one, and thus all complex ideas are made. 2. The second is
bringing two ideas, whether simple or complex, together, and setting
them by one another so as to take a view of them at once, without
uniting them into one, by which it gets all its ideas of relations.
3. The third is separating them from all other ideas that accompany
them in their real existence: this is called abstraction, and thus all
its general ideas are made.
心が単純な観念に対してその力を行使する行為は、主に次の三つである。
1. 複数の単純な観念を一つに結合すること。こうしてすべての複合観念が作られる。
2. 二つの観念を、単純であれ複合であれ、一つに統合することなく並べて同時に眺めること。こうしてすべての関係の観念が得られる。
3. 観念を、現実の存在において伴う他のすべての観念から分離すること。これは抽象と呼ばれ、こうしてすべての一般観念が作られる。
John LockeAn Essay Concerning Human Understanding
1690
We are about to study the idea of a
computational process.
Computational processes are abstract beings that inhabit computers.
As they evolve, processes manipulate other abstract things called
data.
The evolution of a process is directed by a pattern of rules
called a
program.
People create programs to direct processes.
In effect, we conjure the spirits of the computer with our spells.
これから私たちは計算プロセスという概念を学んでいきます。
計算プロセスは、コンピュータの中に存在する抽象的な存在です。
プロセスは進化しながら、データと呼ばれる別の抽象的なものを操作します。
プロセスの進化は、プログラムと呼ばれる規則のパターンによって導かれます。
人々はプロセスを制御するためにプログラムを作成します。
実際のところ、私たちは呪文でコンピュータの精霊を呼び出しているのです。
A computational process is indeed much like a sorcerer's idea of a
spirit. It cannot be seen or touched. It is not composed of matter
at all. However, it is very real. It can perform intellectual work.
It can answer questions. It can affect the world by disbursing money
at a bank or by controlling a robot arm in a factory. The programs we
use to conjure processes are like a sorcerer's spells. They are
carefully composed from symbolic expressions in arcane and esoteric
programming languages
that prescribe the tasks we want our
processes to perform.
計算プロセスは、まさに魔法使いが思い描く精霊のようなものです。
目に見えず、触れることもできません。
物質でできているわけでもありません。
しかし、それは非常に現実的な存在です。
知的な作業を行うことができます。
質問に答えることもできます。
銀行でお金を支払ったり、工場でロボットアームを制御したりして、現実世界に影響を与えることもできます。
プロセスを呼び出すために使うプログラムは、魔法使いの呪文のようなものです。
プログラムは、難解で奥深いプログラミング言語の記号的な式から注意深く組み立てられ、
プロセスに実行させたいタスクを規定します。
A computational process, in a correctly working computer, executes
programs precisely and accurately. Thus, like the sorcerer's
apprentice, novice programmers must learn to understand and to
anticipate the consequences of their conjuring. Even small errors
(usually called bugs)
in programs can have complex and unanticipated consequences.
正常に動作するコンピュータでは、計算プロセスはプログラムを正確かつ精密に実行します。
したがって、魔法使いの弟子のように、初心者プログラマは自分の呪文がもたらす結果を理解し、予測することを学ばなければなりません。
プログラムのほんの小さなエラー(一般に
バグ
と呼ばれます)でさえ、複雑で予期しない結果を招くことがあります。
Fortunately, learning to program is considerably less dangerous than
learning sorcery, because the spirits we deal with are conveniently
contained in a secure way. Real-world programming, however,
requires care, expertise, and wisdom. A small bug in a computer-aided
design program, for example, can lead to the catastrophic collapse of
an airplane or a dam or the self-destruction of an industrial robot.
幸いなことに、プログラミングを学ぶことは魔法を学ぶよりもずっと危険が少ないです。なぜなら、私たちが扱う精霊は安全に閉じ込められているからです。
しかし、現実世界のプログラミングには注意、専門知識、そして知恵が必要です。
たとえば、コンピュータ支援設計プログラムのちょっとしたバグが、飛行機やダムの壊滅的な崩壊、あるいは産業用ロボットの自己破壊を引き起こすこともあるのです。
Master software engineers have the ability to organize programs so
that they can be reasonably sure that the resulting processes will
perform the tasks intended. They can visualize the behavior of their
systems in advance. They know how to structure programs so that
unanticipated problems do not lead to catastrophic consequences, and
when problems do arise, they can
debug
their programs. Well-designed
computational systems, like well-designed automobiles or nuclear
reactors, are designed in a modular manner, so that the parts can be
constructed, replaced, and debugged separately.
熟練したソフトウェアエンジニアは、結果として生じるプロセスが意図したタスクを確実に実行するようにプログラムを構成する能力を持っています。
彼らはシステムの振る舞いを事前に思い描くことができます。
予期しない問題が壊滅的な結果につながらないようにプログラムを構造化する方法を知っており、問題が発生した場合にはプログラムを
デバッグできます。
適切に設計された計算システムは、適切に設計された自動車や原子炉と同様に、モジュール化された方式で設計されており、各部品を個別に構築、交換、デバッグできるようになっています。
Programming in JavaScript
We need an appropriate language for describing processes, and we will
use for this purpose the programming language JavaScript. Just as our
everyday thoughts are usually expressed in our natural language (such
as English, Swedish, or Chinese), and descriptions of quantitative
phenomena are expressed with mathematical notations, our procedural
thoughts will be expressed in JavaScript.
JavaScript was developed in 1995
as a programming language for controlling the behavior
of World Wide Web browsers through scripts that are embedded
in web pages.
The language was conceived by
Brendan Eich, originally under the name Mocha, which
was later renamed to LiveScript, and finally to JavaScript.
The name JavaScript
is a trademark
of Oracle Corporation.
プロセスを記述するには適切な言語が必要であり、ここではプログラミング言語 JavaScript を使用します。
日常の考えが自然言語(英語、スウェーデン語、中国語など)で表現され、量的な現象の記述が数学的記法で表されるように、私たちの手続き的な思考は JavaScript で表現されます。
JavaScript は 1995 年に、ウェブページに埋め込まれたスクリプトを通じて World Wide Web ブラウザの動作を制御するためのプログラミング言語として開発されました。
この言語は
Brendan Eich によって考案され、当初は Mocha という名前でしたが、後に LiveScript に改名され、最終的に JavaScript となりました。
JavaScript
という名前は Oracle Corporation の商標です。
Despite its inception as a language for scripting the web, JavaScript
is a general-purpose programming language. A JavaScript
interpreter is a machine that carries out processes described
in the JavaScript language.
The first JavaScript interpreter was implemented by Eich
at Netscape Communications Corporation for the Netscape Navigator web
browser.
JavaScript inherited its core features from the
Scheme and Self programming languages. Scheme is a dialect of Lisp, and
was used as the programming language for the original version of this
book. From Scheme, JavaScript inherited its most fundamental design
principles,
such as lexically scoped first-class
functions and dynamic typing.
ウェブのスクリプト言語として生まれたにもかかわらず、JavaScript は
汎用プログラミング言語です。JavaScript のインタプリタは、JavaScript 言語で記述されたプロセスを実行するマシンです。
最初の JavaScript インタプリタは、Eich が Netscape Communications Corporation で Netscape Navigator ウェブブラウザ向けに実装しました。
JavaScript は、
Scheme と Self というプログラミング言語からコア機能を受け継いでいます。Scheme は Lisp の方言であり、
本書のオリジナル版のプログラミング言語として使用されていました。Scheme から JavaScript は、レキシカルスコープのファーストクラス関数や動的型付けなど、最も基本的な設計原則を受け継いでいます。
JavaScript bears only superficial resemblance to the language Java,
after which it was
(eventually) named; both Java and JavaScript use the block structure of
the language C. In contrast with Java and C, which usually
employ compilation to lower-level
languages, JavaScript programs were initially
interpreted
by web browsers.
After Netscape Navigator, other web browsers provided interpreters
for the language, including Microsoft's Internet Explorer, whose
JavaScript version is called
JScript. The popularity of JavaScript for controlling web
browsers gave rise to a standardization effort, culminating in
ECMAScript. The
first edition of the ECMAScript standard was led by Guy Lewis
Steele Jr. and completed in June 1997
(ECMA 1997).
The sixth edition, known as ECMAScript 2015, was led by
Allen Wirfs-Brock and adopted by the General Assembly of ECMA in
June 2015 (ECMA 2015).
JavaScript は Java 言語とは表面的に似ているだけで、(最終的に)Java にちなんで名付けられました。Java と JavaScript はどちらも言語 C のブロック構造を使用しています。
Java や C が通常、低水準言語へのコンパイルを行うのに対し、JavaScript プログラムは当初ウェブブラウザによってインタプリトされていました。
Netscape Navigator の後、Microsoft の Internet Explorer をはじめとする他のウェブブラウザもこの言語のインタプリタを提供するようになりました。Internet Explorer の JavaScript バージョンは JScript と呼ばれます。
ウェブブラウザを制御するための JavaScript の人気は標準化の取り組みへとつながり、ECMAScript として結実しました。
ECMAScript 標準の初版は Guy Lewis Steele Jr. が主導し、1997 年 6 月に完成しました(ECMA 1997)。
ECMAScript 2015 として知られる第 6 版は Allen Wirfs-Brock が主導し、2015 年 6 月に ECMA の総会で採択されました(ECMA 2015)。
The practice of embedding JavaScript programs in web pages encouraged
the developers of web browsers to implement JavaScript interpreters.
As these programs became more complex,
the interpreters became more efficient in executing them, eventually
using sophisticated implementation techniques such as Just-In-Time
(JIT) compilation.
The majority of JavaScript programs as of this writing (2021) are embedded
in web pages and interpreted by browsers, but JavaScript is increasingly
used as a general-purpose programming language, using systems such as
Node.js.
ウェブページに JavaScript プログラムを埋め込む慣行は、ウェブブラウザの開発者に JavaScript インタプリタの実装を促しました。
これらのプログラムが複雑になるにつれて、インタプリタはその実行効率を高めていき、最終的には Just-In-Time(JIT)コンパイルなどの高度な実装技術を使用するようになりました。
本書執筆時点(2021 年)では、JavaScript プログラムの大半はウェブページに埋め込まれブラウザによってインタプリトされていますが、Node.js などのシステムを利用して汎用プログラミング言語としての利用もますます増えています。
However, it is the ability of
browsers to execute JavaScript
programs that makes it an ideal language for an online version
of a book on computer programs. Executing programs by clicking on
things on a web page comes naturally in JavaScript—after
all that is what JavaScript was designed for! More fundamentally,
しかし、
ブラウザが JavaScript プログラムを実行できることこそが、コンピュータプログラムに関する書籍のオンライン版に最適な言語にしています。
ウェブページ上のものをクリックしてプログラムを実行するのは JavaScript では自然なことです。結局のところ、それこそが JavaScript が設計された目的なのです! より根本的には、
ECMAScript 2015 possesses a set of features that make it an excellent
medium for studying important programming constructs and data
structures and for relating them to the linguistic features that
support them. Its
lexically scoped first-class functions and their syntactic support
through lambda expressions provide direct and concise access to
functional abstraction, and
dynamic typing allows the adaptation to remain close to the
Scheme original throughout the book. Above and beyond these
considerations, programming in JavaScript is great fun.
ECMAScript 2015 は、重要なプログラミング構成要素やデータ構造を学び、それらを支える言語機能と関連付けるのに優れた特徴を備えています。
レキシカルスコープのファーストクラス関数とラムダ式によるその構文サポートは、関数抽象化への直接的かつ簡潔なアクセスを提供し、動的型付けにより本書全体を通じて Scheme のオリジナルに近い形での改編が可能となっています。
これらの考慮を超えて、JavaScript でのプログラミングはとても楽しいものです。