We have now considered the elements of programming: We have used
primitive arithmetic operations, we have combined these operations, and
we have abstracted these composite operations by
declaring them as compound functions.
But that is not enough to enable us to say that we know
how to program. Our situation is analogous to that of someone who has
learned the rules for how the pieces move in chess but knows nothing
of typical openings, tactics, or strategy. Like the novice chess
player, we don't yet know the common patterns of usage in the domain.
We lack the knowledge of which moves are worth making
(which functions are worth declaring).
We lack the experience to predict the consequences of making a move
(executing a function).
ここまでプログラミングの要素を見てきました。プリミティブな算術演算を使い、それらの演算を組み合わせ、その複合的な操作を複合関数として宣言することで抽象化してきました。しかし、それだけではプログラミングができるとは言えません。私たちの状況は、チェスの駒の動かし方のルールは覚えたものの、典型的な序盤戦術や戦略をまったく知らない人に似ています。初心者のチェスプレイヤーと同じように、この分野でよく使われるパターンをまだ知りません。どの手を指す価値があるのか(どの関数を宣言する価値があるのか)がわからないのです。手を指した結果(関数を実行した結果)がどうなるかを予測する経験も不足しています。
The ability to visualize the consequences of the actions under
consideration is crucial to becoming an expert programmer, just as it
is in any synthetic, creative activity. In becoming an expert
photographer, for example, one must learn how to look at a scene and
know how dark each region will appear on a print for each possible
choice of exposure and
processing options.
Only then can one reason backward, planning framing, lighting,
exposure, and
processing
to obtain the desired effects. So it is with programming, where we are
planning the course of action to be taken by a process and where we control
the process by means of a program. To become experts, we must learn to
visualize the processes generated by various types of
functions.
Only after we have developed such a skill can we learn
to reliably construct programs that exhibit the desired behavior.
検討中のアクションの結果を思い描く能力は、熟練したプログラマーになるために不可欠です。これは、あらゆる創造的な活動と同じです。たとえば、熟練した写真家になるには、シーンを見て、露出や処理オプションの選択ごとに、プリントの各領域がどの程度暗くなるかがわかるようにならなければなりません。
そうして初めて、望む効果を得るために、構図、照明、露出、処理を逆算して計画できるのです。プログラミングも同様で、プロセスが取るべき一連のアクションを計画し、プログラムによってプロセスを制御します。熟練するためには、さまざまな種類の関数が生成するプロセスを思い描けるようにならなければなりません。そのようなスキルを身につけて初めて、望ましい振る舞いを示すプログラムを確実に構築できるようになるのです。
A
function
is a
pattern for the local evolution of a
computational process. It specifies how each stage of the process is
built upon the previous stage. We would like to be able to make
statements about the overall, or global, behavior of a
process whose local
evolution has been specified by a
function.
This is very difficult to do in general, but we can at least try to
describe some typical patterns of process evolution.
関数とは、
計算プロセスの局所的な発展のパターンです。プロセスの各段階が前の段階の上にどのように構築されるかを規定します。関数によって局所的な
発展が規定されたプロセスの、全体的つまり大域的な振る舞いについて述べたいところです。一般的にこれは非常に難しいことですが、少なくともプロセスの発展の典型的なパターンをいくつか記述してみることはできます。
In this section we will examine some common shapes
for
processes generated by simple
functions.
We will also investigate the rates at which these processes consume the
important computational resources of time and space. The
functions
we will consider are very simple. Their role is like that played by test
patterns in photography: as oversimplified prototypical patterns, rather
than practical examples in their own right.
このセクションでは、単純な関数が生成するプロセスに共通する「形」をいくつか調べます。また、これらのプロセスが時間と空間という重要な計算資源をどのような速度で消費するかも調べます。ここで扱う関数は非常に単純なものです。それらの役割は写真におけるテストパターンのようなもので、実用的な例そのものではなく、過度に単純化した原型的パターンです。