SlideShare uma empresa Scribd logo
1 de 76
Baixar para ler offline
Software Language
Design & Engineering


      Eelco Visser
     http://eelcovisser.org




                              Microsoft Research, Redmond
                                    October 20, 2011
Software Engineering




Problem
                                                         Machine
Domain




   bridging the gap between problem domain and solution domain
High-Level Languages




Problem
                                                 HLL                     Machine
Domain




          "A programming language is low level when its programs
           require attention to the irrelevant." Alan J. Perlis (1982)


                          HLLs reduce gap
Domain-Specific Languages




Problem
                   DSL                 HLL               Machine
Domain




      domain-specific languages support more specialization
Software Language Design & Engineering




enable software engineers to
effectively design, implement,
 and apply domain-specific
     software languages
Research: Software Language Engineering



 automatically derive efficient,
scalable, incremental compiler +
   usable IDE from high-level,
   declarativelanguage
           definition
The Spoofax Language Workbench




creating full featured IDEs for domain-specific languages
Research: Software Language Design



systematically design domain-specific
 software languages
   with optimal tradeoff between
  expressivity, completeness, portability,
     coverage, and maintainability
Software Language Design Case Studies

                                               Mobl: client-side stateful web applications




WebDSL: server-side restful web applications
Two Talks



   Declaratively Programming
   the Mobile Web with Mobl



The Spoofax Language Workbench
Declaratively Programming
the Mobile Web with Mobl*


 Zef Hemel                             Eelco Visser
  http://zef.me                      http://eelcovisser.org




      * To appear: SPLASH/OOPSLA, October 2011, Portland
Divergence in Mobile Platforms




 Objective-C            Java                  J2ME/C++




HTML/Javascript         Java                    .NET

           Native Applications not Portable
Convergence in Mobile Platform




Webkit browser   Webkit browser




Webkit browser   Webkit browser
The Universal Userinterface Engine
Mobile Web Architecture
Rich Applications

                                      Audio
    WebDatabases
                              Full-screen support

Location information (GPS)
                                 Offline support
         Canvas

                             Accelerator support
       Multi-touch
Native Applications


            Address book
                Camera
               Compass
                 File IO
             Notifications
Software Engineering with JavaScript




annotated HTML                imperative Javascript

 MVC, No Integration, No Abstraction, Accidental Complexity
Late Failures in Web Applications




               Zef Hemel, Danny M. Groenewegen, Lennart C. L. Kats, Eelco Visser.
             Static consistency checking of web applications with WebDSL. Journal of
                            Symbolic Computation, 46(2):150-182, 2011.
typed                declarative



             http://www.mobl-lang.org


integrated                   concise
Web Application with Touch
Portable Applications
Mobl Architecture
tipcalculator.mobl


application tipcalculator

import mobl::ui::generic

screen root() {
  var amount = 20
  var percentage = 10
  header("Tip calculator")
  group {
    item { numField(amount, label="amount") }
    item { numField(percentage, label="percentage") }
    item { "$" label(Math.round(amount * (1 + percentage/100))) }
  }
}
Model-View Pattern
Task Manager
Data Model

entity Task {
  name     : String (searchable)
  done     : Bool
  due      : DateTime
  category : Category (inverse: tasks)
  tags     : Collection<Tag> (inverse: tasks)
}
entity Category {
  name : String
  tasks : Collection<Task> (inverse: category)
}
entity Tag {
  name : String
  tasks : Collection<Task> (inverse: tags)
}




           HTML5 Data Persistence
Logic

entity Task {
  ...
  function postpone(days : Num) {
    this.due = DateTime.create(
      this.due.getFullYear(),
      this.due.getMonth(),
      this.due.getDate() + days);
  }
  function import(user : String, pw : String) {
    var tasksJSON =
          httpRequest("/export?user="+ user + "&pw=" + pw);
    foreach(t in tasksJSON) {
      add(Task.fromSelectJSON(t));
    }
  }
}



              statically typed: catch errors early
Reactive User Interfaces

screen root() {
  var phrase = ""
  header("Tasks") {
    button("Add", onclick={ addTask(); })
  }
  searchBox(phrase)
  group {
    list(t in Task.search(phrase) limit 20){
      item {
        checkBox(t.done, label=t.name)
      }
    }
  }
}
Navigation

