!""""""" "# $t+ W Tl+% $Oo+ OoVo% $ Mo+ Mo+% $+ Q + + % $ + PpBv+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ Mo+

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
C-LISP. LISP 2 Lisp was invented by John McCarthy in 1958 while he was at the Massachusetts Institute of Technology (MIT).John McCarthyMassachusetts Institute.
C Language.
What Does This Program Do?
Compiling Web Scripts for Apache Jacob Matthews Luke Hoban Robby Findler Rice University.
How Many Continuations can Dance on the Head of a Pin Matthias Felleisen King of Continuations and Professor of Computer Science.
Introduction to Memory Management. 2 General Structure of Run-Time Memory.
Programming Paradigms and languages
Chapter 17 vector and Free Store John Keyser’s Modifications of Slides By Bjarne Stroustrup
Control Structures Any mechanism that departs from straight-line execution: –Selection: if-statements –Multiway-selection: case statements –Unbounded iteration:
Adding Dynamic Content to your Web Site
C Intro.
RPC Robert Grimm New York University Remote Procedure Calls.
Functional Programming. Pure Functional Programming Computation is largely performed by applying functions to values. The value of an expression depends.
SWE 316: Software Design and Architecture
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
CS 290C: Formal Models for Web Software Lecture 10: Language Based Modeling and Analysis of Navigation Errors Instructor: Tevfik Bultan.
JavaScript ICW: Lecture 11 Tom Chothia. Last Lecture URLs Threads, to make a process run in parallel: Make it extend Thread Give it a run method Call.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Session Management A290/A590, Fall /25/2014.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
CHAPTER 1: INTORDUCTION TO C LANGUAGE
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
UniSTEP / MLC Seminars: Maths in Lectures: Understanding the Notation Dr David Butler Maths Learning Centre The University of Adelaide
Javascript and the Web Whys and Hows of Javascript.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
C Course Lecture 4 This lecture we'll talk about: Multi-dimensional arrays. Pointer arithmetic. Pointers to structures. Multi-file programming. What is.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
EE4E. C++ Programming Lecture 1 From C to C++. Contents Introduction Introduction Variables Variables Pointers and references Pointers and references.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
CSU - DCE Advanced Perl CGI Operation - Fort Collins, CO Copyright © XTR Systems, LLC Introduction to the Common Gateway Interface (CGI) on the.
4 Dec 2001Kestrel1 From Patterns to Programming Languages Matthias Felleisen Northeastern University.
CGI Security COEN 351. CGI Security Security holes are exploited by user input. We need to check user input against Buffer overflows etc. that cause a.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Dynamic Memory Allocation Conventional array and other data declarations An incorrect attempt to size memory dynamically Requirement for dynamic allocation.
Computer Science Detecting Memory Access Errors via Illegal Write Monitoring Ongoing Research by Emre Can Sezer.
Chapter 0.2 – Pointers and Memory. Type Specifiers  const  may be initialised but not used in any subsequent assignment  common and useful  volatile.
1 Nov 2001Yale1 Programming Interactive Web Scripts Matthias Felleisen Northeastern University.
Architecture of the web Client Server retrieved or generated web page.
Identification and Protection of Security-Critical Data Nora Sovarel University of Virginia Computer Science June 6, 2006 MCS Project Presentation.
EIW - ASP Introduction1 Active Server Pages VBScript.
Getting Started with MATLAB (part2) 1. Basic Data manipulation 2. Basic Data Understanding 1. The Binary System 2. The ASCII Table 3. Creating Good Variables.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Engineering H192 - Computer Programming Gateway Engineering Education Coalition Lect 5P. 1Winter Quarter C Programming Basics Lecture 5.
Producing a high-impact web experience by integrate Macromedia Flash and ASP By Katie Tuttle CS 330: Internet Architecture and Programming Project.
6 Feb 2002PL Day1 Programming Interactive Web Scripts Matthias Felleisen PLT.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
© 2004 Pearson Addison-Wesley. All rights reserved January 23, 2006 Creating Objects & String Class ComS 207: Programming I (in Java) Iowa State University,
World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.
Lesson 11. CGI CGI is the interface between a Web page or browser and a Web server that is running a certain program/script. The CGI (Common Gateway Interface)
Brief Look InTo JavaScript Dr. Thomas Hicks Computer Science Department Trinity University.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Functional Programming
Arrays & Functions Lesson xx
Storage.
Ada – 1983 History’s largest design effort
The Metacircular Evaluator
Introducing the .NET Framework
CSE-321 Programming Languages Introduction to Functional Programming
Architecture of the web
Web Application Development Using PHP
Presentation transcript:

