Making Programming Easier by Making it More Natural
Making Programming Easier by Making it More Natural Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University http: //www. cs. cmu. edu/~bam bam@cs. cmu. edu 1
The User Interface of Programming Languages n n n Programming is a human activity Want to improve the ability of people to program It makes sense to look at the human side Brad Myers CMU - HCI Institute 2
Who are the Authors? • Not just professional programmers – Many languages aimed at “part-time” or novice programmers • End User Programming! Brad Myers CMU - HCI Institute 3
Why EUP? n By 2005, 55 million end-user programmers n n n 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 n Errors in spreadsheets and other end-user-created software costs companies millions of dollars Brad Myers CMU - HCI Institute 4
Design of New Languages n How make design decisions? n n n Designer’s intuition Similarity to other languages n But many have known problems Key concept: n If you care about usability and learnability: Can leverage off of what is known and what can be learned about people to guide design decisions Brad Myers CMU - HCI Institute 5
“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. ” — Allen Newell and Stuart Card, 1985 Brad Myers CMU - HCI Institute 6
Examples of Problems The men and women here raise your hands! if is_man(x) and is_woman(x) then raise_hand(x); n This issue with “and” applies to other natural languages as well. Find a paint that is not red or orange ( ) not paint. color == red or paint. color == orange not (paint. color == red or paint. color == orange) n Research shows that these differences between natural languages and computer languages hurt understanding Brad Myers CMU - HCI Institute 7
Why Study This? n There are many known problems n n n Little knowledge to guide designs The language which is currently popular seems to have about a 7 to 12 year window n n n Fortran, PL/1, Pascal, C, C++, Java, (maybe C# ? ) … So new languages are always being created We may influence design by identifying problems n n Programming is still hard to learn and hard to do Java / C# took some into account We certainly won't if we don't try, or if we don't know what to say! Brad Myers CMU - HCI Institute 8
Gentle Slope Systems Programming in C++ Visual Basic Lab. View MFC C Programming Difficulty of Use st a c e Stag or t Crea C Programming Basic Goal Program Complexity and Sophistication 9
What we are doing. . . Studying the People 10
Natural Programming Research n Try to provide a more scientific basis for programming language design n Apply results of Empirical Studies of Programmers and Human-Computer Interaction to programming language design n New studies to fill in gaps n Design new programming languages and environments based on these results Brad Myers CMU - HCI Institute 11
Why Would Being Natural be Good? n Language should be close to user’s plan n n “Programming is the process of transforming a mental plan into one that is compatible with the computer. ” — Jean-Michel Hoc Example: n Inserting item into 3 rd place of high score list n Easy by Direct Manipulation (in a spreadsheet) n Difficult to program: n Loop, starting at end of array, shuffle items down, then insert Brad Myers CMU - HCI Institute 12
Why Would Being Natural be Good? #2 n Directness (as in “Direct Manipulation”) n “Distance between one's goals and the actions required by the system to achieve those goals. ” — Hutchins, Hollan and Norman n Example: vs. Let Shape 1. Fill. Color = &H 00 FF& Brad Myers CMU - HCI Institute 13
Background Research n Empirical Studies of Programmers and HCI results not being used in the design of new languages n n n 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 Myers CMU - HCI Institute 15
Our Research n n n Lots of gaps in prior research on people and programming Develop knowledge that can be used in design Ph. D. thesis of John Pane n Available at: http: //www-2. cs. cmu. edu/~pane/thesis/ Brad Myers CMU - HCI Institute 16
Natural Programming Studies n How people naturally express programming concepts and algorithms 1) Nine scenes from Pac. Man 2) Transforming and calculating data in a spreadsheet n Specific issues of language design 3) Selecting specific objects from a group (“and”, “or”, “not”) Brad Myers CMU - HCI Institute 17
Experimental Design n Question should not bias the answer So use pictures instead of textual descriptions Concentrate on kids, non-programmers n n Subjects should not be “tainted” by programming knowledge But test that the results generalize to adults and programmers Brad Myers CMU - HCI Institute 18
Study 1 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. 19
Second Study n n Whether similar results from other domains and with adults Developed 11 questions with scenarios using spreadsheets n n To test database access and operations More conventionally “computational” Brad Myers CMU - HCI Institute 20
Example Question, 2 nd Study Question 4 • Describe in detailed steps what the computer should do to categorize these people into 2 groups of ‘Gold’ and ‘Black’. First name 1 Sandra 2 Bill 3 Cindy 4 Tom 5 Bill 6 Whitney 7 Michael 8 Jay 9 David 10 Will No. Last name Bullock Clinton Crawford Cruise Gates Houston Jordan Leno Letterman Smith Group Brad Myers CMU - HCI Institute First name 1 Sandra 2 Bill 3 Cindy 4 Tom 5 Bill 6 Whitney 7 Michael 8 Jay 9 David 10 Will No. Last name Bullock Clinton Crawford Cruise Gates Houston Jordan Leno Letterman Smith Group Gold Black Gold 21
Results n Rule-based style “If Pac. Man loses all his lives, its game over. ” n n 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 Brad Myers CMU - HCI Institute 22
More Results n Most arithmetic used natural language style “When Pac. Man eats a big dot, the score goes up 100. ” n Operations suggest data as lists, not arrays n n Objects normally moving “If Pac. Man hits a wall, he stops. ” n n People don’t make space before inserting so objects remember their own state 2/3 of the first study subjects drew pictures n Usually to define the initial state Brad Myers CMU - HCI Institute 23
Implications for New Languages n n n 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 Myers CMU - HCI Institute 29
New Language and System: HANDS n Video Brad Myers CMU - HCI Institute 30
Conclusions n Can evaluate languages as to extent they are “natural” n n Can use this technique to answer questions for language designs n n Based on consistency, learnability, etc. 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 Myers CMU - HCI Institute 31
Credits Support for this research has come in part from the National Science Foundation under Grant No. IRI-9900452 and Grant No. IIS-9817527 For more information, see: http: //www. cs. cmu. edu/~Nat. Prog Brad Myers CMU - HCI Institute 32
Making Programming Easier by Making it More Natural Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University http: //www. cs. cmu. edu/~bam bam@cs. cmu. edu 33
- Slides: 27