It’s Alive! Continuous Feedback in UI Programming Sebastian Burckhardt Manuel Fahndrich Peli de Halleux Sean McDirmid Michal Moskal Nikolai Tillmann Microsoft.

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
TouchDevelop: Productive Scripting on and for Mobile Devices and Web Services Thomas Ball Sebastian Burckhardt, Peli de Halleux, Michał Moskal, Nikolai.
Pages and boxes Building quick user interfaces. learning objectives o Build a quick UI with pages and boxes o understand how pages and boxes work o click.
Fusebox & CFCs Barney Boisvert 2004 Fusebox Conference.
Short Portlet Programming Guide in P-Grade (Gridsphere) environment G. Hermann.
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
1 XML Web Services Practical Implementations Bob Steemson Product Architect iSOFT plc.
My first computer: The Apple ][ It wanted to be programmed.
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
The Web Warrior Guide to Web Design Technologies
Java Programming, 3e Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Internet Technologies 1 Master of Information System Management Java Server Faces Model/View/Controller Design Pattern for Web Development Slides.
Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE.
The Composite Pattern.. Composite Pattern Intent –Compose objects into tree structures to represent part-whole hierarchies. –Composite lets clients treat.
1 Exception and Event Handling (Based on:Concepts of Programming Languages, 8 th edition, by Robert W. Sebesta, 2007)
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
4.1 JavaScript Introduction
MVC pattern and implementation in java
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
1 Ajax. 2 What’s Ajax? AJAX is a combination of a few technologies that has come together in the past few years AJAX used to be an acronym for Asynchronous.
WorkPlace Pro Utilities.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
1 Forms A form is the usual way that information is gotten from a browser to a server –HTML has tags to create a collection of objects that implement this.
XForms: A case study Rajiv Shivane & Pavitar Singh.
Chapter 5 Java Script And Forms JavaScript, Third Edition.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
JavaScript II ECT 270 Robin Burke. Outline JavaScript review Processing Syntax Events and event handling Form validation.
10 Adding Interactivity to a Web Site Section 10.1 Define scripting Summarize interactivity design guidelines Identify scripting languages Compare common.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Putting together a complete system Chapter 10. Overview  Design a modest but complete system  A collection of objects work together to solve a problem.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Compiler Construction
In the next step you will enter some data records into the table. This can be done easily using the ‘Data Browser’. The data browser can be accessed via.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Object Oriented Software Development 9. Creating Graphical User Interfaces.
University of Sunderland COM 220 Lecture Six Slide 1 Building Interactive Forms Applications using Oracle.
CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.
Apps Find the latest version of this document at
INFO 355Week #71 Systems Analysis II User and system interface design INFO 355 Glenn Booker.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
JavaScript, Fourth Edition
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Java Programming, 2E Introductory Concepts and Techniques Chapter 4 Decision Making and Repetition with Reusable Objects.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
Chapter 5 Introduction To Form Builder. Lesson A Objectives  Display Forms Builder forms in a Web browser  Use a data block form to view, insert, update,
AJAX. Overview of Ajax Ajax is not an API or a programming language Ajax aims to provide more responsive web applications In normal request/response HTTP.
Positioning Objects with CSS and Tables
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
IE 411/511: Visual Programming for Industrial Applications Lecture Notes #2 Introduction to the Visual Basic Express 2010 Integrated Development Environment.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Day 22, Slide 1 CSE 103 Day 22 Non-students: Please logout by 10:12. Students:
Boxes. boxes- learning targets o I will be able to display buttons (boxes) o I will be able to organize boxes o I will be able to create an animation.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Section 10.1 Define scripting
Introduction to.
JavaScript, Sixth Edition
Names and Attributes Names are a key programming language feature
Learning to Program D is for Digital.
Chap 7. Building Java Graphical User Interfaces
Presentation transcript:

It’s Alive! Continuous Feedback in UI Programming Sebastian Burckhardt Manuel Fahndrich Peli de Halleux Sean McDirmid Michal Moskal Nikolai Tillmann Microsoft Research Jun Kato The University of Tokyo

Live Programming : Archer Analogy [Hancock, 2003] Archer: aim, shoot, inspect, repeat Hose: aim & watch

Archer: aim, shoot, inspect, repeat edit, compile, test, repeat Hose: aim & watch edit & watch Live Programming : Archer Analogy [Hancock, 2003]

Quick Demo: What is Live Programming? What is TouchDevelop?

Question: How to do live programming? Target: Event-driven apps with graphical user interfaces (GUI’s) User input events (tap button, edit text,..) I/O events (e.g. asynchronous web requests) We can think of code editing as an event (replace old program with a new one) What should we do in this situation?

on code changes, just replay execution from beginning How to do live programming? Replay Based ?

How to do live programming? Replay Based ? Inputs? Must record or repeat user inputs and I/O Divergence? Recorded events may no longer make sense after code change Side effects? Replaying external side effects can have surprising consequences Performance? Apps with GUIs can run for a long time, replay not efficient on code changes, just replay execution from beginning

How to do live programming? Replay Based ? Inputs? Must record or repeat user inputs and I/O Divergence? Recorded events may no longer make sense after code change Side effects? Replaying external side effects can have surprising consequences Performance? Apps with GUIs can run for a long time, replay not efficient Replay is difficult. Worse: it does not always make sense. on code changes, just replay execution from beginning

Widen the Scope. Question: How to do live programming? Replay Based ?

Widen the Scope. Question 2: How to do live programming? Question 1: How to program event- driven apps with GUIs? Replay Based Retained Model- View Stateless Model- View ?

Widen the Scope. Question 2: How to do live programming? Question 1: How to program event- driven apps with GUIs? Replay Based Retained Model- View Model- View Based Stateless Model- View

Question 1: How to program GUIs? Model-View-Controller: Well established pattern for interactive applications Many variations exist Model Data definitions Model Data definitions View UI Elements View UI Elements Controller Event handlers Controller Event handlers update trigger

Question 1: How to program GUIs? Model-View-Controller: Well established pattern for interactive applications Many variations exist. We eliminate controller and put event handlers into the view. Model Data definitions Model Data definitions View UI Elements Event Handlers View UI Elements Event Handlers

Question 1: How to program GUIs? Model-View-Controller: Well established pattern for interactive applications Many variations exist. We eliminate controller and put event handlers into the view. Model Data definitions Model Data definitions View UI Elements Event Handlers View UI Elements Event Handlers Key question: How to define and maintain correspondence between view and model?

How to program GUIs? Retained View Model: Data definitions that define the model View-Construction: Code that defines how to construct the view for a given model View-Update: Code that defines how to update the view in reaction to model changes Program = Model + View-Construction + View-Update

How to program GUIs? Retained View Model: Data definitions that define the model View-Construction: Code that defines how to construct the view for a given model View-Update: Code that defines how to update the view in reaction to model changes Program = Model + View-Construction + View-Update Redundant Error prone

How to program GUIs? Retained ViewStateless View Model: Data definitions that define the model View-Construction: Code that defines how to construct the view for a given model Program = Model + View-Construction + View-Update Program = Model + View-Construction Update is simple: throw away old view, build new one.

Example. Very simple app: list of strings. User can add entries by hitting the “add” button. Program = Model + View-Construction

Example data entries: String Collection data field : String Model View-Construction Example Execute view construction code entries = [ “entry1”, “entry2” ] field = “entry3” Model View = Tree, decorated with attributes and event handlers Vert. stack Hor. stack label entry1 label entry2 add button +handler input field

How to write view construction code? Host language for our prototype: TouchDevelop Host language in the paper: lambda-calculus Many frameworks are hybrids between a general-purpose language and a declarative language (e.g. C# + XML). We would prefer: stay within single host language, but make code look as declarative as possible.

Idea: extend host language Special construct: nested “boxed” statements boxed { …. nested code here …. } When executing, creates box tree implicitly view structure is implied by program structure, no need for programmer to manipulate collections! Code looks similar to declarative code.

Code Example. data entries: String Collection data field : String display boxed box → use horizontal layout for each s in entries do boxed labelstyle() s → post boxed box → use horizontal layout boxed buttonstyle() "add" → post to wall on tapped(() => entries → add(field)) boxed inputstyle() box → edit( field, (x) => field := x) function buttonstyle() box → set border(colors → foreground, 0.1) box → set margins(0.5, 0.5, 0.5, 0.5) box → set padding(0.2, 0.2, 0.2, 0.2) box → set background(colors → orange) box → set width(10) View-Construction Code Model

No need for separate language or special collection classes. Adapt layout to various conditions – use a standard conditional Repeated elements - use standard loops Keep your code organized – use functional abstraction Provide widget collection – write a library User interface element = just a function.

Question 1: How to do live programming? This is now much easier to get a grasp on.

Question 1: How to do live programming? on code changes, migrate model, build fresh view Answer:

Does Model Migration Work? Currently, we do something very simple Variables whose types have changed are removed from model Experience: behaves reasonably in practice w.r.t to typical changes and user expectations More interesting solutions conceivable for structured data (cf. schema evolution, dynamic code updating) on code changes, migrate model, build fresh view

Valid Concern: Speed? Isn’t it too slow to reconstruct the view from scratch every time? In our experience (Browser-based, Javascript): Re-executing the compiled display code is no problem for our apps (never more than 1000 objects on screen) However, recreating the DOM tree from scratch is too slow (browser takes too much time) and has other issues (e.g. lose focus while typing in a textbox when it is replaced) Fix: We implemented optimization that modifies the DOM tree incrementally when reexecuting the display code. on code changes, migrate model, build fresh view

Yes, but what does all this mean, exactly? Paper contains a careful formalization of these concepts! Lambda calculus + UI primitives (boxes) Operational semantics System model for event-handling with page stack, UI, and code change events Type and Effect System

Read/Write Model Navigation View Construction Pure

System Model

System Executio n Steps

Two execution modes with different allowed side effects Event handler execution Can mutate model Can push/pop pages Display code execution Can set box attributes Can create boxes

System Model Visuali- zation Need Render (C,-,S,P(p,v),ɛ) Ready (C,B,S,P(p,v),ɛ) Initial (C,-,ɛ,ɛ,ɛ) Active (C,-,S,P(p,v),Q) User taps button or hits back button Handle events in queue until queue empty Build view from model Push start page User changes code

Type & Effect System Judgments Allows us to tell what kind of function we are looking at Lets us ensure that {event handlers, display code} only have the allowed side-effects for the given mode

Practical Experience Type/Effect system is sometimes too restrictive. For example, does not allow this in display code: var x = new object(); x.field := value; More useful in practice: runtime checks that allow allocating fresh objects in a display heap, and allow mutation of the display heap

Goals Programming Model Support succinct programming of apps with GUIs (graphical user interfaces) Support live editing Precise reactive semantics (user events, code changes) Implementation Embed into TouchDevelop (language, runtime, IDE) Enforce correct use of feature (separation of model and view) Contributions Live-View Approach Feature is public Runs on all devices touchdevelop.com Formal System Model Static Type/Effect System Language Integration