$\def\aal{\alpha{\raise 1pt\hbox{\hskip -4pt{\char'47}}}}
M\epsilon\tau\alpha\beta\acute{\alpha}\lambda\lambda o \nu\
ἀ\nu\alpha\pi\alpha\acute{\upsilon}\epsilon\tau\alpha\iota$
(Even while it changes, it stands still.)
(変化しながらも、それは静止している。)
Heraclitus
Plus ça change, plus c'est la même chose.
変われば変わるほど、同じことである。
Alphonse Karr
The preceding chapters introduced the basic elements from which
programs are made. We saw how primitive
functions
and primitive data are combined to construct compound entities, and we
learned that abstraction is vital in helping us to cope with the complexity
of large systems. But these tools are not sufficient for designing
programs. Effective program synthesis also requires organizational
principles that can guide us in formulating the overall design of a
program. In particular, we need strategies to help us structure large
systems so that they will be
modular, that is, so that they can
be divided naturally
into coherent parts that can be
separately developed and maintained.
前の章では、プログラムを構成する基本要素を紹介しました。プリミティブな
関数
とプリミティブなデータを組み合わせて複合的な構成要素を作る方法を見てきましたし、大規模なシステムの複雑さに対処するうえで抽象化が不可欠であることも学びました。しかし、これらのツールだけではプログラムを設計するには不十分です。効果的なプログラム合成には、プログラム全体の設計を定める指針となる組織化の原則も必要です。特に、大規模なシステムを
モジュール的に構成する——つまり、個別に開発・保守できるまとまりのある部分へ自然に
分割できるようにする——ための戦略が求められます。
One powerful design strategy, which is particularly appropriate to the
construction of programs for
modeling physical systems, is to base the
structure of our programs on the structure of the system being
modeled. For each object in the system, we construct a corresponding
computational object. For each system action, we define a symbolic
operation in our computational model. Our hope in using this strategy
is that extending the model to accommodate new objects or new actions
will require no strategic changes to the program, only the addition of
the new symbolic analogs of those objects or actions. If we have been
successful in our system organization, then to add a new feature or
debug an old one we will have to work on only a localized part of the
system.
強力な設計戦略の一つは、特に物理システムの
モデリングに適したもので、モデル化する対象システムの構造に基づいてプログラムの構造を組み立てるというものです。システム内の各オブジェクトに対して、対応する計算オブジェクトを構築します。システムの各動作に対して、計算モデル内でシンボリックな操作を定義します。この戦略を用いる狙いは、新しいオブジェクトや新しい動作に対応するためにモデルを拡張するとき、プログラムの戦略的な変更は不要で、それらのオブジェクトや動作に対応する新しいシンボリックな表現を追加するだけで済むようにすることです。システムの組織化がうまくいっていれば、新機能の追加や既存のバグ修正も、システムの局所的な部分だけを扱えばよくなります。
To a large extent, then, the way we organize a large program is
dictated by our perception of the system to be modeled. In this
chapter we will investigate two prominent organizational strategies
arising from two rather different world views
of the
structure of systems. The first organizational strategy concentrates on
objects, viewing a large system as a collection of distinct objects
whose behaviors may change over time. An alternative organizational
strategy concentrates on the
streams of information that flow in
the system, much as an electrical engineer views a signal-processing
system.
したがって、大規模なプログラムの組織化の方法は、モデル化する対象システムをどう捉えるかに大きく左右されます。この章では、システムの構造に対する大きく異なる二つの世界観
から生まれる、二つの主要な組織化戦略を検討します。第一の組織化戦略は
オブジェクトに焦点を当てるもので、大規模なシステムを、時間とともに振る舞いが変化しうる個別のオブジェクトの集まりと見なします。もう一つの組織化戦略は、システム内を流れる情報の
ストリームに焦点を当てるもので、電気技術者が信号処理システムを捉えるのに似ています。
Both the object-based approach and the stream-processing approach
raise significant linguistic issues in programming.
With objects, we must be concerned with how a computational object can
change and yet maintain its identity. This will force us to abandon
our old substitution model of computation
(section
[1.1.5]) in favor of a more
mechanistic but less theoretically tractable
environment model of
computation. The difficulties of dealing with objects, change, and
identity are a fundamental consequence of the need to grapple with
time in our computational models. These difficulties become even
greater when we allow the possibility of concurrent execution of
programs. The stream approach can be most fully exploited when we
decouple simulated time in our model from the order of the events that
take place in the computer during evaluation. We will accomplish this
using a technique known as
delayed evaluation.
オブジェクトに基づくアプローチとストリーム処理に基づくアプローチは、どちらもプログラミングにおいて重要な言語上の問題を提起します。オブジェクトでは、計算オブジェクトがどのように変化しつつもその同一性を保つことができるかに注意を払わなければなりません。これにより、これまでの置換モデル(section
[1.1.5])を放棄し、より機械的ではあるものの理論的には扱いにくい
環境モデルを採用することを余儀なくされます。オブジェクト、変化、同一性を扱う際の困難は、計算モデルの中で時間という問題に取り組む必要があることの本質的な帰結です。プログラムの並行実行の可能性を認めると、これらの困難はさらに大きくなります。ストリームアプローチは、モデル内のシミュレートされた時間と、評価中にコンピュータで生じるイベントの順序を切り離すことで、最も十分に活用できます。これを実現するために、
遅延評価と呼ばれる技法を用います。
3
Modularity, Objects, and State
モジュール性、オブジェクト、状態