On Mar 2, 3:22 am, William Pursell <bill.purs...@gmail.com> wrote:
> On Mar 1, 7:23 pm, "jason.cipri...@gmail.com"
>
> <jason.cipri...@gmail.com> wrote:
> > On Mar 1, 1:26 pm, Kaz Kylheku <kkylh...@gmail.com> wrote:
>
> > > ROFL.
>
> > I don't know whether to admire you for having enough free time to
> > write the same tedious old code over and over again, or to feel bad
> > for you because while you are sitting there spending days coding the
> > same stuff you've been coding repeatedly for years, I've already
> > started, developed, and completed projects for 5 different clients.
>
> It seems to me that you (Jason) have completely missed the point
> that Kaz is making. Here's my attempt to summarize:
>
> OP: (not quoted by jason) Code generation is a brand new emerging
> technology!
> KAZ: It is not new, it was in widespread use 20 years ago, but you
> didn't notice.
> Jason: Kaz, you're an old hack who spends all your time re-inventing
> the wheel.
Generating source code text is only an implementation strategy for
writing compilers, when you don't have any other interface to target
language.
I only invoked the old guys as an example of how the use of code
generation was already mature long ago, not to criticize them.
I could have chosen these examples instead: high level languages that
are compiled by translating to C. C++ started out as ``C with
classes'', whose compiler put out C code. Some later C++ compilers
worked that way too. That implementation strategy has been used for
other languages, such as Eiffel and Kyoto Common Lisp and its
derivatives.
Should therefore C++ be regarded as a work of code generation? Is that
what is interesting about C++? Is Stroustrup's contribution to
computing that he wrote a program that wrote source code that was fed
to another program? What about the actual semantics of C++?
What is this state of the art of code generation that these people are
trying to adavnce who are getting together for this seminar in
Cambridge, and how does their state of the art really compare to
ancient projects like C with classes, or those pipeline-able Unix
utilities for typesetting? The old guys had code generation down pat
(and they aren't going to the conference).
But I also have another subtle point: namely that text-based code
generation is not only just an implementation kludge when you don't
have an alternate interface; but because it's a kludge, the technique
has no state of the art. To conduct conferences about its advancement
is folly.
The right way to do metaprogramming is with data structures
representing a program, not with character strings representing a
program.
Examples: Lisp and Scheme macros, C++ templates.
The state of the art in code generation has for decades now not
involved writing stuff into files and invoking compilers on it.
That remains the ``state of the kludge'', which, of anyting, requires
gradual retirement, rather than advancement.
> The examples Kaz gave are demonstrations of the technique employed
> to avoid re-implementing the wheel. How you interpreted that as
> an indicator that he reinvents the wheel for each project is,
> to me, an good example of completely missing the point.
Analogy:
Hacker: An international conference on code indentation? ROFL
Goof: What are you laughing at, disrespectful ass? I feel sorry
for the people that have to maintain with your unindented
code!
Way to undermine your credibility.
Hacker: WTF?
And must I have credibility to ROFL? What is credibility? It's the
degree to which we can trust someone's statement of /fact/ without
consulting another source. It has nothing to do with opinions. If say
that generating source code is a fragile, inefficient, limited hack
arising from the target language not giving you a hooks for
manipulating code as data, that is merely my opinion. It is not a
statement of fact. So, in making that statement, I am not using up my
credibility cookies, except to the extent that my opinion might reveal
stupidity or ignorance of the subject matter (which is relevant to
credibility because stupidity and ignorance are undeniably linked to
poor fidelity in the internalization and regurgitation of facts).
And I do in fact have a fairly strong background in code generation.
In my undergraduate days, I took a hands-on course in operating
systems. The class was crowded, and we didn't have enough Sun 2 boxes
(Motorola 68010) on which to run our code. So I decided to write an
emulator. At the core of the emulator was a giant switch statement to
dispatch funtions to opcodes. Of course, I didn't write and maintain
it by hand; I wrote a code-generating script. The input to the script
was a specification using regular expressions on strings of 1's and
0's to match instruction bit patterns and assign them to named
instruction groups. I could handle a family of instructions with one
function by writing a pattern that matches them all and assigns them
to the same group. The generated switch statement would capture all
possible opcode values to the same case. If I wanted the switch to do
more decoding and the handlers to do less (for more speed), I would
break up the group into finer pattern matches.
So for someone to accuse me of repetitively coding everything without
ever making the machine doing all the work is ridiculous.
I had my love affair with lex and yacc too; it didn't last very long
after graduation. I've produced maybe a dozen lex and yacc jobs. I
know I've written more than one hack where some condensed data file
was translated into static C data structures, making that data
available as part of a program's image.
My current company uses an in-house developed technology (rather large
and ambitious) based on code generation. I'm not the principal author,
but I had my fingers in it.
I have lots of experience hacking with text-based macro preprocessing
like m4 (and even wrote a macro preprocessor that was intended to be
superior to it). And of course, I have lots of experience with real
metaprogramming in Lisp: code that writes code, and even code that
writes code that writes code (all without converting anything to
characters that have to be lexed again).
On that harshly-criticized old web site of mine, there are some
projects which are orphaned pages, like this one:
http://users.footprints.net/~kaz/mpp
Why is that not linked from the main page? Because eventually I became
ashamed of it. Not the project itself, but rather the fact that I had
once been interested in something like that.