Waiting..
Auto Scroll
Sync
Top
Bottom
Select text to annotate, Click play in YouTube to begin
00:00:08
given that the program is a database it's easy to create tools that operate on programs because we like biological metaphors we call these tools enzymes there is nip a very useful enzyme that
00:00:21
can extract a procedure from open code we start by selecting a piece of code that we think might be shareable we apply the enzyme and we get a procedure and a call to it with all the
00:00:32
necessary parameters formal and actual it's too bad that the system cannot come up automatically with a meaningful name so we have to supply that writing a new enzyme is not very hard
00:00:47
using ip's powerful apis and domain specific abstractions the lift procedures enzyme is only a few pages long the most important consequence of the iptree representation is to create an
00:01:02
ecology for new abstractions this means that new abstractions of any kind can be added to the system and used right away because the abstractions are used to express the programmer's computational intent we frequently use
00:01:15
the word intention to mean an abstraction a programming language feature a definition in the ip tree we recall that to make an intention useful we need to provide it with an identity then describe how it should
00:01:28
look how it might be implemented edited and so on intentions can cooperate through parameters for example an if statement has its condition and the conditional statement under it as its parameters in principle
00:01:42
any intention can have parameters and any intention can be a parameter it's up to the intentions to decide what combinations make sense the implementation of an intention is described by a transformation enzyme
00:01:55
very much like the editing enzyme we saw earlier let's now turn to a difficult technical problem how can we create a system where separately written transformations can come together operate on the same source tree and
00:02:08
produce a meaningful result paul will explain the solution at compile time the intentions in a program must collaborate to build the desired target the nodes in the tree have to make their contributions to this process in some
00:02:21
order and that order must be determined by ip it's essential the information that any intention acquires will not be invalidated later by another independent intention so to ensure the ip can quickly find an order in which nothing
00:02:34
is invalidated the api allows an intention to ask for the minimal information it needs a node can directly examine only its own structure in order to learn more about its context in the tree it will make
00:02:46
stylized queries of other nodes connected to it we call these queries questions questions are semantic in nature since the semantics of a node is unlikely to change during the build even as the tree structure is transformed
00:02:59
examples of questions are what is your type do you have a constant value and most importantly what is the lower level tree the reduced tree that constitutes your implementation
00:03:16
these semantic questions provide a means for portions of the tree to be abstracted away yet still cooperate with the surrounding nodes when an intention expresses itself in terms of other intentions it can
00:03:28
delegate questions to them for example a while loop might choose to implement itself in terms of ifs and go to's questions that the if can handle are delegated to it saving the author of
00:03:39
while the trouble of handling them some questions may still be intercepted by while though for example a question about where to jump in order to break out of the loop a strict rule for transformations is
00:03:52
that additions to the tree are allowed but deletions are not if nodes could come and go in the tree it would be impossible for ip to decide whether to report the presence of a node to an observer by convention all additions are visible
00:04:04
to intentions that look for them which means that observers must run after modifiers the system maintains extensive dependency structures to enforce this rule ip could not guarantee that any two intentions will work together
00:04:18
but it can detect incompatibilities and report an error with carefully chosen questions it will be possible for intentions to work together when it is meaningful to do so the benefits of intentional identity are
00:04:30
clear when for example there's only one definition for an operator but in case of generics when there are several possible definitions for the same operator the situation is even more interesting making explicit what used to
00:04:43
be implicit is typical to ip a generic operator points to an archetype declaration that represents the abstract operation this declaration is also a convenient place to summarize what is common among the diverse instances
00:04:57
the specializations of the generic procedure will be contributed to the archetype these specializations could appear next to the archetype definition however the archetype is frequently found in a standard library that we
00:05:09
cannot change so we prefer to place the specialization separate from the archetype the system will collect the contributions and select the appropriate instance for each generic reference we've seen how new programs can be
00:05:23
created and edited in ip but what about legacy code abstractions of a legacy language such as c plus plus can be defined as intentions we can adapt a standard compiler front end to parse c plus plus
00:05:37
text and create the intentional tree this can be done for other languages as well for example for java or for html the preprocessor directives of c plus
00:05:52
plus create some interesting challenges it would not be a good idea to simply parse the output of the preprocessor into an ip tree because valuable information would be lost what we would like is to preserve the invariance
00:06:04
represented by the pre-processor directives and expressed them intentionally this can be achieved by a rather complex algorithm the results of automatic preprocessor intention recovery are very interesting
00:06:17
let's look at a typical example here we see a macro definition in the c source and a particular macro call with no parameters after import into ip we see the
00:06:30
automatically recovered macro definition and the macro call note the two new parameters in ip the first one appears because the original macro trickily referred by name to a local variable in the calls environment
00:06:43
a different variable in each call the second parameter is the body of the loop that has been picked up by the sneaky syntax of the original macro in this case ip did not just express the
00:06:58
invariances of the original tricky macro correctly and without pre-processor actions but it also made the undesirable dependency more visible and correctable similar results exist for if-def's
00:07:10
includes and name concatenations we've seen that ip can express abstractions from a wide variety of languages from c preprocessors c plus plus and other object-oriented languages
00:07:23
but even greater opportunities exist with domain-specific abstractions our example comes from the common domain of user interfaces this is an applet exercise written in java that implements a simple paint
00:07:35
program i can use the applet to select a color draw with the mouse and clear the canvas for a new drawing the interesting point is that more than half of the program text is there to
00:07:48
implement the user interface we mark this portion in red the main goal of the code is to paint of course from that perspective the interface is just some magic by which the user sets class variables such as
00:08:01
the pen color or calls some methods such as the method for clearing the canvas ideally the user interface widgets that are used for this purpose would be completely separated from the part of the code that concerns itself with
00:08:13
painting moving to ip let us delete all the interface code and mark the declarations of the variable and the procedure which we think should be under user control
00:08:29
this mark is an intention that can be transformed to exactly the desired interface note for example that the transforming enzyme could automatically create the drop down list from the enumerated type
00:08:47
referenced in the declaration if we now add a new color parameter to the clear procedure we see that the interface will change accordingly incorporating the same change in the original java source would have taken 25
00:09:12
lines any one of which could have been the cause of a bug when intentions are improved all users benefit for example just by loading an update of the intention the interface will be improved in this case by the
00:09:25
automatic incorporation of a color picker java is a procedural language its statements describe how to do things in contrast many domain abstractions including the one we've just used are
00:09:41
declarative they describe what should be done they're better because they're short and allow many ways of accomplishing the intention by separating the intention from the implementation improvements in the
00:09:54
implementations become accessible to the programmers without having to change the program source you
End of transcript