1 Lecture 12 Ideas for the Final Project DSLs in real world; language extensions Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction.

Slides:



Advertisements
Similar presentations
Copyright 2001, ActiveState. XSLT and Scripting Languages or…XSLT: what is everyone so hot and bothered about?
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Modifying existing content Adding/Removing content on a page using jQuery.
Transition from C to C++ …and a Review of Basic Problem Solving.
Presented by: Thabet Kacem Spring Outline Contributions Introduction Proposed Approach Related Work Reconception of ADLs XTEAM Tool Chain Discussion.
What is a Programming Language? The computer operates using binary numbers. The computer only knows about 1’s and 0’s. Humans can also use 1’s and 0’s,
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
6/12/2015Prof. Hilfinger CS164 Lecture 111 Bottom-Up Parsing Lecture (From slides by G. Necula & R. Bodik)
1/18 CS 693/793 Lecture 09 Special Topics in Domain Specific Languages CS 693/793-1C Spring 2004 Mo, We, Fr 10:10 – 11:00 CH 430.
Telescoping Languages: A Compiler Strategy for Implementation of High-Level Domain-Specific Programming Systems Ken Kennedy Rice University.
Advanced Compilers CSE 231 Instructor: Sorin Lerner.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Russell Taylor Lecturer in Computing & Business Studies.
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
The Basic Tools Presented by: Robert E., & Jonathan Chase.
Mgt 240 Lecture Website Construction: Software and Language Alternatives March 29, 2005.
Programming. Software is made by programmers Computers need all kinds of software, from operating systems to applications People learn how to tell the.
4.01B Authoring Languages and Web Authoring Software 4.01 Examine webpage development and design.
THE BASICS OF THE WEB Davison Web Design. Introduction to the Web Main Ideas The Internet is a worldwide network of hardware. The World Wide Web is part.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Type-Directed, Whitespace-Delimited Parsing for Embedded DSLs Cyrus Omar School of Computer Science Carnegie Mellon University [GlobalDSL13] Benjamin ChungAlex.
Extensible Type-Driven Parsing for Embedded DSLs in Wyvern Cyrus Omar Benjamin Chung Darya Kurilova Ligia Nistor Alex Potanin (Victoria University of Wellington)
1 Lecture 2 Unit Conversion Calculator Expressions, values, types. Their representation and interpretation. Ras Bodik Shaon Barman Thibaud Hottelier Hack.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
ITM352 PHP and Dynamic Web Pages: Server Side Processing.
4.1 JavaScript Introduction
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Startup – Chapter 1.
Sikuli Ivailo Dinkov QA Engineer PhoneX Team Telerik QA Academy.
Chapter 33 CGI Technology for Dynamic Web Documents There are two alternative forms of retrieving web documents. Instead of retrieving static HTML documents,
Java: Chapter 1 Computer Systems Computer Programming II.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
1 Extending Java And Developing DSLs With Open Source Language Workbench JetBrains MPS Konstantin Solomatov JetBrains Lead Developer for JetBrains MPS.
JSP Java Server Pages Softsmith Infotech.
University of Sunderland CDM105 Session 5 Web Authoring Tools The past and present A history of web authoring tools and an overview of Macromedia Dreamweaver.
1 Programming Languages Tevfik Koşar Lecture - II January 19 th, 2006.
Client/browser productivity language Ras Bodik, Thibaud Hottelier, James Ide, and Doug Kimelman(IBM)
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
1 Lecture 6 Logic Programming introduction to Prolog, facts, rules Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction to.
CS 390 Unix Programming Summer Unix Programming - CS 3902 Course Details Online Information Please check.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
Introduction to Programming the WWW I CMSC Summer 2003 Lecture 7.
Apache JMeter By Lamiya Qasim. Apache JMeter Tool for load test functional behavior and measure performance. Questions: Does JMeter offers support for.
Overview of Previous Lesson(s) Over View  A program must be translated into a form in which it can be executed by a computer.  The software systems.
Cross Language Clone Analysis Team 2 October 13, 2010.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
Celluloid An interactive media sequencing language.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
User Profiling using Semantic Web Group members: Ashwin Somaiah Asha Stephen Charlie Sudharshan Reddy.
Introduction What is detector simulation? A detector simulation program must provide the possibility of describing accurately an experimental setup (both.
Intermediate 2 Computing Unit 2 - Software Development.
4.01B Authoring Languages and Web Authoring Software 4.01 Examine webpage development and design.
JavaScript 101 Introduction to Programming. Topics What is programming? The common elements found in most programming languages Introduction to JavaScript.
FUNCTIONAL PROGRAMING AT WORK - HASKELL AND DOMAIN SPECIFIC LANGUAGES Dr. John Peterson Western State Colorado University.
1 Lecture 14 Data Abstraction Objects, inheritance, prototypes Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction to Programming.
1 CSC160 Chapter 1: Introduction to JavaScript Chapter 2: Placing JavaScript in an HTML File.
LECTURE #4: JQUERY AND FORM VALIDATION Josh Kaine Josh Kaine 4/1/2016.
REEM ALMOTIRI Information Technology Department Majmaah University.
1 Using jQuery JavaScript & jQuery the missing manual (Second Edition)
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Lecture 1b- Introduction
ITM352 PHP and Dynamic Web Pages: Server Side Processing 1.
Topic: Programming Languages and their Evolution + Intro to Scratch
Learning to Program D is for Digital.
Unit# 8: Introduction to Computer Programming
Presentation transcript:

1 Lecture 12 Ideas for the Final Project DSLs in real world; language extensions Ras Bodik Shaon Barman Thibaud Hottelier Hack Your Language! CS164: Introduction to Programming Languages and Compilers, Spring 2012 UC Berkeley

Final project Think of it as self-designed PA10 The goal: convince yourself you can use CS164 skills to solve a real problem. Typical final project: design and implement a small language. Instead of final exam, you’ll have free pizza and can demo your work! 2

CS164 Fall 2009 Demo session 3

Also will announce winners of contests 4 Best Parser Contest. Best PA9 Browser Demo Contest. Fall 2010

Project timeline 5

Final project proposal Find a problem solvable with CS164 skills Your customers: programmers, end-users, web designers, … Document how the problem is solved today Give example of typical code (illustrate today’s problems) Show how your small language would solve it (design) Rewrite typical code in your language Outline the implementation Internal/external/hybrid? Compiled/interpreted? One page of text. Due Sun Mar 3. Work in pairs or triples. 6

Finding the right problem is half the solution A problem well stated is a problem half solved. Inventor Charles Franklin KetteringInventor Charles Franklin Kettering (1876–1958) We're all fairly good at problem solving. That's the skill we were taught and endlessly drilled on at school. Once we have a problem, we know how to turn the crank and get a solution. Ah, but finding a problem—there's the rub. Engineering education is based on the presumption that there exists a predefined problem worthy of a solution. If only it were so! From When the Problem is the Problem, Robert LuckyWhen the Problem is the Problem 7

Today What you’ll have built after PA9 –Your final project can build on PA1-9 Examples of cs164 projects animation browser extensions debugger for 164 distributed continuations Examples of influential DSLs protovis memoize mapReduce family 8

Programming Assignments PA4-6: parser and compilers You’ll know: write a grammar, translate programs to other language interpret programs, limited natural language processing PA7-9: browser w/ modern scripting Parse and layout a subset of HTML; a subset of jQuery; reactive programming 9

Reactive Programming with events My box document.addEventListener ( 'mousemove', function (e) { var left = e.pageX; var top = e.pageY; setTimeout(function() { document.getElementById("box").style.top = top; document.getElementById("box").style.left = left; }, 500); }, false);

PA9-like language body.column.div delay 500 mouse top left top left Program structure is clearer when data and control is explicit in dataflow version: changing mouse coordinates are streams coordinate streams adjust box position after they are delayed structured names of document element allow analysis

memoize 12

memoize Memoize: a replacement for make. Author: Bill McCloskey, Berkeley Allows writing build scripts in "common" languages eg in Python or the shell rather than forcing you to rely on make's hopelessly recondite makefile language. 13

Example 1: a shell script calling memoize #!/bin/sh memoize.py gcc -c file1.c memoize.py gcc -c file2.c memoize.py gcc -o program file1.o file2.o 14

Example 2: a python script calling memoize #!/usr/bin/env python import sys from memoize import memoize def run(cmd): status = memoize(cmd) if status: sys.exit(status) run('ocamllex x86lex.mll') run('ocamlyacc x86parse.mly') run('ocamlc -c x86parse.mli') run('ocamlc -c x86parse.ml') run('ocamlc -c x86lex.ml') run('ocamlc -c main.ml') run('ocamlc -o program x86parse.cmi x86parse.cmo x86lex.cmo main.cmo') 15

How would you make it work? Let's try to design it. Goal: determine if a command needs to be rerun. 16

How memoize works Key idea: determine if a command needs to run Assumptions: a command is a pure function –its output depends only on its input files –common for compilers and other build tools Computing Dependences (what cmd depends on): –uses strace to intercept system calls, like open –r = os.system('strace -f -o %s -e trace=%s /bin/sh -c "%s"' % (outfile, calls, ecmd)) Computing file modification times: –Alternative 1: use system file modification time –Alternative 2: compute MD5 hash value for a value Keep dependences and times in a file 17

D3 18

D3: a JS DSL for manipulating data documents 19

D3 example 20

Problems solvable by DSLs Where did we already use DSLs in cs164 project: –grammars –graph visualization Additional DSLs that would come really handy –tree rewriting –grammar debuggers –environment visualizers 21

Problems solvable by DSLs scripting of games, build processes, etc templating of web pages and other documents graph layout (GraphViz) tree rewriting (GrGen) 22

MediaWiki Template DSL The Template:Weather page has the text: The Weather in {{{1}}} is always {{{2}}}. An editor can then add the template {{Weather}} on several other wikipages. On the State of Maine page: {{Weather|Maine|cold}} Displays: The Weather in Maine is always cold. On the State of Florida page: {{Weather|Florida|hot}} Displays: The Weather in Florida is always hot. 23

MapReduce family MapReduce Sawsall PlumeJava 24

Example projects from past cs164 Grainline: constraint language for tailors TablUI: 25

brainstorming 26

Customers of your DSLs 27

Discussion continued 28

Low-risk final projects These projects are safe in that you don't need to come up with a problem to be solved by the language. You will still need to do some good thinking before you can implement these languages. Can implement in 164 or in another langauge (eg Lua, Python, JavaScript, etc) 29

Extend an existing DSL write a plugin for jQuery: example of a plugin that adds if/else to jQuery (this is a nice example bit it is too small for a final project)example make jQuery animation a bit richer, for example allow some of these composable animationscomposable animations add a new kind of "mark" to protovisprotovis 30

Rethink an existing DSL Do jQuery or protovis better 31

Grow the 164 language extend 164 with some cool features, such as meta- programming (to support sugar directly) 32

Bug finding write a tool that finds a class of bugs (a program analyzer). –memory leaks This tool could instrument the program and identify potential bugs generate interface for C programs from a config file: examples: swigswig 33

Compilation and source-to-source translation 1) Compile the 164 language into more efficient code ex: turn hashtables into structs (tuples) when possible May involve adding static types or program analysis 2) Translate 164 to a language with a fast interpreter eg Lua (Python and JS don’t have full coroutines) Motivation: remove interpretation overhead, thus enable more exciting final projects 34

Debugger for 164 language especially one that can be easily given to students in a starter kit breakpoints, pretty-printing of data exploit existing Python debuggers? 35

Pros Domain-specific languages allow solutions to be expressed in the idiom and at the level of abstraction of the problem domain. Consequently, domain experts themselves can understand, validate, modify, and often even develop domain-specific language programs. Self-documenting code. Domain-specific languages enhance quality, productivity, reliability, maintainability, portability and reusability. Domain-specific languages allow validation at the domain level. As long as the language constructs are safe any sentence written with them can be considered safe. 36

Cons of DSLs Cost of learning a new language vs. its limited applicability Cost of designing, implementing, and maintaining a domain- specific language as well as the tools required to develop with it (IDE)IDE Finding, setting, and maintaining proper scope. Difficulty of balancing trade-offs between domain-specificity and general-purpose programming language constructs. Potential loss of processor efficiency compared with hand- coded software.efficiency Proliferation of similar non-standard domain specific languages, i.e. a DSL used within insurance company A versus a DSL used within insurance company B. 37