1 Towards More Natural Functional Programming Languages Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University.

Slides:



Advertisements
Similar presentations
Software Development Languages and Environments. Programming languages High level languages are problem orientated contain many English words are easier.
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
Project Proposal.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
Games and Simulations O-O Programming in Java The Walker School
Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
Ch 11 Cognitive Walkthroughs and Heuristic Evaluation Yonglei Tao School of Computing and Info Systems GVSU.
1 CS 106, Winter 2009 Class 5, Section 4 Slides by: Dr. Cynthia A. Brown, Instructor section 4: Dr. Herbert G. Mayer,
Design Activities in Usability Engineering laura leventhal and julie barnes.
1 Studying Development and Debugging To Help Create a Better Programming Environment Brad A. Myers and Andrew Ko Human-Computer Interaction Institute School.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
XP 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial 10.
C++ for Engineers and Scientists Third Edition
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 2: Algorithm Discovery and Design
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
Object Oriented Software Development
1 Making Programming Easier by Making it More Natural Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Carolyn Seaman University of Maryland, Baltimore County.
1 Shawlands Academy Higher Computing Software Development Unit.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
UNDERSTANDING USERS: MODELING TASKS AND LOW- LEVEL INTERACTION Human-Computer Interaction
1 Human-Computer Interaction  Design process  Task and User Characteristics  Guidelines  Evaluation.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
CS 4720 Usability and Accessibility CS 4720 – Web & Mobile Systems.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Object-Oriented Software Engineering Practical Software Development using UML and Java Chapter 7: Focusing on Users and Their Tasks.
Abstraction IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, September 17, 2013 Marie desJardins University of Maryland, Baltimore County.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Heuristic evaluation Functionality: Visual Design: Efficiency:
Input, Output, and Processing
CSC 395 – Software Engineering Lecture 13: Object-Oriented Analysis –or– Let the Pain Begin (At Least I’m Honest!)
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Design Rules-Part B Standards and Guidelines
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
CPS120: Introduction to Computer Science Decision Making in Programs.
Current Assignments Homework 2 is available and is due in three days (June 19th). Project 1 due in 6 days (June 23 rd ) Write a binomial root solver using.
Usability 1 Usability evaluation Without users - analytical techniques With users - survey and observational techniques.
The Software Development Process
User Interface Evaluation Cognitive Walkthrough Lecture #16.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Intermediate 2 Computing Unit 2 - Software Development.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington Java Programs COMP 102 #3.
CPS120: Introduction to Computer Science Variables and Constants.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Introduction CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Human-Computer Interaction Design process Task and User Characteristics Guidelines Evaluation ISE
Controlling Program Flow with Decision Structures.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
© Peter Andreae Java Programs COMP 102 # T1 Peter Andreae Computer Science Victoria University of Wellington.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Algorithms and Flowcharts
Computer Programming.
Chap. 6 :: Control Flow Michael L. Scott.
Phil Tayco Slide version 1.0 Created Oct 2, 2017
Chap. 6 :: Control Flow Michael L. Scott.
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Presentation transcript:

1 Towards More Natural Functional Programming Languages Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University

2 The User Interface of Programming Languages n Programming is a human activity n Want to improve the ability of people to program n It makes sense to look at the human side n Programming is a human activity n Want to improve the ability of people to program n It makes sense to look at the human side

3 — 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.”

4 What is “Usability”? n Usability = “The effectiveness, efficiency, and satisfaction with which users can achieve tasks in a particular environment of a product.” n Components: n Learnability: Easy to learn so users can get started rapidly. n Effectiveness: Experts can use it effectively and with high productivity. n Low Error rate: Users make few errors. n Satisfaction: Pleasant to use. No frustrations for users.  Similar to motivations for functional languages n Usability = “The effectiveness, efficiency, and satisfaction with which users can achieve tasks in a particular environment of a product.” n Components: n Learnability: Easy to learn so users can get started rapidly. n Effectiveness: Experts can use it effectively and with high productivity. n Low Error rate: Users make few errors. n Satisfaction: Pleasant to use. No frustrations for users.  Similar to motivations for functional languages

