[erlang-questions] [ANN] Brim - HTML templating library

Michael Turner michael.eugene.turner@REDACTED
Fri Mar 16 06:41:13 CET 2012

Richard, I wouldn't consider autocompletion "programming by example",
and especially not for purposes of discussion here. A successful
result from autocompletion is still only a text-paste in a GUI, once
and only once. A successful result in PBE is a step added to an
algorithm specification that you'd (at least potentially) save and
later reuse in many hands-off, unseen operations.

Keyboard macros also aren't quite it, either, though they come much
closer to the idea. Insofar as they contain parameterized
search-replace commands, they involve recognition of explicitly
described patterns (code) rather than inferring patterns and
generating the code. Also, keyboard macros can't really do iteration
(or did I miss something in their development?)

The basic idea of PBE can work in a batch environment (and indeed was
probably first applied there, if not under that rubric): here's the
input, here's the output,  give me back a best guess at a mapping

But thanks for pointing out autocompletion anyway. A non-interactive
*kind* of autocompletion might work nicely for what I suggest. A web
designer might want to include substantial amounts of text in order to
get a sense of the balance of the layout. So for the web designer, my
HTML example becomes

 <head><title>The Title</title></head>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

But it would be ungainly, in the code, to include that whole
greeked-text paragraph in the Erlang term for which you want to
establish a mapping. As a coder, you'd probably prefer to supply the
matching algorithm with a more concise input data structure like this:

 { <<"The Text">>, <<"Lorem ipsum ...">> }

Here it should be understood that <<"[some text] ...">> says to match on

  <sometags>Lorem ipsum *</sometags>

in the HTML template input, in effect a kind of autocompletion of the
pattern specification.

What's the point? It's to maximize results by taking complex
communication between experts down to the bare minimum. There are
people who can design gorgeous web layouts but who can't handle code
at all -- including fairly minimal CSS selectors. There are
programmers who can implement anti-gravity and controlled
thermonuclear reactions in their sleep, but whose web page layouts are
invariably, irretrievably ugly. It's like that line from that movie,
"With my looks and your brains, we could go far." PBE could help more
people go the distance, and in record time.

-michael turner

On Fri, Mar 16, 2012 at 6:06 AM, Richard O'Keefe <ok@REDACTED> wrote:
> On 16/03/2012, at 1:17 AM, Michael Turner wrote:
>> Dan Halbert pioneered PBE at Xerox PARC. It was later taken up as a
>> research project at at Apple. Then it was championed by none other
>> than Melinda Gates, at Microsoft.
>> It never took off.
> No?  There are programmers who swear by "Intellisense" and similar automatic
> completion whizz-bang in their IDE.  One of the Smalltalk systems I use,
> Pharo, does this.  I swear *at* it, but that's another story.  The web browser
> I mainly use offers an autocomplete list when I start to type a URL.  Unlike
> Pharo, this doesn't visually obscure what I'm trying to type, so I just use it,
> and don't swear at it.  Start typing a query in the Google box, and again an
> autocomplete list pops up (but NOT in the way!) and very handy it is.
> That's small-scale programming by example.
> I don't know what key it is that I'm pressing by mistake, but it seems as if
> every time I have to use vim and want to quit I end up in macro recording and
> have to spend a long time finger-dancing on the keyboard just to quit.  Macro
> recording is precisely programming by example.
> The thing that Windows victims got unhappy about was *not* the system watching
> what they were trying to do and getting *ready* to be helpful about it but the
> system seizing control.  If Clippy had stayed entirely off the screen unless
> and until people pressed a special Ctrl-Alt-Help chord, it would still be here.
> I had to use Explorer the other day on someone's netbook, and I started typing
> a URL and it seized control from me, saying in effect, "no, I know better than
> you what you want, you really want to go to your home page, and to prove how
> much better I know than you do, I'm going to delete your typing."  PBE is not
> the problem, interfering is the problem.

More information about the erlang-questions mailing list