!""""""" "# $t+ W Tl+% $Oo+ OoVo% $ Mo+ Mo+% $+ Q + + % $ + PpBv+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ Mo+ Mo+% $+ Q + + % $ + PpBv+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ Mo+ Mo+% $+ Q + B % $ + Pp+v+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $m+ Pp+v+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $n+ Pp+v+% $+ + +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $n+ Pp+v+% $+ + +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ Mo+ Mo+% $+ Q + B % $ + Pp+v+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $m+ Pp+v+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $n+ Pp+v+% $+ + +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ +o+% $+ Q + B % $n+ Pm+v+% $+ + +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $n+ Pp+v+% $+ + +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $m+ Pp+v+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $m+ Pp+v+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ Q + B % $m+ Pp+v+% $+ N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ + + B % $m+ Pp+v+% $Q N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ + + B % $ + Pp+v+% $Q M +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ + + B % $M+ Pp+v+% $Q N +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ + + B % $ + Pp+v+% $Q M +n+ % $pP + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ + + B % $ + Pp+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ +o+% $+ + + B % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ Mo+% $+ + + B % $ + Pp+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ BoVo% $ +o+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ OoVo% $ +o+ +o+% $+ + + B % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ W Tl+% $Oo+ BoVo% $ +o+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Bl+% $Oo+ +oVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ +bPm+v+% $Q P +n+ % $p+ + PpP% $+ +rK +r% /((((((( () !""""""" "# $t+ + Vl+% $Oo+ +o+o% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ +bP +v+% $Q M +n+ % $p+ + PpP% $+ +rK +r% /((((((( () !""""""" "# $t+ + Bl+% $Oo+ +oVo% $ Wo+ +o+% $ % $ + Pm+v+% $Q P +n+ % $p+ + PpP% $+ +rKb+r% /((((((( () !""""""" "# $t+ + Tl+% $Oo+ BoVo% $ Wo+ +o+% $ % $ +bPm+v+% $Q P +n+ % $p+ + PpP% $+ +rK +r% /((((((( () Automatically Restructuring Programs for the Web Matthews, Graunke, Krishnamurthi, Findler, Felleisen

50% of Web pages are generated on demand. The so-called Web scripts are nowadays complex, evolving programs. However, existing technology is inadequate. Web Scripts

fun input msg = print msg; read fun adder = print (input 1st number?) + (input 2nd number?) Pro: interaction is computation driven; natural programming style. Interactive Programming Paradigm

Web scripts must terminate after producing one single page (exception: Fast CGI); control information is erased between user interactions (Fast CGI solves this problem). Back button + window cloning; the client becomes a co-routine with unbounded resumption points (Fast CGI cant solve it). Serious Engineering Problem

Solution: come up with a hack to explicitly store/recover state per hand. Current Approaches fun produce-html msg hidden-mark env =... fun adder = hidden-mark = extract-hidden-mark env = extract-env ans = extract-answer if hidden-mark = undefined then produce-html 1st number? step 1 [] else if hidden-mark = step 1 then produce-html 2nd number? step 2 [ans] else if hidden-mark = step 2 then produce-html ((hd env) + ans) done []

Program Inversion: the interaction becomes user driven! Current Approaches But inversion is: unnatural; complicated; error prone, if done per hand; counter-productive.

Use a PL that can explicitly manipulate continuations to grab and store them on the server [Queinnec 2000]. Problems: most PLs dont support call/cc existing infrastructure becomes useless; distributed garbage collection problem; timeouts are an imperfect solution. A Better Solution?

use existing, well understood FP techniques to automatically transform them into programs for the Web. Write usual interactive programs in your favourite PL and environment; Use a PL that has call/cc. A Better Solution?

continuation passing style (CPS), lambda lifting, defunctionalization. How can we grab, send, and resume continuations in an arbitrary PL? By transforming the program with: The Preprocessing Solution One last step generates a program for the web.

fun adder = input 1st number? λ n 0 => input 2nd number? λ n 1 => print n 0 + n 1 fun input msg = print msg; read fun adder = print (input 1st number?) + (input 2nd number?) fun input msg f = print msg; f read Continuation Passing Style

Lambda lifting fun input msg f env = print msg; f env read fun adder = input 1st number? f 0 [] fun f 0 [] n 0 = input 2nd number? f 1 [n 0 ] fun f 1 [n 0 ] n 1 = print n 0 + n 1 fun input msg f = print msg; f read fun adder = input 1st number? λ n 0 => input 2nd number? λ n 1 => print n 0 + n 1

fun adder = input 1st number? 0 [] fun f 0 [] n 0 = input 2nd number? 1 [n 0 ] fun f 0 [n 0 ] n 1 = print n 0 + n 1 fun apply idx env = funs.idx env vector funs = {f 0, f 1 } Defunctionalization fun input msg idx env = print msg; apply idx env read fun input msg f env = print msg; f env read fun adder = input 1st number? f 0 [] fun f 0 [] n 0 = input 2nd number? f 1 [n 0 ] fun f 0 [n 0 ] n 1 = print n 0 + n 1