screen root() { {
         addTask()
  var phrase = ""
       t = Task()
  header("Add") {
  header("Tasks") {
    button("Done", onclick={
    button("Add", onclick={ addTask(); })
  }    add(t);
  searchBox(phrase)
       screen return;
  group {
    })
  } list(t in Task.search(phrase) limit 20){
  textField(t.name)
       item {
  datePicker(t.due)
          checkBox(t.done, label=t.name)
}      }
    }
  }
}
Continuations

screen root() {
  button("Ask", onclick={
     alert("Hello " + prompt("First name") + " "
                     + prompt("Last name"));
  })
}
screen prompt(question : String) : String {
  var answer = ""
  header(question) {
     button("Done", onclick={
        screen return answer;
     })
  }
  textField(answer)
}
Reusable Controls


screen root() {
  tabSet([("One", tab1),
          ("Two", tab2)],
    defaultTab="One")
}
control tab1() {
  header("Tab 1")
  label("This is tab 1")
}
control tab2() {
  header("Tab 2")
  label("This is tab 2")
}




                User Interface Idiom: Tab
Tab Set: Higher-Order Control

control tabSet(tabs : [(String,Control)], activeTab : String) {
  list((tabName, tabControl) in tabs) {
    block(onclick={ activeTab = tabName; },
          style=activeTab==tabName ?
                activeTabButton : inactiveTabButton) {
      label(tabName)
    }
  }
  list((tabName, tabControl) in tabs) {
    block(activeTab==tabName ? visibleTab : invisibleTab) {
      tabControl()
    }
  }
}




       increase coverage: developers can create abstractions
User Interface Idiom: Master Detail


screen root() {
  header("Tasks")
  masterDetail(
    Task.all() order by due desc,
    taskItem,
    taskDetail)
}
control taskItem(t : Task) {
  checkBox(t.done, label=t.name)
}
control taskDetail(t : Task) {
  textField(t.name)
  datePicker(t.due)
}
Master Detail: Higher-Order Control

control masterDetail(items : Collection<?>,
                     masterItem : Control1<?>,
                     detail : Control1<?>)
{
  group {
    list(it in items) {
      item(onclick={ detailScreen(it,detail); }) {
        masterItem(it)
      }
    }
  }
}
screen detailScreen(it : ?, detail : Control1<?>) {
  header("Detail") { backButton() }
  detail(it)
}
Adaptive Layout
applications
Mobl Applications
GR8 Conference Program
mPodder
Ken




http://itsneh.com/ken/
Mobl Summary

❖ Linguistic integration
  ★ data model, user interface, styling, application logic

❖ Domain abstractions
  ★ reduce accidental complexity, platform details

❖ User-defined abstractions
  ★ data binding
  ★ reactive programming
  ★ reusable controls

❖ Model-View
  ★ automate the controller
Mobl IDE: Static Cross-Concern Consistency Checking




        Constructed on Spoofax Language Workbench
The Spoofax Language Workbench*
 Rules for Declarative Specification of Languages and IDEs




      Lennart Kats                           Eelco Visser
      http://www.lclnet.nl               http://eelcovisser.org




                             * OOPSLA 2010
Research: Software Language Engineering



 Automatically derive efficient,
scalable, incremental compiler +
   usable IDE from high-level,
   declarativelanguage
           definition
Language Definitions for Compilers

Syntax definition
★ concrete syntax
★ abstract syntax

Static semantics
★ error checking
★ name resolution
★ type analysis

Model-to-model transformation
★ express constructs in core language

Code generation
★ translate core language models to implementation
Editor Services for Modern IDEs

Syntactic Editor Services
★ syntax checking
★ bracket matching
★ syntax highlighting
★ code folding
★ outline view

Semantic Editor Services
★ error checking
★ reference resolving
★ hover help
★ code completion
★ refactoring
Syntax Definition with SDF
Declarative Syntax Definition


lexical syntax
  [a-zA-Z_$][a-zA-Z0-9_]* -> ID

context-free syntax
  STRING                       ->    LimitedSetExp {cons("String")}
  NUMBER                       ->    LimitedSetExp {cons("Num")}
  LimitedSetExp                ->    Exp
  QId                          ->    LimitedExp {cons("Var")}
  "(" Exp ")"                  ->    LimitedExp {cons("Brackets")}
  Exp BoolMethodId Exp         ->    Exp {cons("BinMethodCall"), left}
  Exp CompareMethodId Exp      ->    Exp {cons("BinMethodCall"), left}
  Exp TermOperatorMethodId Exp ->    Exp {cons("BinMethodCall"), left}
  Exp OperatorMethodId Exp     ->    Exp {cons("BinMethodCall"), left}