5 Why Human Computer Interaction? n The field of Human Computer Interaction studies how to improve and evaluate usability n Data, knowledge that can guide designs n To make systems more usable n Techniques for evaluating usability n So claims can be substantiated n So improvements can be made n The field of Human Computer Interaction studies how to improve and evaluate usability n Data, knowledge that can guide designs n To make systems more usable n Techniques for evaluating usability n So claims can be substantiated n So improvements can be made

6 Who are the Programmers? Not just professional programmers anymore n By 2005, 55 million end-user programmers n Compared to only 2.75 million professional programmers Not just professional programmers anymore n By 2005, 55 million end-user programmers n Compared to only 2.75 million professional programmers

7 Design of New Languages n How make design decisions? n Based on math, logic, type theory n Designer’s intuition or sense of aesthetics n Similarity to other languages n But many have known problems n Key concept: n If you care about usability: Can leverage off of what is known and what can be learned about people to guide design decisions n How make design decisions? n Based on math, logic, type theory n Designer’s intuition or sense of aesthetics n Similarity to other languages n But many have known problems n Key concept: n If you care about usability: Can leverage off of what is known and what can be learned about people to guide design decisions

8 What we are doing... Studying the People

9 if ((isMan x) && (isWoman x)) then (raise_hands x) else () ( ) n Research shows that these differences between natural languages and computer languages hurt understanding Examples of Problems The men and women here raise your hands! Buy a paint that is not red or blue if (( not isRed || isBlue ) x) then buy x else () ( ) n (This issue with “and” applies to other natural languages as well.)

10 My Research Goals n Make programming significantly easier to learn and more effective for non-professional programmers and beginners n Try to provide a more objective basis for usability decisions for programming language design n Apply results of Empirical Studies of Programmers, Psychology of Programming, and Human-Computer Interaction to programming language design n New studies n Design new programming languages and environments based on these results n Make programming significantly easier to learn and more effective for non-professional programmers and beginners n Try to provide a more objective basis for usability decisions for programming language design n Apply results of Empirical Studies of Programmers, Psychology of Programming, and Human-Computer Interaction to programming language design n New studies n Design new programming languages and environments based on these results

11 Multiple Criteria n Focusing on learnability and naturalness for beginners n Less emphasis: n Scalability n Provability n Efficiency n Mathematical or Logic properties n Similarity to other familiar languages n etc. n Focusing on learnability and naturalness for beginners n Less emphasis: n Scalability n Provability n Efficiency n Mathematical or Logic properties n Similarity to other familiar languages n etc.

Gentle Slope Systems Difficulty of Use Program Complexity and Sophistication

Gentle Slope Systems Difficulty of Use Programming in C++ MFC Program Complexity and Sophistication

Gentle Slope Systems Difficulty of Use Programming in C++ MFC Program Complexity and Sophistication Functional Languages? UI libraries

Gentle Slope Systems Difficulty of Use Programming in C++ MFC Program Complexity and Sophistication Functional Languages? UI libraries Visual Basic Basic C++ Programming

Gentle Slope Systems Difficulty of Use Programming in C++ MFC Program Complexity and Sophistication Functional Languages? UI libraries Visual Basic Basic C Programming My Goal

17 What is “Natural Programming”? n Attempt to make programming closer to the way people think n Make programming “more natural” n First, have to find out how people think about algorithms, data structures, etc. n Note: Not “natural language” n Still creating a formal language n Attempt to make programming closer to the way people think n Make programming “more natural” n First, have to find out how people think about algorithms, data structures, etc. n Note: Not “natural language” n Still creating a formal language

18 Why Might Being Natural be Good? n “Programming is the process of transforming a mental plan into one that is compatible with the computer.” — Jean-Michel Hoc n So process might be easier if transformation is smaller n Closeness of mapping n "The closer the programming world is to the problem world, the easier the problem-solving ought to be.… Conventional textual languages are a long way from that goal." — Green and Petre n “Programming is the process of transforming a mental plan into one that is compatible with the computer.” — Jean-Michel Hoc n So process might be easier if transformation is smaller n Closeness of mapping n "The closer the programming world is to the problem world, the easier the problem-solving ought to be.… Conventional textual languages are a long way from that goal." — Green and Petre