CPS: the only function that interacts with the user ( input ) is passed a continuation. λ lifting: the structure of the program is flattened; all functions are named and global. Defunctionalization: no function is passed or returned. Till now, the function input simply executes the continuation passed to it... What have we done till now? The Preprocessing Solution

Interactive Program CGI Program fun input msg idx env = produce-html msg idx env fun input msg idx env = print msg; apply idx env read vector funs... fun apply... fun adder = input 1st number? 0 [] fun f 0... fun f 1... fun adder = idx = extract-idx; env = extract-env; ans = extract-answer; apply idx env ans; handle NoCont => input 1st number? 0 [] vector funs... fun apply... fun f 0... fun f 1...

You can do it also in C... #include typedef struct { int code; void *env; } closure; typedef void (*closuretype)(void*, void*); void input(char *s, closure *k); closure *make_closure( int code, void *env){ closure *k = (closure*) malloc(sizeof(closure)); k->code = code, k->env = env; return k; } void f 0 (void *env, void *n 0 ) { closure *k = make_closure(1, n 0 ); input("2nd number?", k); } void f 1 (void *n0, void *n 1 ) { printf("%d\n", (int) n 0 + (int) n 1 ); } closuretype closures[] = {f 0, f 1 }; void apply(closure *k, void *args){ int code = k->code; void *env = k->env; free(k); (*(closures[code]))(env, args); } void input(char *s, closure *k){ char buffer[10]; int i; printf("%s", s); fgets(buffer,10, stdin); i = atoi(buffer); apply(k, (void *) i); } int main() { closure *k = make_closure(0, (void *) 0); input("1st number?", k); return 0; }

…or even in BASIC... The dispatcher: REM adder... IF idx = 0 THEN GOTO 100 ELSE IF idx = 1 THEN GOTO REM f REM f1...

Solution: save the store in a cookie. val high_score = ref 0;... high_score := !high_score + 1; Save Store in Cookies Problem: the store is independent from the continuations.

Problem: Race Conditions Buy a flatscreen... Web Server Balance=900 BUY=FLATSCREEN Balance=900 Balance=160 Thank you :-) Buy a scanner... Balance=900 BUY=SCANNER Web Client

Solution: Sequence Numbers Buy a flatscreen... Web Server : SEQ= Balance=900 BUY=FLATSCREEN SEQ= Balance=900 Balance=160 SEQ= Balance=160 Thank you :-) Buy a scanner... SEQ= Balance=900 BUY=SCANNER (Reintroduces the server side storage management problem.) Web Server : Web Client

Security/Efficiency Problem: a malicious user may forge the continuation; a curious user may inspect sensitive data. Solution: encrypt/sign continuation. Problem: continuations may be large pieces of data. Solution: compress them.

Problem: Debugging Executed code bears little resemblance to programmers code. How do you debug it? Answer: still an open question... Ad hoc solution for PLs with call/cc : dont preprocess; reimplement the input function to store continuations and send HTML to Web browser; reimplement the main function to resume current continuation.

Paul Graunke, Shriram Krishnamurthi, Robert Bruce Findler, Matthias Felleisen (2001): Automatically Restructuring Programs for the Web. Jacob Matthews, Paul Graunke, Shriram Krishnamurthi, Robert Bruce Findler, Matthias Felleisen (2004): Automatically Restructuring Programs for the Web. Christian Queinnec (2000): The influence of browsers on evaluators or, continuations to program Web servers. In: ACM SIGPLAN International Conference on Functional Programming. Andrew W. Appel (1992): Compiling with Continuations. Cambridge University Press. Thomas Johnson (1985): Lambda Lifting: Transforming Programs to Recursive Equations. In: Proceedings of the Conference on Functional Programming Languages and Computer Architecture. Nancy, France. John C. Reynolds (1972): Definitional Interpreters for Higher-Order Programming Languages. In: Proceedings of the 25 th ACM National Conference. pp. 717–740. Literature

Conclusion Automatic restructuring of programs for the Web enables programmers to: use existing paradigms and tools; structure programs in a natural way; Thank you! be more productive.

DISJUNCTION CONJUNCTION NEGATION IMPLIES IFF EMPTY SET OMEGA IN NOT IN UNION INTERSECTION SUBSET SUPERSET 2 POWERSET CARTESIAN PRODUCT EXISTS FORALL, = (NOT) EQUAL TO, LESS (GREATER) THAN, LESS (GREATER) THAN OR EQUAL TO CIRCA EQUIVALENT SUM PRODUCT TO DIVISION ROOT INTEGRAL INFINITY,,, DELTA, DELTA, SMALL DELTA, SIGMA,, SMALL PSI, ALPHA, BETA