character-level grammars: integration of lexical and context-free syntax
An Interactive Language Workbench




develop and use language in same environment
Debugging Ambiguities
Declarative Disambiguation



context-free priorities
  Exp "." ID -> LimitedExp
> Exp "." ID "(" {NamedExp ","}* ")" -> LimitedExp
> Exp TermOperatorMethodId Exp -> Exp
> Exp OperatorMethodId Exp -> Exp
> Exp CompareMethodId Exp -> Exp
> Exp BoolMethodId Exp -> Exp
> "!" Exp -> Exp
> Exp "?" Exp ":" Exp -> Exp
> LimitedExp Filter+ -> Exp
Parsing after Disambiguation
Natural and Flexible Error Recovery*




permissive grammar + backtracking + region discovery [*OOPSLA & SLE 2009]
Transformation with Stratego
Syntactic Normalization and Desugaring


rules

  normalize :
    FunctionNoReturnType(manno*, name, farg*, stat*) ->
    Function(manno*, name, farg*,
              SimpleType(QId("mobl", "void")), stat*)

  normalize :
    IfNoElse(e, block) -> If(e, block, Block([]))

  desugar :
    ForInferred(lvalue, e, elem*) -> For(lvalue, t, e, elem*)
    where GenericType(_, [t]) := <type-of> e
CPS Transform




cps-lift-exprs :
  [Return(e)|stats] ->
     <concat>[stats2, [Return(e2)|<cps-lift-expressions> stats]]
  where not(<is-sync> e)
  with {| Exp
        : stats2 := <cps-lift-expression> e
        ; e2 := <Exp>
        |}
Type Analysis




eq-type-of :
  String(_) -> SimpleType(QId("mobl", "String"))

eq-type-of :
  FieldAccess(e, x) -> t
  where Property(_, _, t, _) := <lookup-property> (<type-of> e, x)
Type Checking

constraint-error :
  t@SimpleType(_) -> (t, $[Type is not defined: [<pp-mobl-type> t]])
  where not(<lookup-type> t)

constraint-error :
  t@FieldAccess(e, x) -> (t, $[Property [x] not defined])
  where <type-of> e
  where not(type-of)




                            origin tracking
Semantic Editor Services

editor-analyze:
  (ast, path, project-path) -> (ast2, errors, warnings, notes)
  with // ...

editor-complete-proposal :
  SimpleType(COMPLETION(_)) -> proposals
  where
    all-types := <get-all-types>;
    proposals := <map(type-name-to-proposal); flatten-list> all-types

editor-hover:
  (t@SimpleType(_), position, ast, path, project-path) ->
    <get-doc> <lookup-type> t2
  where t2 := <lookup-node> (position, ast)

editor-resolve:
    (t@SimpleType(qid), position, ast, path, project-path) -> target
    where target := <ensure-origin(lookup-type|qid)> t
Editor Services Bindings



module MoBL-Builders

imports MoBL-Builders.generated

builders
  provider   :   include/mobl.jar
  observer   :   editor-analyze
  on save    :   generate-artifacts
  builder    :   "Show ATerm" = generate-aterm (openeditor) (realtime) (meta)
  builder    :   "Format code" = format-code (openeditor) (realtime)
  builder    :   "Desugar"      = editor-desugar (openeditor) (realtime) (meta)




                        Connect transformations to IDE
Integrated Language Definition Testing*




Includes testing of the editor services [* OOPSLA 2011]
Software Language Design & Engineering

           Linguistic abstraction:
       capture software knowledge in
         domain-specific languages                    http://spoofax.org

separation of concerns + linguistic integration    http://mobl-lang.org

     cross concern consistency checking               http://webdsl.org
          early detection of failures              http://researchr.org
    Language workbench: DSL design and            http://eelcovisser.org
    implementation with less effort than
       traditional language engineering


 http://researchr.org/search/publication/mobl+spoofax+webdsl
behind the scenes
synchronous programming


var results = Task.all().list();
for(var i = 0; i < results.length; i++) {
   alert(results[i].name);
}
render page




                 time
query database
 and process
    results




      ...
render page




                                  time
                 query database
browser freeze    and process
                     results




                       ...
render page

 send query




                time
     ...


process query
    result


     ...
asynchronous programming


Task.all.list(function(results) {
    for(var i = 0; i < results.length; i++) {
       alert(results[i].name);
    }
  });
...
Task.all().list(function(results) {
  alert("Hello, ");
});                      breaks sequential
alert("world!");
                     execution assumption