19 Why Might Being Natural be Good? n Example: n Inserting item into 3rd place of high score list n Conventional Languages: n Loop, starting at end of array, shuffle items down, then insert n Example: n Inserting item into 3rd place of high score list n Conventional Languages: n Loop, starting at end of array, shuffle items down, then insert

20 Why Might Being Natural be Good? 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 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. VB: Let Shape1.FillColor = &H00FF00FF& ML: SetColor ( Shape1, 0x00FF00FF ) vs. VB: Let Shape1.FillColor = &H00FF00FF& ML: SetColor ( Shape1, 0x00FF00FF )

21 Background Research n Empirical Studies of Programmers, Psychology of Programming, and HCI results not being used in the design of new languages n 30 years of research on what makes languages hard to learn and error-prone n Java / C# looping, etc. n Summarized in our comprehensive tech report — John Pane and Brad Myers, “Usability Issues in the Design of Novice Programming Systems” TR# CMU-CS Aug, n Empirical Studies of Programmers, Psychology of Programming, and HCI results not being used in the design of new languages n 30 years of research on what makes languages hard to learn and error-prone n Java / C# looping, etc. n Summarized in our comprehensive tech report — John Pane and Brad Myers, “Usability Issues in the Design of Novice Programming Systems” TR# CMU-CS Aug,

22 Examples of Problems Identified n Promote Locality and Avoid Hidden Dependencies n Type definitions often are far from the use n Code readability is of key importance n Don’t try to reduce keystrokes if makes less readable n Inheritance and object-oriented design are very difficult n Beware of misleading appearances n When novices and experts mis-read code n Avoid subtle distinctions in syntax n E.g., a=b vs. a==b; () vs. [] vs. {}; >= vs. => vs. -> n Promote Locality and Avoid Hidden Dependencies n Type definitions often are far from the use n Code readability is of key importance n Don’t try to reduce keystrokes if makes less readable n Inheritance and object-oriented design are very difficult n Beware of misleading appearances n When novices and experts mis-read code n Avoid subtle distinctions in syntax n E.g., a=b vs. a==b; () vs. [] vs. {}; >= vs. => vs. ->

23 More Examples n People expect consistency with external representations and usage (math, English, etc.): n People will search for an analogue in their experience that is similar to the syntax n “and”; a=a+1; a=2 vs. 2=a; 1<a<10; n ML: ~ is unary negative, - for subtraction: 5 - ~2 n So, if different meaning, should have different presentation n Significant difficulties in finding bugs due to invisible data, dependencies, and control flow n People expect consistency with external representations and usage (math, English, etc.): n People will search for an analogue in their experience that is similar to the syntax n “and”; a=a+1; a=2 vs. 2=a; 1<a<10; n ML: ~ is unary negative, - for subtraction: 5 - ~2 n So, if different meaning, should have different presentation n Significant difficulties in finding bugs due to invisible data, dependencies, and control flow

24 HCI Methods for Analyzing Languages n Analyze languages as user interfaces n Green’s Cognitive Dimensions — Green and Petre, 1996, “Usability Analysis of VP Environments: A ‘Cognitive Dimensions Framework’. Journal of VL&C, 7(2): n 13 dimensions n Nielsen’s heuristic analysis principles — Nielsen, J., Usability Engineering. 1993, Boston: Academic Press n 10 principles n Can also perform usability studies for specific issues n Analyze languages as user interfaces n Green’s Cognitive Dimensions — Green and Petre, 1996, “Usability Analysis of VP Environments: A ‘Cognitive Dimensions Framework’. Journal of VL&C, 7(2): n 13 dimensions n Nielsen’s heuristic analysis principles — Nielsen, J., Usability Engineering. 1993, Boston: Academic Press n 10 principles n Can also perform usability studies for specific issues

25 Consistency n Both a Cognitive Dimension and a Heuristic Analysis principle C++ uses the word " static " to mean at least 3 different things In C++, can use int a,b; to define globals or locals, but not as procedure parameters n Should be able to copy code and use the same code elsewhere In Visual Basic, to assign something you use “=” unless is an object, in which case you use “Set” and “=” " foo = 15 " vs. " Set foo = object “ n ML: “fun f x = 0” vs. “case e of x => 0” n Both a Cognitive Dimension and a Heuristic Analysis principle C++ uses the word " static " to mean at least 3 different things In C++, can use int a,b; to define globals or locals, but not as procedure parameters n Should be able to copy code and use the same code elsewhere In Visual Basic, to assign something you use “=” unless is an object, in which case you use “Set” and “=” " foo = 15 " vs. " Set foo = object “ n ML: “fun f x = 0” vs. “case e of x => 0”

