280 likes | 444 Views
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. The User Interface of Programming Languages. Programming is a human activity
E N D
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
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
Not just professional programmers • Many languages aimed at“part-time” or novice programmers Who are the Authors? • End User Programming!
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
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 peopleto guide design decisions
“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
Find a paint that is not red or orange Examples of Problems The men and women here raise your hands! if is_man(x) and is_woman(x) then raise_hand(x); • This issue with “and” applies to other natural languages as well. () 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
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 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!
Visual Basic LabView C Programming C Programming StagecastCreator Basic Gentle Slope Systems Programming in C++ MFC DifficultyofUse Goal Program Complexity and Sophistication
What we are doing... Studying the People
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
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 • 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: 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 vs. Let Shape1.FillColor = &H00FF00FF&
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
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/
Natural Programming Studies • How people naturally express programming concepts and algorithms 1) Nine scenes from PacMan 2) Transforming and calculating data in a spreadsheet • Specific issues of language design 3) Selecting specific objects from a group (“and”, “or”, “not”)
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
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.
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”
Example Question, 2nd Study Question 4 • Describe in detailed steps what the computer should do tocategorize these people into 2 groups of ‘Gold’ and ‘Black’. Firstname Lastname Firstname Lastname No. Group No. Group 1 Sandra Bullock 1 Sandra Bullock Gold 2 Bill Clinton 2 Bill Clinton Gold 3 Cindy Crawford 3 Cindy Crawford Gold 4 Tom Cruise 4 Tom Cruise Gold 5 Bill Gates 5 Bill Gates Black 6 Whitney Houston 6 Whitney Houston Gold 7 Michael Jordan 7 Michael Jordan Gold 8 Jay Leno 8 Jay Leno Black 9 David Letterman 9 David Letterman Black 10 Will Smith 10 Will Smith Gold
Results • 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
More Results • 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
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 oflists + arrays + sets • Support simple arithmetic in natural language style (“add 1 to score”) • Using mathematical notation such as > < rather than words achieves better accuracy
New Language and System: HANDS • Video
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
Credits Support for this research has come in part from the National Science Foundation underGrant No. IRI-9900452 and Grant No. IIS-9817527 For more information, see: http://www.cs.cmu.edu/~NatProg
Talk Given Using • Slide Show Commander • Developed as part of thePebbles Projecthttp://www.cs.cmu.edu/~pebbles • Available commercially http://www.slideshowcommander.com/
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 Thank you!