Bridging the Semantic Gap in Gradual Programming

undefined
 
Gradual Programming:
Bridging the Semantic Gap
 
Bor-Yuh Evan Chang
Bor-Yuh Evan Chang
   Amer Diwan   Jeremy G. Siek
University of Colorado, Boulder
 
PLDI FIT 2009
Have you noticed a time where your program
is not optimized where you expect?
Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming
“I need a
map data
structure
Load class file
Run class
initialization
Create hashtable
Problem
Problem
: Tools (IDEs, checkers, optimizers) have no
knowledge of what the programmer cares about
… hampering programmer productivity,
software reliability, and execution efficiency
Observation
Observation
: A disconnect between programmer
intent and program meaning
Example: Iteration Order
 
class
 OpenArray 
extends
 Object {
private
 Double data[];
public boolean
 contains(Object lookFor) {
for
 (i = 0; i < data.length; i++) {
 
if
 (data[i].equals(lookFor)) 
return true
;
}
return false
;
}
}
Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming
Compiler cannot choose a different
iteration order (e.g., 
parallel
parallel
)
 
class
 OpenArray 
extends
 Object {
private
 Double data[];
public boolean
 contains(Object lookFor) {
for
 (i = 0; i 
<
 data.length; i++) {
 
if
 (data[i].equals(lookFor)) 
return true
;
}
return false
;
}
}
Must specify an iteration order
Must specify an iteration order
even when it should not matter
Wild and Crazy Idea: Use Non-Determinism
Programmer starts with a potentially
non-deterministic program
Analysis identifies instances of “under-
determinedness”
Programmer eliminates “under-
determinedness”
Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming
Question
Question
: What does this mean?
Is it “under-determined”?
Response
Response
: Depends, is the
iteration order important?
Let’s try a few program variants
Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming
Do they compute
the same result?
What about here?
Surprisingly, analysis says no.  Why?
Exceptions!
Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming
Need 
user
interaction
to 
refine
specification 
that captures
programmer
intent
 
left-to-right
 iteration
 
returns true
 
right-to-left
 iteration
 
throws NullPointerException
Scary Proposal?
 
“Fix semantics per program”:
Abstract constructs with 
many possible
concrete implementations
 
Apply 
program analysis 
to find inconsistent
implementations
Interact 
with the user to refine the
specification
Language 
designer role 
can enumerate the
possible implementations
Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming
Bridging the Semantic Gap
Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming
“I need a
map data
structure
“Looks like iterator
order matters for
your program”
“Yes, I need
iteration in
sorted order”
“Let’s use a
balanced binary
tree (TreeMap)”
Slide Note
Embed
Share

Observing a disconnect between programmer intent and program meaning, Gradual Programming by Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek explores tools' lack of knowledge in understanding programmers' priorities, hindering productivity and reliability. Through examples like iteration orders and non-determinism, the authors propose addressing semantic gaps for enhanced program optimization and efficiency.

  • Gradual Programming
  • Semantic Gap
  • Program Optimization
  • Programmer Intent
  • Software Reliability

Uploaded on Sep 30, 2024 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Gradual Programming: Bridging the Semantic Gap Bor-Yuh Evan Chang Amer Diwan Jeremy G. Siek University of Colorado, Boulder PLDI FIT 2009

  2. Have you noticed a time where your program is not optimized where you expect? Observation: A disconnect between programmer intent and program meaning I need a map data structure Load class file Run class initialization Create hashtable semantic gap Problem: Tools (IDEs, checkers, optimizers) have no knowledge of what the programmer cares about hampering programmer productivity, software reliability, and execution efficiency Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming 2

  3. Example: Iteration Order Must specify an iteration order even when it should not matter class OpenArray extends Object { private Double data[]; public boolean contains(Object lookFor) { for (i = 0; i < data.length; i++) { if (data[i].equals(lookFor)) return true; } return false; } } } class OpenArray extends Object { private Double data[]; public boolean contains(Object lookFor) { for (i = 0; i < data.length; i++) { if (data[i].equals(lookFor)) return true; } return false; } Compiler cannot choose a different iteration order (e.g., parallel) Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming 3

  4. Wild and Crazy Idea: Use Non-Determinism Programmer starts with a potentially non-deterministic program Analysis identifies instances of under- determinedness Programmer eliminates under- determinedness Question: What does this mean? Is it under-determined ? Response: Depends, is the iteration order important? over-determined just right class OpenArray extends Object { private Double data[]; public boolean contains(Object lookFor) { for (i = 0; i < data.length; i++) { if (data[i].equals(lookFor)) return true; } return false; } } } class OpenArray extends Object { private Double data[]; public boolean contains(Object lookFor) { i 0 .. data.length-1 { if (data[i].equals(lookFor)) return true; } return false; } starting point under-determined Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming 4

  5. Lets try a few program variants public boolean contains(Object lookFor) { for (i = 0; i < data.length; i++) { if (data[i].equals(lookFor)) return true; } return false; } Do they compute the same result? Approach: Try to verify equivalence of program variants up to a specification public boolean contains(Object lookFor) { for (i = data.length-1; i >= 0; i--) { if (data[i].equals(lookFor)) return true; } return false; } public boolean contains(Object lookFor) { parallel_for (0, data.length-1) i => { if (data[i].equals(lookFor)) return true; } return false; } Yes Pick any one No Ask user What about here? Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming 5

  6. Surprisingly, analysis says no. Why? Exceptions! Need user interaction to refine specification that captures programmer intent a.data = null a.contains( ) left-to-right iteration returns true right-to-left iteration throws NullPointerException Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming 6

  7. Scary Proposal? Fix semantics per program : Abstract constructs with many possible concrete implementations Apply program analysis to find inconsistent implementations Interact with the user to refine the specification Language designer role can enumerate the possible implementations Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming 7

  8. Bridging the Semantic Gap I need a map data structure Looks like iterator order matters for your program Yes, I need iteration in sorted order Let s use a balanced binary tree (TreeMap) Bor-Yuh Evan Chang, Amer Diwan, and Jeremy G. Siek - Gradual Programming 8

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#