26 Error-Proneness n HCI Principle = Prevent errors n C and C++ array bounds errors n Requiring the "break" in each branch of C, C++ switch statements causes many errors (still in Java, fixed in C#) Small typos can result in compilable programs that perform incorrectly, e.g., "=" for "==” or " x-=3 ” vs. " x=-3 “ or fun f(SOME _)=... (a constructor pattern) vs. fun f(SOME_)=... (a variable) n HCI Principle = Prevent errors n C and C++ array bounds errors n Requiring the "break" in each branch of C, C++ switch statements causes many errors (still in Java, fixed in C#) Small typos can result in compilable programs that perform incorrectly, e.g., "=" for "==” or " x-=3 ” vs. " x=-3 “ or fun f(SOME _)=... (a constructor pattern) vs. fun f(SOME_)=... (a variable)

27 Good Error Messages n Should be: clear, helpful, precise, constructive n Not “syntax error” n In C++, so much flexibility, compiler often doesn’t know where error is n Similar problems with type inference systems SML/NJ: stdIn: Error: operator and operand don't agree [tycon mismatch] operator domain: ?.t operand: ?.t in expression: f B n Should be: clear, helpful, precise, constructive n Not “syntax error” n In C++, so much flexibility, compiler often doesn’t know where error is n Similar problems with type inference systems SML/NJ: stdIn: Error: operator and operand don't agree [tycon mismatch] operator domain: ?.t operand: ?.t in expression: f B

28 Closeness of Mapping n HCI principle = Speak the User's Language n Expressions of algorithms close to the way users think of them n Also, syntactic Issues: n C++ uses "void" to mean "none", "char" to mean 8-bit number,... n Visual Basic uses "Dim" to declare variables and "wend" to end while loops n Arrays start at 0 whereas people think of counting from 1 n Case sensitivity n HCI principle = Speak the User's Language n Expressions of algorithms close to the way users think of them n Also, syntactic Issues: n C++ uses "void" to mean "none", "char" to mean 8-bit number,... n Visual Basic uses "Dim" to declare variables and "wend" to end while loops n Arrays start at 0 whereas people think of counting from 1 n Case sensitivity

29 Viscosity n Resistance to local change n To change parameters of a function in C++, have to edit.h file and.cpp file, plus all call sites n Changing an “if” statement into a “do” statement was difficult in early structure editors n VLs are very difficult due to layout issues n May have to reposition all lines and boxes to make room and neaten resulting drawing n May need to disconnect and reconnect many wires n Need for correct indenting may make Haskell programs resistant to editing n But good editor can help n Resistance to local change n To change parameters of a function in C++, have to edit.h file and.cpp file, plus all call sites n Changing an “if” statement into a “do” statement was difficult in early structure editors n VLs are very difficult due to layout issues n May have to reposition all lines and boxes to make room and neaten resulting drawing n May need to disconnect and reconnect many wires n Need for correct indenting may make Haskell programs resistant to editing n But good editor can help

30 Less is More n HCI principle (“keep it simple”) C, C++ have 16 levels of precedence that have to be memorized, some of which are left-associative and some are right-associative. Consider: a=b+=c=+d*e+++f==g which is a legal statement in C++ and C n Deep nesting in functional languages n “Too many parentheses” n HCI principle (“keep it simple”) C, C++ have 16 levels of precedence that have to be memorized, some of which are left-associative and some are right-associative. Consider: a=b+=c=+d*e+++f==g which is a legal statement in C++ and C n Deep nesting in functional languages n “Too many parentheses”

31 Help the user get started with the system n Small things should be simple n Programs that do small things must still often be very large, e.g., creating a window containing a single red rectangle n The 2-pages needed in Motif to do “Hello World” n “zero” lines in Visual Basic n In Java, it still requires: class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } n Note 3 kinds of parentheses, 9 special words ML: print "Hello World!" n Small things should be simple n Programs that do small things must still often be very large, e.g., creating a window containing a single red rectangle n The 2-pages needed in Motif to do “Hello World” n “zero” lines in Visual Basic n In Java, it still requires: class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); } n Note 3 kinds of parentheses, 9 special words ML: print "Hello World!"

