
Boomerang: A bidirectional programming language for ad-hoc data - durana
http://www.seas.upenn.edu/~harmony/
======
showerst
A note to anyone who creates a new programming language: Please put up a quick
bite of sample code that shows how your language looks and what it does on the
site, and don't require me to download a PDF and search through it.

~~~
benhoyt
Good call. Quote from the PDF in the meantime:

"To give a sense of what programming in Boomerang is like, we will define the
lens implementing the transformations between XML and CSV composers shown
above.

First we define a lens c that handles a single <composer> element. It uses a
number of functions defined in our XML library, as well as primtives for
copying (copy) and deleting (del) strings, and for concatenating lenses (.).

    
    
        let c : lens =
          Xml.elt NL2 "composer"
            begin
              Xml.simple_elt NL4 "name"
                (copy [A-Za-z ]+ . ins ", ") .
              Xml.attr2_elt_no_kids NL4 "years"
                "birth" (copy NUMBER . ins "-")
                "death" (copy NUMBER) .
              Xml.simple_elt NL4 "nationality" (del [A-Za-z]+)
            end
    

Using c, we then define a lens that handles a top-level <composers> element,
enclosing a list of <composers>. This lens is defined using the features
already described, a primitive for inserting a string (ins), as well as union
(|) and Kleene star.

    
    
        let cs : lens =
          Xml.elt NL0 "composers"
            begin
              copy EPSILON |
              c . (ins newline . c)*
            end
    

..."

~~~
benhoyt
Ask HN/PG: Asterisks _around something_ make it italics (except in indented
code, apparently). In the above comment I had to remove a literal asterisk in
the text because I couldn't figure out how to escape it. Backslash doesn't
work, and two stars in a row doesn't work. Any ideas?

Update: Okay, so putting spaces around it ( * ) works. But the asterisk in
question was inside parens without spaces.

------
ShabbyDoo
I just skimmed the manual a bit, so I'm still quite uninformed. Does it
require bidi translations? If so, that's quite a limitation as most of the
data manipulations I've done have been at least a bit lossy.

Some formalisms would certainly be nice though..it's easy to think that you've
transformed data well only to find holes in your methods later.

~~~
gjm11
Oddly enough, it allows _lossy bidirectional translations_. The general setup
is that you have an "abstract" representation of some information, and a
"concrete" representation that may have extra details in it. Then the three
key operations are:

"get" abstract info from a concrete version;

"put" new abstract info into a concrete version, returning a new concrete
version;

"create" a new concrete version from abstract info, presumably filling in
extra details with defaults.

The running example in their tutorial is a database of information about
composers. The "concrete" version is an XML file. The "abstract" version is
something more compact, one entry per line, which omits the nationality data
in the XML file.

~~~
ShabbyDoo
Oh, ok....bidirectional != roundtrip-able

Now that makes sense.

~~~
mgreenbe
Not quite. A lens comprises three operations:

    
    
      get : C -> A
      put : A x C -> C
      create : A -> C
    

And the GetPut, PutGet, CreateGet laws require of every lens that:

    
    
      put (get c) c = c
      get (put a c) = a
      get (create a) = a
    

In other words, if there are no edits, then it _is_ a round trip. The real
inequality you mean is bidirectional != bijective.

(EDIT: for typesetting equations.)

------
mahmud
It's another Benjamin Pierce project, so you know it has solid theoretical
foundations, and it's written in OCaml :-)

~~~
carterschonwald
I had the pleasure of having out with the folks in the UPenn plclub (their
programming language research group) one summer during high school, awesome
group of people. One fellow who graduated a year agowas hacking together a
pretty snazzy user level tcp/ip stack with a programmable scheduler in
haskell. (some measures indicated that it did better than apache or erlang!)

------
joe_the_user
Well, Their site requires Javascript for no good reason, so that's a point
against them.

~~~
ionfish
It uses it for the pagination, which is both irritating and pointless. The
only advantage gained by doing this is speed--and they could have that by
making the links go to anchors within the page. This kind of thing is far from
rare, but it does make me sad when I see real programmers doing it.

