Upload
rodney-garrison
View
220
Download
2
Embed Size (px)
Citation preview
1
Making Programming Easier by Making it More NaturalMaking Programming Easier by Making it More Natural
Brad A. MyersBrad A. MyersHuman-Computer Interaction InstituteHuman-Computer Interaction InstituteSchool of Computer ScienceSchool of Computer ScienceCarnegie Mellon UniversityCarnegie Mellon University
http://www.cs.cmu.edu/~bamhttp://www.cs.cmu.edu/[email protected]@cs.cmu.edu
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 2
The User Interface of Programming Languages
Programming is a human activity Want to improve the ability of people to program It makes sense to look at the human side
Programming is a human activity Want to improve the ability of people to program It makes sense to look at the human side
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 3
Who are the Authors?
• Not just professional programmers– Many languages aimed at
“part-time” or novice programmers
• Not just professional programmers– Many languages aimed at
“part-time” or novice programmers
• End User Programming!• End User Programming!
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 4
Why EUP?
By 2005, 55 million end-user programmers Compared to only 2.75 million professional programmers Use spreadsheets, CAD systems, special-purpose
scripting and visual languages, etc.
These languages are unnecessarily hard to use and prone to errors Errors in spreadsheets and other end-user-created
software costs companies millions of dollars
By 2005, 55 million end-user programmers Compared to only 2.75 million professional programmers Use spreadsheets, CAD systems, special-purpose
scripting and visual languages, etc.
These languages are unnecessarily hard to use and prone to errors Errors in spreadsheets and other end-user-created
software costs companies millions of dollars
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 5
Design of New Languages
How make design decisions? Designer’s intuition Similarity to other languages
But many have known problems
Key concept: If you care about usability and learnability:
Can leverage off of what is known andwhat can be learned about people
to guide design decisions
How make design decisions? Designer’s intuition Similarity to other languages
But many have known problems
Key concept: If you care about usability and learnability:
Can leverage off of what is known andwhat can be learned about people
to guide design decisions
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 6
— Allen Newell and Stuart Card, 1985— Allen Newell and Stuart Card, 1985
“Millions for compilers but hardly a penny for understanding human programming language use. Now, programming languages are obviously symmetrical, the computer on one side, the programmer on the other. In an appropriate science of computer languages, one would expect that half the effort would be on the computer side, understanding how to translate the languages into executable form, and half on the human side, understanding how to design languages that are easy or productive to use.... The human and computer parts of programming languages have developed in radical asymmetry.”
“Millions for compilers but hardly a penny for understanding human programming language use. Now, programming languages are obviously symmetrical, the computer on one side, the programmer on the other. In an appropriate science of computer languages, one would expect that half the effort would be on the computer side, understanding how to translate the languages into executable form, and half on the human side, understanding how to design languages that are easy or productive to use.... The human and computer parts of programming languages have developed in radical asymmetry.”
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 7
( )not (paint.color == red or paint.color == orange) Research shows that these differences between
natural languages and computer languages hurt understanding
( )not (paint.color == red or paint.color == orange) Research shows that these differences between
natural languages and computer languages hurt understanding
Examples of Problems
if is_man(x) and is_woman(x) then raise_hand(x); This issue with “and” applies to other natural
languages as well.
if is_man(x) and is_woman(x) then raise_hand(x); This issue with “and” applies to other natural
languages as well.
The men and women here raise your hands!The men and women here raise your hands!
Find a paint that is not red or orangeFind a paint that is not red or orange not paint.color == red or paint.color == orange not paint.color == red or paint.color == orange
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 8
Why Study This? There are many known problems
Programming is still hard to learn and hard to do
Little knowledge to guide designs The language which is currently popular seems to
have about a 7 to 12 year window Fortran, PL/1, Pascal, C, C++, Java, (maybe C# ?) … So new languages are always being created
We may influence design by identifying problems Java / C# took some into account
We certainly won't if we don't try, or if we don't know what to say!
There are many known problems Programming is still hard to learn and hard to do
Little knowledge to guide designs The language which is currently popular seems to
have about a 7 to 12 year window Fortran, PL/1, Pascal, C, C++, Java, (maybe C# ?) … So new languages are always being created
We may influence design by identifying problems Java / C# took some into account
We certainly won't if we don't try, or if we don't know what to say!
Gentle Slope Systems
Difficultyof
Use
Goal
Programming in C++
MFC
Program Complexity and Sophistication
C Programming
LabView
Stagecast
Creator
Visual Basic
Basic
C Programming
What we are doing...
Studying the People
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 11
Natural Programming Research
Try to provide a more scientific basis for programming language design
Apply results of Empirical Studies of Programmers and Human-Computer Interaction to programming language design
New studies to fill in gaps
Design new programming languages and environments based on these results
Try to provide a more scientific basis for programming language design
Apply results of Empirical Studies of Programmers and Human-Computer Interaction to programming language design
New studies to fill in gaps
Design new programming languages and environments based on these results
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 12
Why Would Being Natural be Good?
Language should be close to user’s plan “Programming is the process of transforming a mental
plan into one that is compatible with the computer.” — Jean-Michel Hoc
Language should be close to user’s plan “Programming is the process of transforming a mental
plan into one that is compatible with the computer.” — Jean-Michel Hoc
Example: Inserting item into 3rd place of high score list
Easy by Direct Manipulation (in a spreadsheet) Difficult to program:
Loop, starting at end of array, shuffle items down, then insert
Example: Inserting item into 3rd place of high score list
Easy by Direct Manipulation (in a spreadsheet) Difficult to program:
Loop, starting at end of array, shuffle items down, then insert
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 13
Why Would Being Natural be Good? #2
Directness (as in “Direct Manipulation”) “Distance between one's goals and the actions required
by the system to achieve those goals.”— Hutchins, Hollan and Norman
Directness (as in “Direct Manipulation”) “Distance between one's goals and the actions required
by the system to achieve those goals.”— Hutchins, Hollan and Norman
Example: Example:
vs.
Let Shape1.FillColor = &H00FF00FF&
vs.
Let Shape1.FillColor = &H00FF00FF&
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 15
Background Research
Empirical Studies of Programmers and HCI results not being used in the design of new languages 30 years of research on what makes languages hard to
learn and error-prone Java / C# looping, etc.
Summarized in our comprehensive tech report— John Pane and Brad Myers, “Usability Issues in the Design of
Novice Programming Systems” TR# CMU-CS-96-132. Aug, 1996.http://www.cs.cmu.edu/~pane/cmu-cs-96-132.html
Empirical Studies of Programmers and HCI results not being used in the design of new languages 30 years of research on what makes languages hard to
learn and error-prone Java / C# looping, etc.
Summarized in our comprehensive tech report— John Pane and Brad Myers, “Usability Issues in the Design of
Novice Programming Systems” TR# CMU-CS-96-132. Aug, 1996.http://www.cs.cmu.edu/~pane/cmu-cs-96-132.html
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 16
Our Research
Lots of gaps in prior research on people and programming
Develop knowledge that can be used in design Ph.D. thesis of John Pane
Available at:
http://www-2.cs.cmu.edu/~pane/thesis/
Lots of gaps in prior research on people and programming
Develop knowledge that can be used in design Ph.D. thesis of John Pane
Available at:
http://www-2.cs.cmu.edu/~pane/thesis/
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 17
Natural Programming Studies
How people naturally express programming concepts and algorithms1) Nine scenes from PacMan
2) Transforming and calculating data in a spreadsheet
Specific issues of language design3) Selecting specific objects from a group (“and”, “or”, “not”)
How people naturally express programming concepts and algorithms1) Nine scenes from PacMan
2) Transforming and calculating data in a spreadsheet
Specific issues of language design3) Selecting specific objects from a group (“and”, “or”, “not”)
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 18
Experimental Design
Question should not bias the answer So use pictures instead of textual descriptions Concentrate on kids, non-programmers
Subjects should not be “tainted” by programming knowledge
But test that the results generalize to adults and programmers
Question should not bias the answer So use pictures instead of textual descriptions Concentrate on kids, non-programmers
Subjects should not be “tainted” by programming knowledge
But test that the results generalize to adults and programmers
Usually Pacman moves like this.
Now let's say we add a wall.
Pacman moves like this.
Not like this.
Usually Pacman moves like this.
Now let's say we add a wall.
Pacman moves like this.
Not like this.
Do this: Write a statement that summarizes how I (as the computer) should move Pacman in relation to the presence or absence of other things.
Study 1
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 20
Second Study
Whether similar results from other domains and with adults
Developed 11 questions with scenarios using spreadsheets To test database access and operations More conventionally “computational”
Whether similar results from other domains and with adults
Developed 11 questions with scenarios using spreadsheets To test database access and operations More conventionally “computational”
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 21
Example Question, 2nd Study
No.
Firstname
Lastname
Group
1 Sandra Bullock 2 Bill Clinton 3 Cindy Crawford 4 Tom Cruise 5 Bill Gates 6 Whitney Houston 7 Michael Jordan 8 Jay Leno 9 David Letterman 10 Will Smith
Question 4• Describe in detailed steps what the computer should do to
categorize these people into 2 groups of ‘Gold’ and ‘Black’.
No.
Group
1 Sandra Bullock Gold 2 Bill Clinton Gold 3 Cindy Crawford Gold 4 Tom Cruise Gold 5 Bill Gates Black 6 Whitney Houston Gold 7 Michael Jordan Gold 8 Jay Leno Black 9 David Letterman Black 10 Will Smith Gold
Firstname
Lastname
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 22
Results
Rule-based style“If PacMan loses all his lives, its game over.”
Some use of Constraint style: “Pacman cannot go through a wall.”
Rule-based style“If PacMan loses all his lives, its game over.”
Some use of Constraint style: “Pacman cannot go through a wall.”
Set operations instead of iterations“Subtract 20,000 from all elements in Round 2”
— These tend to eliminate control structures
Set operations instead of iterations“Subtract 20,000 from all elements in Round 2”
— These tend to eliminate control structures
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 23
More Results
Most arithmetic used natural language style“When PacMan eats a big dot, the score goes up 100.”
Most arithmetic used natural language style“When PacMan eats a big dot, the score goes up 100.”
Operations suggest data as lists, not arrays People don’t make space before inserting
Objects normally moving“If PacMan hits a wall, he stops.”
so objects remember their own state
2/3 of the first study subjects drew pictures Usually to define the initial state
Operations suggest data as lists, not arrays People don’t make space before inserting
Objects normally moving“If PacMan hits a wall, he stops.”
so objects remember their own state
2/3 of the first study subjects drew pictures Usually to define the initial state
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 29
Implications for New Languages Use event-based style for dynamic events Provide operations on groups of objects Work to minimize the need for control structures
and variables Data structures that combine the capabilities of
lists + arrays + sets Support simple arithmetic in natural language
style (“add 1 to score”) Using mathematical notation such as > <
rather than words achieves better accuracy
Use event-based style for dynamic events Provide operations on groups of objects Work to minimize the need for control structures
and variables Data structures that combine the capabilities of
lists + arrays + sets Support simple arithmetic in natural language
style (“add 1 to score”) Using mathematical notation such as > <
rather than words achieves better accuracy
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 30
New Language and System: HANDS
Video
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 31
Conclusions
Can evaluate languages as to extent theyare “natural” Based on consistency, learnability, etc.
Can use this technique to answer questions for language designs Instead of just using the designer’s intuition Hopefully our data can help
Languages can be evaluated just like any other user interface using HCI principles and techniques
If you want a useable and learnable programming language, there are data and techniques that can help
Can evaluate languages as to extent theyare “natural” Based on consistency, learnability, etc.
Can use this technique to answer questions for language designs Instead of just using the designer’s intuition Hopefully our data can help
Languages can be evaluated just like any other user interface using HCI principles and techniques
If you want a useable and learnable programming language, there are data and techniques that can help
Brad MyersBrad MyersCMU - HCI InstituteCMU - HCI Institute 32
Credits
Support for this research has come in part from the National Science Foundation under
Grant No. IRI-9900452
andGrant No. IIS-9817527
For more information, see:
http://www.cs.cmu.edu/~NatProg
Support for this research has come in part from the National Science Foundation under
Grant No. IRI-9900452
andGrant No. IIS-9817527
For more information, see:
http://www.cs.cmu.edu/~NatProg
33
Making Programming Easier by Making it More NaturalMaking Programming Easier by Making it More Natural
Brad A. MyersBrad A. MyersHuman-Computer Interaction InstituteHuman-Computer Interaction InstituteSchool of Computer ScienceSchool of Computer ScienceCarnegie Mellon UniversityCarnegie Mellon University
http://www.cs.cmu.edu/~bamhttp://www.cs.cmu.edu/[email protected]@cs.cmu.edu