32 Other Issues n Many more, see: n You can send me examples from each other’s systems! n But these are mainly good for analysis n Given a design question, how answer it? n Many more, see: n You can send me examples from each other’s systems! n But these are mainly good for analysis n Given a design question, how answer it?

33 Our Research n Lots of gaps in prior research on people and programming n Develop knowledge that can be used in design n Ph.D. thesis of John Pane n Available at: n Evaluate: n How people express algorithms and think about tasks n Vocabulary and notations used n Related to the HCI principles of “know the user”, “task analysis”, and “closeness of mapping” n Lots of gaps in prior research on people and programming n Develop knowledge that can be used in design n Ph.D. thesis of John Pane n Available at: n Evaluate: n How people express algorithms and think about tasks n Vocabulary and notations used n Related to the HCI principles of “know the user”, “task analysis”, and “closeness of mapping”

34 Our Studies so far n How people naturally express programming concepts and algorithms 1) Nine scenes from PacMan 2) Transforming and calculating data in a spreadsheet n Specific issues of language design 3) Selecting specific objects from a group (“and”, “or”, “not”) n How people naturally express programming concepts and algorithms 1) Nine scenes from PacMan 2) Transforming and calculating data in a spreadsheet n Specific issues of language design 3) Selecting specific objects from a group (“and”, “or”, “not”)

35 Experimental Design n Question should not bias the answer n So use pictures instead of textual descriptions n Concentrate on kids, non-programmers n Subjects should not be “tainted” by existing programming languages n Tested that the results generalize to adults and programmers n Question should not bias the answer n So use pictures instead of textual descriptions n Concentrate on kids, non-programmers n Subjects should not be “tainted” by existing programming languages n Tested 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

37 Second Study n Whether similar results from other domains and with adults n Developed 11 questions with scenarios using spreadsheets n To test database access and operations n More conventionally “computational” n Whether similar results from other domains and with adults n Developed 11 questions with scenarios using spreadsheets n To test database access and operations n More conventionally “computational”

38 Example Question, 2nd Study No. First name Last name 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 First name Last name

39 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.” Aggregate operations instead of iterations “The monsters turn blue and run away” “Subtract 20,000 from all elements in Round 2” — These tend to eliminate control structures Aggregate operations instead of iterations “The monsters turn blue and run away” “Subtract 20,000 from all elements in Round 2” — These tend to eliminate control structures

40 More Results The words “AND” and “THEN” often used for sequencing instead of as a logical operator “The monsters turn color and start to back up.” n Boolean expression (AND, OR) not common Usually had mutually exclusive rules “If I press the up arrow, PacMan goes up. If I press the down arrow, PacMan goes down, …” General case first, then exceptions “When you encounter a ghost, it should kill you. But if you get a big pill first you can eat them.” n Boolean expression (AND, OR) not common Usually had mutually exclusive rules “If I press the up arrow, PacMan goes up. If I press the down arrow, PacMan goes down, …” General case first, then exceptions “When you encounter a ghost, it should kill you. But if you get a big pill first you can eat them.”

41 Yet More Results Most arithmetic used natural language style “When PacMan eats a big dot, the score goes up 100.” n Operations suggest data as lists, not arrays n People don’t make space before inserting Objects normally moving “If PacMan hits a wall, he stops.” n so objects remember their own state 2/3 of the first study subjects drew pictures n Usually to define the initial state n Operations suggest data as lists, not arrays n People don’t make space before inserting Objects normally moving “If PacMan hits a wall, he stops.” n so objects remember their own state 2/3 of the first study subjects drew pictures n Usually to define the initial state