Task.all().list(function(results) {
  // make changes
  ...
  persistence.flush(function() {
    alert("Changes saved!");
  });
});
continuation-passing style
     transformation
function displayLocationAndReturn() : Coordinates {
  var position = mobl::location::getPosition();
  log("Lat: " + position.latitude);
  log("Long: " + position.longitude);
  return position;
}




function displayLocationAndReturn(callback) {
   mobl.location.getPosition(function(position) {
     console.log("Lat: " + position.latitude);
     console.log("Long: " + position.longitude);
     callback(position);
   });
};
function displayLocationAndReturn() : Coordinates {
  var position = mobl::location::getPosition();
  log("Lat: " + position.latitude);
  log("Long: " + position.longitude);
  return position;
}




function displayLocationAndReturn(callback) {
   mobl.location.getPosition(function(position) {
     console.log("Lat: " + position.latitude);
     console.log("Long: " + position.longitude);
     callback(position);
   });
};
function displayLocationAndReturn() : Coordinates {
  var position = mobl::location::getPosition();
  log("Lat: " + position.latitude);
  log("Long: " + position.longitude);
  return position;
}




function displayLocationAndReturn(callback) {
   mobl.location.getPosition(function(position) {
     console.log("Lat: " + position.latitude);
     console.log("Long: " + position.longitude);
     callback(position);
   });
};

Mais conteúdo relacionado

Semelhante a Software Language Design & Engineering: Mobl & Spoofax

Software Language Design & Engineering
Software Language Design & EngineeringSoftware Language Design & Engineering
Software Language Design & EngineeringEelco Visser
 
Linguistic Abstraction for the Web
Linguistic Abstraction for the WebLinguistic Abstraction for the Web
Linguistic Abstraction for the WebEelco Visser
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesEelco Visser
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010Satish Verma
 
Advanced Serverless Computing in Azure: not another "Hello serverless World"!
Advanced Serverless Computing in Azure: not another "Hello serverless World"!Advanced Serverless Computing in Azure: not another "Hello serverless World"!
Advanced Serverless Computing in Azure: not another "Hello serverless World"!Lorenzo Barbieri
 
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNextMicrosoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNextRodolfo Finochietti
 
Visual Studio.NET
Visual Studio.NETVisual Studio.NET
Visual Studio.NETsalonityagi
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersDave Bost
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#Talbott Crowell
 
App innovationcircles xamarin
App innovationcircles xamarinApp innovationcircles xamarin
App innovationcircles xamarinMohit Chhabra
 
Whidbey old
Whidbey old Whidbey old
Whidbey old grenaud
 
Google Dev Day2007
Google Dev Day2007Google Dev Day2007
Google Dev Day2007lucclaes
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinPranav Ainavolu
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...Maarten Balliauw
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomerzefhemel
 
Introduction to Xamarin Mobile Platform
Introduction to Xamarin Mobile PlatformIntroduction to Xamarin Mobile Platform
Introduction to Xamarin Mobile PlatformDominik Minta
 
Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Bruce Johnson
 

Semelhante a Software Language Design & Engineering: Mobl & Spoofax (20)

Software Language Design & Engineering
Software Language Design & EngineeringSoftware Language Design & Engineering
Software Language Design & Engineering
 
Linguistic Abstraction for the Web
Linguistic Abstraction for the WebLinguistic Abstraction for the Web
Linguistic Abstraction for the Web
 
TI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific LanguagesTI1220 Lecture 14: Domain-Specific Languages
TI1220 Lecture 14: Domain-Specific Languages
 
Tml for Objective C
Tml for Objective CTml for Objective C
Tml for Objective C
 
Visual Studio .NET2010
Visual Studio .NET2010Visual Studio .NET2010
Visual Studio .NET2010
 
Advanced Serverless Computing in Azure: not another "Hello serverless World"!
Advanced Serverless Computing in Azure: not another "Hello serverless World"!Advanced Serverless Computing in Azure: not another "Hello serverless World"!
Advanced Serverless Computing in Azure: not another "Hello serverless World"!
 
Visual studio.net
Visual studio.netVisual studio.net
Visual studio.net
 
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNextMicrosoft 2014 Dev Plataform -  Roslyn -& ASP.NET vNext
Microsoft 2014 Dev Plataform - Roslyn -& ASP.NET vNext
 
Visual Studio.NET
Visual Studio.NETVisual Studio.NET
Visual Studio.NET
 
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for DevelopersMSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
MSDN Presents: Visual Studio 2010, .NET 4, SharePoint 2010 for Developers
 
