In 1974, Donald Knuth had already remarked:
--8<-------------------------------------------------------->8---
For 15 years or so I have been trying to think of how to write a
compiler that really produces top quality code. For example, most of
the MIX programs in my books are considerably more efficient than any
of todayN++N++N++s most visionary compiling schemes would be able to
produce. [...] We [...] always [ran] up against the same problem: the
compiler needs to be in a dialog with the programmer; it needs to know
properties of the data, and whether certain cases can arise, etc.
For some reason we all (especially me) had a mental block about
optimization, namely that we always regarded it as a behind-the-
scenes activity, [...] which the programmer isnN++N++N++t supposed to know.
This veil was first lifted from my eyes in [...] 1973, when I ran
across a remark by Hoare [...] that, ideally, a language should be
designed so that an optimizing compiler can describe its optimizations
in the source language. Of course! Why hadnN++N++N++t I ever thought of it?
A program-manipulation system is obviously what weN++N++N++ve been leading up
to, and I wonder why I never thought of it before. Of course, the
idea isn't original with me; when I told Hoare, he said, ``Exactly!''
and referred me to a recent work by Darlington and Burstall [...]
which describes a system which removes some recursions from a
LISP-like language (curiously, without introducing any [go-to]N++N++N++s)
[...]. Since LISP programs are easily manipulated as LISP [...]
objects, there has also been a rather extensive development of similar
ideas in this domain, notably by Warren Teitelman [...]. The time is
clearly ripe for program-manipulation systems, and a great deal of
further work suggests itself.
Source: ``Structured programming with go to statements,'' Donald
E. Knuth, ACM Computing Surveys (CSUR) 6.4 (1974): 261--301.
--8<-------------------------------------------------------->8---
It seems to me that telling the compiler what is mutable is a clear >illustration of how a compiler is in dialog with the programmer, just
like declaring a variable's type, with the C ``register'' keyword as
another example.
It's actually a monolog. You might consider that error messages from
a compiler turn it into a dialog, but that's not how programming in
most languages works (including Lisp, while Rust may be the exception
that proves the rule).
It seems that we prefer to write executable programs from the start,
and either optimize them by applying transformations manually, or
fully automatic (using an optimizing compiler), not
semi-automatically. I guess one of the problems of the idea of semi-automatic transformations is that the transformations are no
longer applicable after changes due to changes in requirements. So
you either want to apply the changes to the transformed program (and
when you transform it manually, and treat the transformed program as
the new source, you can easily apply changes to the transformed
program), or you want fully automatic transformation, even if you only
get a best-effort result.
This reminds me the research project CIP (Computer-Aided,
Intuition-Guided Programming): They designed a wide-spectrum language
CIP-L (described in LNCS 183, published 1985) and a program
transformation system CIP-S (described in LNCS 292, published 1987).
The idea was that you write a specification in CIP-L, and then tell
CIP-S to perform various transformation steps, that eventually result
in an executable and efficient program.
This idea looked interesting, amd I looked in the books, but did not
find them inspiring apart from the basic idea. And apparently the
idea has not taken the world by storm, not even in the research world (according to Springer there are 63 citations of LNCS 183 and 45 of
LNCS 292).
This idea looked interesting, amd I looked in the books, but did not
find them inspiring apart from the basic idea. And apparently the
idea has not taken the world by storm, not even in the research world
For 99% of my code, the compiler does a good enough job, but for the remaining case, I often would like to be able to state some specific
property which I'd like to get, but often it's hard to state it clearly
in terms of the source code in a way that will still make sense further
down the compilation stages.
[This reminds me of the extensible languages like EL/1 and IMP72 that were popular in the 1970s. They ended up being unusable because every program
was in a different language. -John]
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 76 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 54:02:23 |
| Calls: | 1,265 |
| Calls today: | 1 |
| Files: | 1,362 |
| D/L today: |
3 files (2,684K bytes) |
| Messages: | 285,448 |