42 Third Study: Select Objects from a Group n Concentrate on a known problematic area n Use of AND, OR, NOT n Often eliminated from Web searching n Newsweek reports that less than 6% of users manage to use “and”, “or”, “+”, “-” n Still dominant in all programming languages n First: generate queries given results n Then, answer queries n Form-based and Textual formats n Order was counter-balanced n Concentrate on a known problematic area n Use of AND, OR, NOT n Often eliminated from Web searching n Newsweek reports that less than 6% of users manage to use “and”, “or”, “+”, “-” n Still dominant in all programming languages n First: generate queries given results n Then, answer queries n Form-based and Textual formats n Order was counter-balanced

43 Generate Queries

44 Answer Queries

45 Results Using “unless” did not help accuracy “select the objects that are blue unless the objects are square” vs. “select the objects that match blue and not square “And” was a Boolean conjunction sometimes “select the objects that match blue and circle” vs. “select the objects that match blue and the objects that match circle” Precedence of “not” varied “select the objects that match not red and square” 64% interpreted as “(not red) and square” “select the objects that match not triangle or green” 67% interpreted as “not (triangle or green)” “And” was a Boolean conjunction sometimes “select the objects that match blue and circle” vs. “select the objects that match blue and the objects that match circle” Precedence of “not” varied “select the objects that match not red and square” 64% interpreted as “(not red) and square” “select the objects that match not triangle or green” 67% interpreted as “not (triangle or green)”

46 More results n 2-D forms helped for generation n 94% correct with match forms, vs. 85% correct with text (p<.0001) n 2-D forms helped for generation n 94% correct with match forms, vs. 85% correct with text (p<.0001) (blue and not square) or (circle and not green)

47 Implications for New Languages n For increased usability for novices: n Use event-based style for dynamic events n Work to minimize the need for control structures and variables n Provide operations on groups of objects n Data structures that combine the capabilities of lists + arrays + sets n Support simple arithmetic in natural language style (“add 1 to score”) n Avoid the use of the word “and” altogether n For increased usability for novices: n Use event-based style for dynamic events n Work to minimize the need for control structures and variables n Provide operations on groups of objects n Data structures that combine the capabilities of lists + arrays + sets n Support simple arithmetic in natural language style (“add 1 to score”) n Avoid the use of the word “and” altogether

48 New Language and System: HANDS n Video Video n Video Video Human-centered Advances for Novices to Develop Software

49 Properties of HANDS n Goal: Allow children age 10 to create interactive games and simulations n Programming in the small (in the tiny) n Event based computation model n Metaphor of agent manipulating cards n All data is visible as properties of the cards n All operations work on singletons or lists n No distinction in syntax n Can generate lists on the fly with queries n Minimize need for control structures n Minimize need for local variables n Goal: Allow children age 10 to create interactive games and simulations n Programming in the small (in the tiny) n Event based computation model n Metaphor of agent manipulating cards n All data is visible as properties of the cards n All operations work on singletons or lists n No distinction in syntax n Can generate lists on the fly with queries n Minimize need for control structures n Minimize need for local variables

50 More Properties of Hands n Verbose Language n Easier to read n No precedence n Does use parentheses n But just one kind! n Environment provide lots of help with syntax and graphics n Tries to be extremely consistent, and also apply other HCI rules n For example, combines IF, CASE (switch), and COND (from Lisp) into one construct n Verbose Language n Easier to read n No precedence n Does use parentheses n But just one kind! n Environment provide lots of help with syntax and graphics n Tries to be extremely consistent, and also apply other HCI rules n For example, combines IF, CASE (switch), and COND (from Lisp) into one construct

51 Conclusions n Much more research needed on the human side of programming n Usability of languages and environments can be improved n Claims about usability can be tested n Languages can be evaluated using HCI principles and techniques n If you want a useable and learnable programming language, there are data and techniques available that can help. n Much more research needed on the human side of programming n Usability of languages and environments can be improved n Claims about usability can be tested n Languages can be evaluated using HCI principles and techniques n If you want a useable and learnable programming language, there are data and techniques available that can help.

52 Credits Support for this research has come in part from the National Science Foundation under Grant No. IRI and Grant No. IIS For more information, see: Support for this research has come in part from the National Science Foundation under Grant No. IRI and Grant No. IIS For more information, see:

53 Towards More Natural Functional Programming Languages Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University Brad A. Myers Human-Computer Interaction Institute School of Computer Science Carnegie Mellon University