Liberate computer user from programmingrus/liberate.pdf · • Computer programming is the activity...
Transcript of Liberate computer user from programmingrus/liberate.pdf · • Computer programming is the activity...
Liberate computer user fromprogramming
Teodor Rus
The University of Iowa, Department of Computer Science
Liberate computer use from programming – p.1/60
Computers
A computer (C) is a composed mechanismC = 〈Processor,Memory, I/Odevices〉 where:
1. Memory is an electronic device that can store encodedinformation representing operations and data.
2. Processor is an electronic device that executes operations storedin memory. It has a register called program counter (PC) and performs the loop:
while (PC.opcode is not halt)
Execute (PC); PC := Next(PC);
3. I/O devices allow one to store and retrieve information in/fromcomputer memory
Liberate computer use from programming – p.2/60
Formal expressionbeginSpec
name ComputerSystem is
sort Memory, Processor, Devices, Control;
opns receive:Device x Control -> Memory,
transmit:Memory x Control -> Device,
store:Processor x Control -> Memory,
fetch:Memory x Control -> Processor,
process:Memory x Processor x Control -> Processor,
Memory x Processor x Control -> Memory,
Processor x Control -> Processor;
vars PC: Control;
axms Value(PC.operation) in {receive,transmit,store,fe tch,process};
actn Run:: while PluggedIn and PowerOn do
l_0: Perform (PC); PC := Next(PC) :ˆl_0
endSpec
Liberate computer use from programming – p.3/60
Problem solving
To solve a problems with a computer we need to:1. Develop an algorithm that solves the problem.
2. Represent the algorithm using the machine-language of thecomputer. This representation was called a program.
3. Use an input device to load the program in computer memory.
4. Activate the machine by loading the PC register with the memoryaddress of the program start instruction.
5. Use an output device to retrieve the result generated by program.
Liberate computer use from programming – p.4/60
Computer programming• Programs are machine-language
representations of algorithms to be performedby a computer.
• Computer programming is the activity ofmapping algorithms into programs.
Liberate computer use from programming – p.5/60
Facts• Fact 1: algorithms are developed using human-logic and are
expressed using the natural language of the problem domain.
• Fact 2: programs are developed using machine-logic and areexpressed using the artificial (binary) language of the machine.
• Fact 3: Programming is tedious, error prone, and requiresprofessional knowledge of both problem domains (to developalgorithms) and computers (to represent algorithms usingmachine languages)
Liberate computer use from programming – p.6/60
ProblemLiberate problem solving from programming!
Rationale:1. Programming is tedious
2. Programming is error prone
3. Problem solving by computer programming is un-natural:it requires problem domain expert to become a computer expert.
Liberate computer use from programming – p.7/60
Programming is tedious• To make programming simpler and avoid errors, tools (software
tools) that allow program development using human languageshave been invented.
• Conceptual gap: when people think about their problem domainthey handle conceptual representations which are fundamentalydifferent from the reprsentations computers accept when they areprogrammed [SCS96].
Liberate computer use from programming – p.8/60
Bridging the gap1. By raising the level of abstractions computers accept.
This fails because of the conceptual gap; it only increasessoftware compexity.
2. By making programming more like thinkingThis fails because human thinking mechanism is different fordiffertent problem domains.
3. By make programming easier through domain special languagesThis fails because language learnig is difficult and it does notbridge the gap.
Liberate computer use from programming – p.9/60
The solution1. Characterize problem domain in terms of concepts that are:
universal in the domain, stand-alone, and composable.
2. Computationally emancipate problem domain structure it using a
domain ontology where terms are associated with computer articats implementing
them.
3. Dedicate a virtual machine to problems domain and make thedomain problem solving process identical with domainprogramming.
Note: this problem solving paradigm takes the computer to the problem
rather that taking the problem to the computer.Liberate computer use from programming – p.10/60
Example software tools• Generation 0: (assembly languages and assemblers) allow the use
of mnemonic notations for the machine binary codes.
• Generation 1: (imperative programming languages, compilers, andinterpreters) allow the use of symbolic notation for both machineoperation and program control-flow.
• Generation 2: tools that support a variety of programming styles(functional, logical, concurrent, visual, synchronous, constraint,object-oriented, aspect-oriented. etc.).
• Generation 3: tools that support special-purpose programminglanguages.
Liberate computer use from programming – p.11/60
Essence of programming
It doesn’t matter what programming tool oneuses, by programming one creates programs.
That is, by programming one creates binaryrepresentations of problem solving processes.
Question: can computer user be liberated from
programming?
Liberate computer use from programming – p.12/60
ObservationsIt doesn’t matter what tools one uses to createprograms:
• programming is still the same kind of technically tedious task,albeit carried out on a higher, more appropriate, level ofabstraction [Har08].
• program developer needs to understand both the algorithm(problem domain) and program (the computer)
• the use of higher abstractions to create programs implies complexsoftware tools and consequently difficulties for computer user.
Liberate computer use from programming – p.13/60
Liberate programming• Program development tools do not change the essence of
programming;
• People dream of making programming easier by liberating it fromvarious "straitjackets":
1. Backus [Bac78] liberates programming from Von Newmannstyle, thus developing functional style.
2. Harel [Har01, Har08] dreams of liberating programming,period.
3. Here I discuss another idea:liberate computer user from programming!
Liberate computer use from programming – p.14/60
Liberate computer user
Since one cannot change the essence ofprogramming, perhaps we can make it easier bybetter understanding computer-based problemsolving process.
• First I analyze the liberation of computer user from programmingusing the Harel’s dream [Har08] of programming liberation, period.
• Then I present a more realistic solutions consisting of two actions:
1. Computational emancipation of problem domain
2. Development of aplication driven software
Liberate computer use from programming – p.15/60
Programming straitjackets
Harel [Har08] identifies the three straitjacketsfrom which he wants to liberate programming:
1. the need to write down a program as a symbolic, textual, orgraphical artifact;
2. the need to specify requirements (the what) separately from theprogram (the how) and to oppose one against the other;
3. the need to structure behavior according to system’s structure,providing each piece or object with its full behavior.
Liberate computer use from programming – p.16/60
Relaxing the straitjackets
Steps taken by others to relax programmingstraitjackets:
(1) is relaxed by the research that decrease the effort involved inwriting relevant programs, such as query-by-example [Zlo77].
(2) is relaxed by special languages [Bac78, Apt96] as well as bythe research on generative (genetic) programming [Koz92, CE00]
(3) is relaxed by the research on aspect-orientation [AFEC04] thattries to ease the need to totally align behavior with structure.
Liberate computer use from programming – p.17/60
NoteThe steps taken to relax programmingstraitjackets do not change the essence ofprogramming:
by programming one still creates programs.
Liberate computer use from programming – p.18/60
Harel’s dreamis about “freeing ourselves from the straitjacketsof programming"
Question: who are the "ourselves" in Harel’sdream?
Answer: ourselves in Harel’s dream are all those
who develop computer programs. That is, Harel,
as I, talk about freeing the computer user from the
straitjackets of programming.
Liberate computer use from programming – p.19/60
Getting computers to work
Harel dreams of getting computers “to do whatwe want" intuitive, natural, and also fun.Harel’s disclaimer: no, I don’t have a solution . . . and I definitely havenoting that is magical. But the message here is definitely
“maybe we should be thinking about this something more".
Liberate computer use from programming – p.20/60
The Dream• Part 1: program development
play in the program• Part 2: program execution
play out the program
Liberate computer use from programming – p.21/60
Program development
The three main stages in program development:• Structured analysis and design (SAD)
• Object oriented analysis and design (OAD)
• Conceptual analysis and design (CAD)
Liberate computer use from programming – p.22/60
Modeling mechanism
The modeling mechanism used in the threestages for program development is provided bytransition systems, where:
• States are functions mapping variables to values(or assigning value to variables);
• Transitions are operators mapping functions into functions;
• Systems are operatorial expressions.
Note: somtimes this is done in the domain theory
Liberate computer use from programming – p.23/60
SADIn SAD structural models are based on functionaldecomposition and information flow, i.e.:
• States are functions mapping variables to values
• Operators are function compositions expressed by statements inprocedural languiages
• Systems are procedural programs expressed by hierarchicaldata-flow and control-flow diagrams.
Note: SAD does not change the essance of pro-
gramming.
Liberate computer use from programming – p.24/60
OADOAD raises concepts used in SAD to the level ofabstraction types by grouping data andoperations into types of behaviors called classes.
• States are objects obtaines as class-instantiations
• Operators are “object creation, destruction, and compositions".
• Systems are object-oriented programs expressed by UMLdiagrams.
Note: Programs are models of behaviors but OAD
does not change the essence of programming.
Liberate computer use from programming – p.25/60
CAD• CAD is based on specializing the concepts
used in OAD to the domain of application.• CAD behaviors express characteristic
concepts of the application domains.• The result of a CAD system is a
domain-knowlege, not a piece of data orbehavior.
Liberate computer use from programming – p.26/60
CAD modeling• States are knowledge expressed as tuple (term, implementation)
where term is a natural language expression of the domainconcept, and imnplementation is a computational object thatimplements the term.
• Opertators are reasoning mechanisms that generate domainknowledge from given domain knowledge.
• Systems are domain expressions representing new domainconcepts (obtained by reasoning) in terms of given domainconcepts
Note: CAD changes the essence of programming.
Liberate computer use from programming – p.27/60
ObservationsConceptual modeling is the oldest branch of reasoning by modeling(see Springer LNCS on Conceptual Modeling – ER). However:
• Conceptual models are static and represent IT concepts[REDF05].
That is : conceptual models are not problem domain models usedin computer-based problem solving process.
• Chen [Che06] suggests dynamic conceptual modeling; suchmodels may evolve as CEADed ontologies.
• Rolland [Rol06] relate dynamnic conceptual models to softwareengineering process (on step behind using conceptual modelingin domain-oriented computer-based problem-solving processw).
Liberate computer use from programming – p.28/60
Harel’s natural programmingOur daily instructions to people and tools concern:
• combinations of laying out general principles (acceptedconventions),
• showing or walking through examples of what we have in mind,
• prescribing rules and conditions for what can or must be doneversus what must not or cannot be done.
Note: the reliability of these “programs" rely on social laws that
constrain people to be “good citizens"
Could we program computers this way?
Liberate computer use from programming – p.29/60
Scientific support• Work on visual-formalisms for reactive system develpment
(statecharts, message sequence charts, live sequence charts)
• Succes of software tools based on visual approach and UML(statemat, rhapsody, rational rose)
• Trends of software development: Structural Analysis and Designs→ OO Analysis and Design → Conceptual Analysis and Design
• Computational emancipation of applicatiobn domain (CEAD) bycomputational thinking developed in IT.
Liberate computer use from programming – p.30/60
Example
To answer the question raised above Harel shows
us how to use natural programming to program a
mobile phone.
Liberate computer use from programming – p.31/60
Assumptions1. The phone consists of a display screen, standard keys, and
additional buttons.
2. The phone user knows “the basic separate capabilities of eachphone component". For example, when the user presses andreleases a given button the phone goes on and the display isilluminated.
3. But the phone was not yet endowed with a phone-like behavior;one can press the phone keys and nothing happens.
4. There are some magic fairies that allows us to “talk to the phone"!There are no fairies in Harel paper, they are the creation of Jacqueline and
Isabella (my grad-daughters); I adopted them here to help us talk to the phone.
Liberate computer use from programming – p.32/60
Natural phone programming
Hey phone, listen and do:1. Whenever I press the button b1 and hold it for 1 second you
should switch the phone one; if I press and hold the button b1 for 2seconds you switch the phone off. And the fairy behind b1 does it.
2. Don’t ever switch off if display shows that text is in progress. Andthe good fairy obey this rule too.
3. If I press and release a sequence of 12 standard keys followed bythe pressing and releasing of the button b2 you should connect tothe phone identified by the number I just dialed, if one exists!
4. And many other similar instructions.
Liberate computer use from programming – p.33/60
Is it feasible?• Harel discusses this example natural programming as a dream;
but he and his students have created the language live sequencecharts [DH01, HM03] and have really implemented this behavior.
• However, as other researchers who approached the problem of“programming liberation", the solution Harel offers just make theprogramming a more complicated business.
• So, can we really liberate computer user from programming?To answer this questions I will show how I and my students wouldnaturally program the phone using our approach of ComputationalEmancipation of the Application Domain (CEAD).
Liberate computer use from programming – p.34/60
Harel observations1. We talk to a computerized mock-up image of the phone.
2. Natural programming is about communicating (in a natural style)to a system that consists of multi-modal components (chunks ofbehavior). I call them characteristic components of the domain.
3. The "talking" to the phone is like a play-in action that manipulatecomputing objects;
4. Feasibility is illustrated by human-computer interaction such asMicrosoft tabletop computing systems [Wil].
Liberate computer use from programming – p.35/60
What about straitjackets?1. Play-in is carried out directly and visually and does not require the
programmer to prepare a complete artifact. However, programmer
manipulates prefabricated computing artifacts; but we don’t care of what artifacts a
fairy manipulates.
2. There is no need to separate specifications from operationaltasks; anything what is been played-in is legal.
3. Play-in is universal hence the programmer is free to specify anybehavior anyway anytime. Note that fairies are dedicated to the domain,
they only perform domain actions.
Liberate computer use from programming – p.36/60
Observations• Completeness: since the requirements are part of the program,
programming is always complete.
• Integration: since every action is complete there are no integrationconstraints. Hence, system change is direct.
• Inheritance: objects can be substitutes freely as long as behavior ispreserved.
In a nutshell: the programmer teaches and guides the computer to get
to “know" about the system’s intended behavior. We may easily fall into the
usual programming trap if we don’t use domain dedicated fairies
Liberate computer use from programming – p.37/60
Facts1. The play-in process is a language that expresses something that
the computer knows how to execute/run. Harel believes that “wecan harness the computer to do that". It is more natural to harness the
application domain.
2. Played-in behavior is subjected to the “on-the-fly processing" (byspeech and natural language recognition?), formalization, andlogical captures. This is obvious in our approach.
3. This process is somehow recorded and thus transformed into aformal artifact whose semantic captures “the properties of theallowed traces of system behavior". This is a domain-algorithm
associated with a new fairy and is recorded as a SADL process.
Liberate computer use from programming – p.38/60
Natural program execution1. Programmer (computer user) needs to get immediate feedback
about how the playing in has been rendered.
2. Programmer needs to observe both the generated formal versionof the played-in behavior as well as its immediate effect on theplayed interface.
3. At any point in the play-in programming process the programmercan ask to run the current version of the program. This wastermed play-out.
4. The programmer should be able to play-in with the play-out thusmaking changes in the formal rendition.
Liberate computer use from programming – p.39/60
How to implement it?
Play-out should be doable in interpreter mode
(direct-execution) or in compiler mode (synthesiz-
ing an executable).
Liberate computer use from programming – p.40/60
ConclusionWhen the programmer feels that the system hasreceived enough instructions and guidelines shelets it free to “start behaving". This belongs to the dream.
Note: with our approach the system is associated
with a name in the domain ontology and a fairy is
in charge of performing it. This is not a dream.
Liberate computer use from programming – p.41/60
Constraints1. Whatever programmer has told the system that it must do it will
indeed do.
2. Whatever programmer has told the system that is not allowed todo it will never do.
3. Whatever programmer has told the system that it might do (suchas nondeterministic or probabilistic choice among possibilities) thesystem will decide whether to do or not in the appropriate fashion.
Liberate computer use from programming – p.42/60
Book of rulesHumans cannot be expected to be pedantically obedient but computercan!
1. Humans have their “books" of rules containing all manner ofinstructions, regulations, guidelines, and laws relevant to theirexistence.
2. If humans chose to adopt the “good citizen stand" they carry-outthe behavior algorithm just as described: live anyway they choseas long as it is within the confines of the “books of rules".
Questions: can we reliably transfer this procedure to the formal realm of
computing? And if so, what kind of computational tools are required?
Liberate computer use from programming – p.43/60
Realizability
The generation of actual behaviors that areconsistent with a collection of play-in behaviorswas called realizability [Var06].Observations:
1. The realizability in general is difficult; however, realizability on agiven domain of behaviors is almost obvious!
2. Hence, one-size-fits-all pattern of current computer-basedproblem solving process need be changed.
Liberate computer use from programming – p.44/60
Rationale for realizability1. The components of a realizable behavior may be multimodal and
can contain constraints as well as operational instructions, andthus they may limit or even contradict each other.
2. Are there computational techniques to verify the consistency ofplay-in and play-out behaviors?
3. Such computations should be doable on the fly such that theprogrammer can be warned that a behavior being played-incontradicts what has already programmed.
Liberate computer use from programming – p.45/60
Neuroscience• Harel believes that realizable computational techniques can be
developed within the framework of temporal logic [MP92];
• I think that the natural realizable computational techniques can bethe result of Neuroscience [KSJ00, PAF+07].
• But note, domain-dedicated realizable computational techniquesare at hand today.
Liberate computer use from programming – p.46/60
Feasibility• Harel model: scenario based programming [DH01, HM03].
This model support the natural programming as dreamed about but it complicates
programming and is not feasible with the current computation techniques.
• Computational Emancipation of Application Domains, (CEAD)[RC06, RC07] is an achievable model of natural programming:1. it requires domain-dedicated software tool development (well-understood).
2. it is feasible with the current computation techniques (semantic-web).
3. it moves computer-based problem-solving process in the application domain.
Liberate computer use from programming – p.47/60
Domain driven softwareOur approach for liberating computer user fromprogramming moves problem solving processfrom computer environment into problem domainenvironment and consists of:
1. Structure application domains using appropriate ontologies
2. Develop problem solving algorithms (not programs) in terms ofdomain characteristic abstractions
3. Execute algorithms (not programs) directly by domain-dedicatedsoftware
Liberate computer use from programming – p.48/60
Making the dream feasible
1. Chunks of behavior: domain characteristicabstractions (universal, stand alone, composable).
2. Computerized mock-up: a knowledgerepresentation network (use description logic).
3. Play-in: problem-solving activity in terms ofdomain concepts
4. Play-out: computations performed by a virtualmachine executing domain abstraction.
Liberate computer use from programming – p.49/60
Implementing the dream
By Computational Emancipation of ApplicationDomain (CEAD):
1. Identify problem-domain characteristic abstractions
2. Organize domain abstraction into a domain ontology
3. Associate concepts in the ontology with URI-s of computerartifacts implementing them
4. Design and implement the domain-dedicated virtual-achine
Liberate computer use from programming – p.50/60
A phone ontologyWe first identify the problem domain, the phone business domain
(PBD) and structure it in terms of main-concepts as seen in Figure 1.PBD
���
���������9@
@@R
XXXXXXXXXz
screenDisplay
keysStandard
���� ��HHHj
k1 k2 . . . kn
buttonsAdditional
���� ��HHHj
b1 b2 . . . bm
actionsMain
���� ��HHHj
a1 a2 . . . ak
Figure 1: Phone domain representation
Liberate computer use from programming – p.51/60
CEAD-ing the phoneSecondly, we will use our fairies to computationally emancipate the
PBD by associating each concept in phone ontology with a fairy that
allow us to talk to it, Figure 2.Phone
���
���������9@
@@R
XXXXXXXXXz
screenDisplay
DF
keysStandard
���� ��HHHj
k1 k2 . . . kn
Fk1Fk2
. . . Fkn
buttonsAdditional
���� ��HHHj
b1 b2 . . . bm
Fb1Fb2. . . Fbn
actionsMain
���� ��HHHj
a1 a2 . . . ak
Fa1Fa2
. . . Fan
Figure 2: Phone domain computationally emancipatedLiberate computer use from programming – p.52/60
Phone programmingDefine new actions in terms of the actions already defined on Figure 2and evolve PBD by adding the new actions to the domainrepresentation.
Example new actions:
• Calling a number: a1; ki1 , ki2 , . . . , ki12 ; a2;
• Sending a text: a1, a3; ki1 , ki2 , . . . , kit; a2;
Note: here the fairy associated with the button a3 make thestandard key selection represent letters rather than numbers;
• Phone user is free to define, add, remove actions as she pleases
Liberate computer use from programming – p.53/60
Implementation1. Walk the phone ontology and associate each fairy with the URI of
a computer artifact that implements its behavior.
2. Associate the phone ontology with a virtual computer that performthe loop:
CurrentURI = StartingFairy;
while (CurrentURI.action is not halt)
Execute(CurrentURI.action);
CurrentURI := Next(CurrentURI);
3. CurrentURI is associated with the fairy responsible with theuser-phone communication
Liberate computer use from programming – p.54/60
Another exampleA mathematician wants to use natural programming to program hercomputer to do signal processing using Discrete Fourier Transform.
Assumptions:
1. The mathematician employs complex algebra, matrix algebra, andFourier Transforms.
2. The mathematician knows how to sample discrete signals.
3. The mathematician has fairies that perform complex operations,matrix operations.
4. The mathematician has a fairy that can generate the FourierMatrix that corresponds to a signal sample.
Liberate computer use from programming – p.55/60
Frequency samplingUsing natural programming the mathematician constructs the programthat compute Frequency Sampling as shown in Figure 3.
Discrete Fourier Transform�������) ?
PPPPPPPqComplex algebra Signal processing Matrix algebra
�������)
PPPPPPPqSignal sampling
?
Frequency computation������
HHHHHjsig:vector(a1, . . . , an)
Fourier matrix:FM(sig)
Frequency sampling:
FS = FM(sig)× sigT
Figure 3: Discrete Fourier TransformLiberate computer use from programming – p.56/60
Fourier matrix• Let sig = (a0, a1, . . . , an−1) be a signal sample.
• The discrete spectrum of frequencies of sig is a vectorν(sig) = (b0, b1, . . . , bn−1) whose components are computed bythe formula: bj =
∑n−1k=0 ak ∗ ei2π/n∗j∗k, j = 0, 1, . . . , n − 1.
• Fourier matrix of sig, FM(sig, n) is:
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
ei2π/n∗0∗0 ei2π/n∗0∗1 ei2π/n∗0∗2 . . . ei2π/n∗0∗n−1
ei2π/n∗1∗0 ei2π/n∗1∗1 ei2π/n∗1∗2 . . . ei2π/n∗1∗n−1
ei2π/n∗2∗0 ei2π/n∗2∗1 ei2π/n∗2∗2 . . . ei2π/n∗2∗n−1
. . . . . . . . . . . . . . .
ei2π/n∗(n−1)∗0 ei2π/n∗(n−1)∗1 ei2π/n∗(n−1)∗2 . . . ei2π/n∗(n−1)2
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
˛
Liberate computer use from programming – p.57/60
NotationsOne can simplify the Fourier matrix FM(sig, n) by the notation:w(n) = ei2π/n = cos(2π/n) + i sin(2π/n) and w(n)n = 1
Note: the elements of FM are powers of w(n) and thus we have:
FM(sig, n) =
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
1 1 1 . . . 1
1 w(n) w(n)2 . . . w(n)n−1
1 w(n)2 w(n)4 . . . w(n)2(n−1)
. . . . . . . . . . . . . . .
1 w(n)n−1 w(n)2(n−1) . . . w(n)(n−1)2
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
∣
Liberate computer use from programming – p.58/60
Fourier Transforms• The Discrete Fourier Transform (DFT) is the algorithm that
computes ν(sig) using the scalar productν(sig) = FM(sig, n) × sigT . Hence, the mathematician programshis machine by writing (or telling):
F1: let Sig=(a_1,a_2,...,a_n);
generate FM(n);
transpose Sig to SigT;
compute Fq(Sig) = FM X SigT
• Fast Fourier Transform [CT65] uses properties of FM to reducethe complexity of ν(sig) from O(n2) to O(n logn).
Liberate computer use from programming – p.59/60
Bibliography
References
[AFEC04] M. Aksit, R.E. Filman, T. Elard, and S. Clarke. AspectOriented Software Development. Addison-Wesley, 2004.
[Apt96] K. Apt. From Logic Programming to PROLOG. PrenticeHall, 1996.
[Bac78] J. Backus. Can programming be liberated from the vonnewmann style? a functional style and its algebra ofprograms. Comm. ACM, 21(8):613–641, 1978.
[CE00] K. Czarnecki and U. Eisenecker. Generative Programming:Methods, Tools, and Application. Addison-Wesley, 2000.
[Che06] P.P. Chen. Suggested research directions for a new frontier– active conceptual modeling. In Conceptual Modeling - ER,
Liberate computer use from programming – p.60/60