Exploring SharePoint with F#
Exploring SharePoint with F#Exploring SharePoint with F#
Exploring SharePoint with F#
 
App innovationcircles xamarin
App innovationcircles xamarinApp innovationcircles xamarin
App innovationcircles xamarin
 
Whidbey old
Whidbey old Whidbey old
Whidbey old
 
Google Dev Day2007
Google Dev Day2007Google Dev Day2007
Google Dev Day2007
 
Cross platform mobile app development with Xamarin
Cross platform mobile app development with XamarinCross platform mobile app development with Xamarin
Cross platform mobile app development with Xamarin
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
mobl presentation @ IHomer
mobl presentation @ IHomermobl presentation @ IHomer
mobl presentation @ IHomer
 
mobl
moblmobl
mobl
 
Introduction to Xamarin Mobile Platform
Introduction to Xamarin Mobile PlatformIntroduction to Xamarin Mobile Platform
Introduction to Xamarin Mobile Platform
 
Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0Overview of VS2010 and .NET 4.0
Overview of VS2010 and .NET 4.0
 

Mais de Eelco Visser

CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingEelco Visser
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesEelco Visser
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingEelco Visser
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionEelco Visser
 
CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionEelco Visser
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesEelco Visser
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with StatixEelco Visser
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionEelco Visser
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Eelco Visser
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementEelco Visser
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersEelco Visser
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationEelco Visser
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesEelco Visser
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksEelco Visser
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisEelco Visser
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionEelco Visser
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsEelco Visser
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingEelco Visser
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingEelco Visser
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Eelco Visser
 

Mais de Eelco Visser (20)

CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term RewritingCS4200 2019 | Lecture 5 | Transformation by Term Rewriting
CS4200 2019 | Lecture 5 | Transformation by Term Rewriting
 
CS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic ServicesCS4200 2019 | Lecture 4 | Syntactic Services
CS4200 2019 | Lecture 4 | Syntactic Services
 
CS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | ParsingCS4200 2019 | Lecture 3 | Parsing
CS4200 2019 | Lecture 3 | Parsing
 
CS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definitionCS4200 2019 | Lecture 2 | syntax-definition
CS4200 2019 | Lecture 2 | syntax-definition
 
CS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: IntroductionCS4200 2019 Lecture 1: Introduction
CS4200 2019 Lecture 1: Introduction
 
A Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation RulesA Direct Semantics of Declarative Disambiguation Rules
A Direct Semantics of Declarative Disambiguation Rules
 
Declarative Type System Specification with Statix
Declarative Type System Specification with StatixDeclarative Type System Specification with Statix
Declarative Type System Specification with Statix
 
Compiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler ConstructionCompiler Construction | Lecture 17 | Beyond Compiler Construction
Compiler Construction | Lecture 17 | Beyond Compiler Construction
 
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)Domain Specific Languages for Parallel Graph AnalytiX (PGX)
Domain Specific Languages for Parallel Graph AnalytiX (PGX)
 
Compiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory ManagementCompiler Construction | Lecture 15 | Memory Management
Compiler Construction | Lecture 15 | Memory Management
 
Compiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | InterpretersCompiler Construction | Lecture 14 | Interpreters
Compiler Construction | Lecture 14 | Interpreters
 
Compiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code GenerationCompiler Construction | Lecture 13 | Code Generation
Compiler Construction | Lecture 13 | Code Generation
 
Compiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual MachinesCompiler Construction | Lecture 12 | Virtual Machines
Compiler Construction | Lecture 12 | Virtual Machines
 
Compiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone FrameworksCompiler Construction | Lecture 11 | Monotone Frameworks
Compiler Construction | Lecture 11 | Monotone Frameworks
 
Compiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow AnalysisCompiler Construction | Lecture 10 | Data-Flow Analysis
Compiler Construction | Lecture 10 | Data-Flow Analysis
 
Compiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint ResolutionCompiler Construction | Lecture 9 | Constraint Resolution
Compiler Construction | Lecture 9 | Constraint Resolution
 
Compiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type ConstraintsCompiler Construction | Lecture 8 | Type Constraints
Compiler Construction | Lecture 8 | Type Constraints
 
Compiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type CheckingCompiler Construction | Lecture 7 | Type Checking
Compiler Construction | Lecture 7 | Type Checking
 
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term RewritingCompiler Construction | Lecture 5 | Transformation by Term Rewriting
Compiler Construction | Lecture 5 | Transformation by Term Rewriting
 
Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing Compiler Construction | Lecture 4 | Parsing
Compiler Construction | Lecture 4 | Parsing
 

Último

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 

Último (20)

Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 

Software Language Design & Engineering: Mobl & Spoofax

  • 1. Software Language Design & Engineering Eelco Visser http://eelcovisser.org Microsoft Research, Redmond October 20, 2011
  • 2. Software Engineering Problem Machine Domain bridging the gap between problem domain and solution domain
  • 3. High-Level Languages Problem HLL Machine Domain "A programming language is low level when its programs require attention to the irrelevant." Alan J. Perlis (1982) HLLs reduce gap
  • 4. Domain-Specific Languages Problem DSL HLL Machine Domain domain-specific languages support more specialization
  • 5. Software Language Design & Engineering enable software engineers to effectively design, implement, and apply domain-specific software languages
  • 6. Research: Software Language Engineering automatically derive efficient, scalable, incremental compiler + usable IDE from high-level, declarativelanguage definition
  • 7. The Spoofax Language Workbench creating full featured IDEs for domain-specific languages
  • 8. Research: Software Language Design systematically design domain-specific software languages with optimal tradeoff between expressivity, completeness, portability, coverage, and maintainability
  • 9. Software Language Design Case Studies Mobl: client-side stateful web applications WebDSL: server-side restful web applications
  • 10. Two Talks Declaratively Programming the Mobile Web with Mobl The Spoofax Language Workbench
  • 11. Declaratively Programming the Mobile Web with Mobl* Zef Hemel Eelco Visser http://zef.me http://eelcovisser.org * To appear: SPLASH/OOPSLA, October 2011, Portland
  • 12. Divergence in Mobile Platforms Objective-C Java J2ME/C++ HTML/Javascript Java .NET Native Applications not Portable
  • 13. Convergence in Mobile Platform Webkit browser Webkit browser Webkit browser Webkit browser
  • 16. Rich Applications Audio WebDatabases Full-screen support Location information (GPS) Offline support Canvas Accelerator support Multi-touch
  • 17. Native Applications Address book Camera Compass File IO Notifications
  • 18. Software Engineering with JavaScript annotated HTML imperative Javascript MVC, No Integration, No Abstraction, Accidental Complexity
  • 19. Late Failures in Web Applications Zef Hemel, Danny M. Groenewegen, Lennart C. L. Kats, Eelco Visser. Static consistency checking of web applications with WebDSL. Journal of Symbolic Computation, 46(2):150-182, 2011.
  • 20.
  • 21. typed declarative http://www.mobl-lang.org integrated concise
  • 25. tipcalculator.mobl application tipcalculator import mobl::ui::generic screen root() { var amount = 20 var percentage = 10 header("Tip calculator") group { item { numField(amount, label="amount") } item { numField(percentage, label="percentage") } item { "$" label(Math.round(amount * (1 + percentage/100))) } } }
  • 28. Data Model entity Task { name : String (searchable) done : Bool due : DateTime category : Category (inverse: tasks) tags : Collection<Tag> (inverse: tasks) } entity Category { name : String tasks : Collection<Task> (inverse: category) } entity Tag { name : String tasks : Collection<Task> (inverse: tags) } HTML5 Data Persistence
  • 29. Logic entity Task { ... function postpone(days : Num) { this.due = DateTime.create( this.due.getFullYear(), this.due.getMonth(), this.due.getDate() + days); } function import(user : String, pw : String) { var tasksJSON = httpRequest("/export?user="+ user + "&pw=" + pw); foreach(t in tasksJSON) { add(Task.fromSelectJSON(t)); } } } statically typed: catch errors early
  • 30. Reactive User Interfaces screen root() { var phrase = "" header("Tasks") { button("Add", onclick={ addTask(); }) } searchBox(phrase) group { list(t in Task.search(phrase) limit 20){ item { checkBox(t.done, label=t.name) } } } }
  • 31. Navigation screen root() { { addTask() var phrase = "" t = Task() header("Add") { header("Tasks") { button("Done", onclick={ button("Add", onclick={ addTask(); }) } add(t); searchBox(phrase) screen return; group { }) } list(t in Task.search(phrase) limit 20){ textField(t.name) item { datePicker(t.due) checkBox(t.done, label=t.name) } } } } }
  • 32. Continuations screen root() { button("Ask", onclick={ alert("Hello " + prompt("First name") + " " + prompt("Last name")); }) } screen prompt(question : String) : String { var answer = "" header(question) { button("Done", onclick={ screen return answer; }) } textField(answer) }
  • 33. Reusable Controls screen root() { tabSet([("One", tab1), ("Two", tab2)], defaultTab="One") } control tab1() { header("Tab 1") label("This is tab 1") } control tab2() { header("Tab 2") label("This is tab 2") } User Interface Idiom: Tab
  • 34. Tab Set: Higher-Order Control control tabSet(tabs : [(String,Control)], activeTab : String) { list((tabName, tabControl) in tabs) { block(onclick={ activeTab = tabName; }, style=activeTab==tabName ? activeTabButton : inactiveTabButton) { label(tabName) } } list((tabName, tabControl) in tabs) { block(activeTab==tabName ? visibleTab : invisibleTab) { tabControl() } } } increase coverage: developers can create abstractions
  • 35. User Interface Idiom: Master Detail screen root() { header("Tasks") masterDetail( Task.all() order by due desc, taskItem, taskDetail) } control taskItem(t : Task) { checkBox(t.done, label=t.name) } control taskDetail(t : Task) { textField(t.name) datePicker(t.due) }
  • 36. Master Detail: Higher-Order Control control masterDetail(items : Collection<?>, masterItem : Control1<?>, detail : Control1<?>) { group { list(it in items) { item(onclick={ detailScreen(it,detail); }) { masterItem(it) } } } } screen detailScreen(it : ?, detail : Control1<?>) { header("Detail") { backButton() } detail(it) }
  • 43. Mobl Summary ❖ Linguistic integration ★ data model, user interface, styling, application logic ❖ Domain abstractions ★ reduce accidental complexity, platform details ❖ User-defined abstractions ★ data binding ★ reactive programming ★ reusable controls ❖ Model-View ★ automate the controller
  • 44. Mobl IDE: Static Cross-Concern Consistency Checking Constructed on Spoofax Language Workbench
  • 45. The Spoofax Language Workbench* Rules for Declarative Specification of Languages and IDEs Lennart Kats Eelco Visser http://www.lclnet.nl http://eelcovisser.org * OOPSLA 2010
  • 46. Research: Software Language Engineering Automatically derive efficient, scalable, incremental compiler + usable IDE from high-level, declarativelanguage definition
  • 47. Language Definitions for Compilers Syntax definition ★ concrete syntax ★ abstract syntax Static semantics ★ error checking ★ name resolution ★ type analysis Model-to-model transformation ★ express constructs in core language Code generation ★ translate core language models to implementation
  • 48. Editor Services for Modern IDEs Syntactic Editor Services ★ syntax checking ★ bracket matching ★ syntax highlighting ★ code folding ★ outline view Semantic Editor Services ★ error checking ★ reference resolving ★ hover help ★ code completion ★ refactoring
  • 50. Declarative Syntax Definition lexical syntax [a-zA-Z_$][a-zA-Z0-9_]* -> ID context-free syntax STRING -> LimitedSetExp {cons("String")} NUMBER -> LimitedSetExp {cons("Num")} LimitedSetExp -> Exp QId -> LimitedExp {cons("Var")} "(" Exp ")" -> LimitedExp {cons("Brackets")} Exp BoolMethodId Exp -> Exp {cons("BinMethodCall"), left} Exp CompareMethodId Exp -> Exp {cons("BinMethodCall"), left} Exp TermOperatorMethodId Exp -> Exp {cons("BinMethodCall"), left} Exp OperatorMethodId Exp -> Exp {cons("BinMethodCall"), left} character-level grammars: integration of lexical and context-free syntax
  • 51. An Interactive Language Workbench develop and use language in same environment
  • 53. Declarative Disambiguation context-free priorities Exp "." ID -> LimitedExp > Exp "." ID "(" {NamedExp ","}* ")" -> LimitedExp > Exp TermOperatorMethodId Exp -> Exp > Exp OperatorMethodId Exp -> Exp > Exp CompareMethodId Exp -> Exp > Exp BoolMethodId Exp -> Exp > "!" Exp -> Exp > Exp "?" Exp ":" Exp -> Exp > LimitedExp Filter+ -> Exp
  • 55. Natural and Flexible Error Recovery* permissive grammar + backtracking + region discovery [*OOPSLA & SLE 2009]
  • 57. Syntactic Normalization and Desugaring rules normalize : FunctionNoReturnType(manno*, name, farg*, stat*) -> Function(manno*, name, farg*, SimpleType(QId("mobl", "void")), stat*) normalize : IfNoElse(e, block) -> If(e, block, Block([])) desugar : ForInferred(lvalue, e, elem*) -> For(lvalue, t, e, elem*) where GenericType(_, [t]) := <type-of> e
  • 58. CPS Transform cps-lift-exprs : [Return(e)|stats] -> <concat>[stats2, [Return(e2)|<cps-lift-expressions> stats]] where not(<is-sync> e) with {| Exp : stats2 := <cps-lift-expression> e ; e2 := <Exp> |}
  • 59. Type Analysis eq-type-of : String(_) -> SimpleType(QId("mobl", "String")) eq-type-of : FieldAccess(e, x) -> t where Property(_, _, t, _) := <lookup-property> (<type-of> e, x)
  • 60. Type Checking constraint-error : t@SimpleType(_) -> (t, $[Type is not defined: [<pp-mobl-type> t]]) where not(<lookup-type> t) constraint-error : t@FieldAccess(e, x) -> (t, $[Property [x] not defined]) where <type-of> e where not(type-of) origin tracking
  • 61. Semantic Editor Services editor-analyze: (ast, path, project-path) -> (ast2, errors, warnings, notes) with // ... editor-complete-proposal : SimpleType(COMPLETION(_)) -> proposals where all-types := <get-all-types>; proposals := <map(type-name-to-proposal); flatten-list> all-types editor-hover: (t@SimpleType(_), position, ast, path, project-path) -> <get-doc> <lookup-type> t2 where t2 := <lookup-node> (position, ast) editor-resolve: (t@SimpleType(qid), position, ast, path, project-path) -> target where target := <ensure-origin(lookup-type|qid)> t
  • 62. Editor Services Bindings module MoBL-Builders imports MoBL-Builders.generated builders provider : include/mobl.jar observer : editor-analyze on save : generate-artifacts builder : "Show ATerm" = generate-aterm (openeditor) (realtime) (meta) builder : "Format code" = format-code (openeditor) (realtime) builder : "Desugar" = editor-desugar (openeditor) (realtime) (meta) Connect transformations to IDE
  • 63. Integrated Language Definition Testing* Includes testing of the editor services [* OOPSLA 2011]
  • 64. Software Language Design & Engineering Linguistic abstraction: capture software knowledge in domain-specific languages http://spoofax.org separation of concerns + linguistic integration http://mobl-lang.org cross concern consistency checking http://webdsl.org early detection of failures http://researchr.org Language workbench: DSL design and http://eelcovisser.org implementation with less effort than traditional language engineering http://researchr.org/search/publication/mobl+spoofax+webdsl
  • 66. synchronous programming var results = Task.all().list(); for(var i = 0; i < results.length; i++) { alert(results[i].name); }
  • 67. render page time query database and process results ...
  • 68. render page time query database browser freeze and process results ...
  • 69. render page send query time ... process query result ...
  • 70. asynchronous programming Task.all.list(function(results) { for(var i = 0; i < results.length; i++) { alert(results[i].name); } }); ...
  • 71. Task.all().list(function(results) { alert("Hello, "); }); breaks sequential alert("world!"); execution assumption
  • 72. Task.all().list(function(results) { // make changes ... persistence.flush(function() { alert("Changes saved!"); }); });
  • 73. continuation-passing style transformation
  • 74. function displayLocationAndReturn() : Coordinates { var position = mobl::location::getPosition(); log("Lat: " + position.latitude); log("Long: " + position.longitude); return position; } function displayLocationAndReturn(callback) { mobl.location.getPosition(function(position) { console.log("Lat: " + position.latitude); console.log("Long: " + position.longitude); callback(position); }); };
  • 75. function displayLocationAndReturn() : Coordinates { var position = mobl::location::getPosition(); log("Lat: " + position.latitude); log("Long: " + position.longitude); return position; } function displayLocationAndReturn(callback) { mobl.location.getPosition(function(position) { console.log("Lat: " + position.latitude); console.log("Long: " + position.longitude); callback(position); }); };
  • 76. function displayLocationAndReturn() : Coordinates { var position = mobl::location::getPosition(); log("Lat: " + position.latitude); log("Long: " + position.longitude); return position; } function displayLocationAndReturn(callback) { mobl.location.getPosition(function(position) { console.log("Lat: " + position.latitude); console.log("Long: " + position.longitude); callback(position); }); };