SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Xopus Application Framework


   Sebastiaan Visser - Xopus B.V.
      sebastiaan@xopus.com




         January 15, 2009
Introduction



   Everyone likes JavaScript!
Introduction



   Everyone likes JavaScript!

   JavaScript is a very popular client-side language because:


       It is a simple language.
       It is a very dynamic language.
       It is very closely tied to the DOM.
Introduction



   Everyone likes JavaScript!

   JavaScript is a very popular client-side language because:


       It is a simple language.
       It is a very dynamic language.
       It is very closely tied to the DOM.
       It is the only thing out there.
Problem observation


   JavaScript is very well-suited for dynamic web pages.

   Xopus is not a web page, but an application.

   We observe some problems with the language:


       There are only functions and objects.
       No modules, classes, name spacing, explicit dependencies, etc.
       No help to structure your program.
       No such thing as ‘idiomatic JavaScript’.
Existing JS Frameworks


  AFLAX AJAX.NET AJAXGear Toolkit AJFORM AjaxAC AjaxRequest
  Ajaxcaller Bajax Behaviour CPaint DOM-Drag Dojo Toolkit
  Engine FlashObject Flexible AJAX JSPkg MochiKit Moo.FX
  Nifty Corners OSFlash Flashjs PAJAJ PEAR:: HTML AJAX Plex
  Toolkit Prototype RSLite Rico SACK SAJAX Sardalya Sarissa
  Scriptaculous Solvent Symfony TOXIC Taconite ThyApi Tibet
  WZ DradDrop WZ jsGraphics XAJAX XHConn XOAD ZK Zephyr
  Zimbra dp.SyntaxHighlighter jQuery jWic libXmlRequest
  moo.ajax overLIB qForms qooxdoo 1




  We focus on program architecture not browser integration.


    1
        from: http://edevil.wordpress.com/2005/11/14/javascript-libraries-roundup/
Solving the problem


   Luckily JavaScript is very dynamic, why not create us a paradigm
   ourselves?

   This presentation describes:


       how we have created an ‘object oriented’ framework.
       how we could keep this framework to be pure JavaScript.
       how this framework can help us structure our programs.
       how Xopus 4 uses this framework.
Framework
  The framework supports:


      Writing modules in an OO ‘extended subset’ of JS.
      Hierarchically structuring programs into packages.
      Some forms of program verification.
      Making dependencies explicit.
      Dependency resolution.
      Consistent file-system layout.
Framework
  The framework supports:


         Writing modules in an OO ‘extended subset’ of JS.
         Hierarchically structuring programs into packages.
         Some forms of program verification.
         Making dependencies explicit.
         Dependency resolution.
         Consistent file-system layout.


  And:


         Server side compilation to flattened form.
         Serving the client efficient and possibly obfuscated code.
         Even more!
Example



  Package(quot;com.xopus.codequot; );

  Import(quot;com.xopus.code.Foodquot; );
  Extends(quot;com.xopus.code.Animalquot; );

  Class(
     function Monkey (name) { this.name = name; },
     function getName () { return this.name; },
     function favorite () { return new Food(quot;bananaquot; ) ; },
     Static, function kind () { return quot;chimpquot; ; }
  );
Example - compiled


  (function (Food,Animal) {

    var Monkey = comxopuscodeMonkey = function Monkey (name) { this.name = name; };
    Monkey.prototype.Monkey = Monkey;
    var Monkey prototype = Monkey.prototype;

    Monkey prototype.getName = function Monkey getName () { return this.name; };
    Monkey prototype.favorite = function Monkey favorite () { return new Food(quot;bananaquot; ); };
    Monkey.kind = function Monkey kind () { return quot;chimpquot; ; };

    for (var method in Monkey.prototype)
       Monkey.prototype[method]. class = Monkey;

    for (var prop in Animal.prototype)
       if (Monkey.prototype[prop])
          Monkey.prototype[Identifier({Animal:1}) + quot;$quot; + prop] = Animal.prototype[prop];
       else
          Monkey.prototype[prop] = Animal.prototype[prop];

  }).apply(this, [comxopuscodeFood,comxopuscodeAnimal]);
Example - construction


   (function (Food,Animal) {

    var Monkey =
    comxopuscodeMonkey =
    function Monkey (name) {
      this.name = name;
    };

    Monkey.prototype.Monkey = Monkey;
    var Monkey prototype = Monkey.prototype;
    ...
   }).apply(this, [comxopuscodeFood,comxopuscodeAnimal]);
Example - methods



   Monkey prototype.getName =
   function Monkey getName () { return this.name; };

   Monkey prototype.favorite =
   function Monkey favorite () { return new Food(quot;bananaquot; ); };

   Monkey.kind = function Monkey kind () { return quot;chimpquot; ; };

   for (var method in Monkey.prototype)
     Monkey.prototype[method]. class = Monkey;
Preserving stacktrace
Example - inheritance




    for (var prop in Animal.prototype)
      if (Monkey.prototype[prop])
        Monkey.prototype[Identifier({Animal:1}) + quot;$quot; + prop] =
        Animal.prototype[prop];
      else
        Monkey.prototype[prop] = Animal.prototype[prop];
Compilation



      Server side compilation (currently) uses SpiderMonkey.
      Compilation entirely written in the JS framework.
      Uses reflection, only possible compile time.
      Compiler extensions for profiling, coverage, dependency
      visualization.
Compilation



      Server side compilation (currently) uses SpiderMonkey.
      Compilation entirely written in the JS framework.
      Uses reflection, only possible compile time.
      Compiler extensions for profiling, coverage, dependency
      visualization.


  http://localhost/xopus/loader/test.html

  console.dir(Loader.modules.map);
Modules



  The framework has support for:


      Fully qualified package names.
      Regular classes.
      Interfaces and abstract classes.
      Methods, put on prototype.
      Constructors, always the first method.
      (mandatory, constructor name defines class name)
Dependencies


  The framework also has support for:


      Implementing interfaces.
      Extending (possibly multiple) other classes.
      Static decoration of other classes.
      Dynamic decoration of instances.


  No full checks on interface implementation yet, should be possible.
Annotations

  Methods can be annotated with additional information:


      Public, Private, Protected, Static.
      Continuation, Test, Deprecated, API.
      Anonymous static functions are special: class constructors.


  Annotations can be used for:


      Documentation.
      Parametrize compilation.
      For runtime reflection.
Unit testing


   Package(quot;com.xopus.test.lang.jsquot; );
   Extends(quot;com.xopus.code.dev.testing.TestCasequot; )
   Tests(quot;com.xopus.code.lang.js.ArrayUtilquot; )
   Class(
      function ArrayUtilTest() { this.TestCase(); },
      Static, function () { new ArrayUtilTest().start(); },
      Test, function last()
      {
        var obj = {};
        var arr = [1, 2, 3, obj];
        this.assertTrue(
          quot;last() should return the last value in the arrayquot;,
          arr.last() === obj);
      }
   );
Demo




        Uses runtime Test annotation.
        Can run entire packages - like com.xopus.*
        Mac mini automatically tests everything.




  http://localhost/xopus/tester/runner/runner.html?modules=com.xopus.test.lang&profiling=true
Conclusion

  Advantages:


      More consistency, more structure
      Framework for abstraction.
      Framework for analyses.
      No runtime overhead.


  Disadvantages:


      Code you debug not the code you write.
      Minor compile-time overhead.
      Requires server side machinery.

Mais conteúdo relacionado

Mais procurados

Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Anton Arhipov
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracerrahulrevo
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
walkmod - JUG talk
walkmod - JUG talkwalkmod - JUG talk
walkmod - JUG talkwalkmod
 
BarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformationsBarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformationswalkmod
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistAnton Arhipov
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Ganesh Samarthyam
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGSylvain Wallez
 
walkmod: how it works
walkmod: how it workswalkmod: how it works
walkmod: how it workswalkmod
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpathAlexis Hassler
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesCharles Nutter
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Anton Arhipov
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript BasicsMindfire Solutions
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Martin Alfke
 
walkmod: quick start
walkmod: quick startwalkmod: quick start
walkmod: quick startwalkmod
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes BackBurke Libbey
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIGanesh Samarthyam
 

Mais procurados (20)

Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
Why Doesn't Java Has Instant Turnaround - Con-FESS 2012
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracer
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
walkmod - JUG talk
walkmod - JUG talkwalkmod - JUG talk
walkmod - JUG talk
 
BarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformationsBarcelonaJUG2016: walkmod: how to run and design code transformations
BarcelonaJUG2016: walkmod: how to run and design code transformations
 
JRuby and You
JRuby and YouJRuby and You
JRuby and You
 
Voxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with JavassistVoxxed Days Vilnius 2015 - Having fun with Javassist
Voxxed Days Vilnius 2015 - Having fun with Javassist
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
walkmod: how it works
walkmod: how it workswalkmod: how it works
walkmod: how it works
 
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw  est prêt à tuer le classpathSoft-Shake 2016 : Jigsaw  est prêt à tuer le classpath
Soft-Shake 2016 : Jigsaw est prêt à tuer le classpath
 
JavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for DummiesJavaOne 2011 - JVM Bytecode for Dummies
JavaOne 2011 - JVM Bytecode for Dummies
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
walkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventionswalkmod: An open source tool for coding conventions
walkmod: An open source tool for coding conventions
 
A Deeper look into Javascript Basics
A Deeper look into Javascript BasicsA Deeper look into Javascript Basics
A Deeper look into Javascript Basics
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?Can you upgrade to Puppet 4.x?
Can you upgrade to Puppet 4.x?
 
walkmod: quick start
walkmod: quick startwalkmod: quick start
walkmod: quick start
 
The Enterprise Strikes Back
The Enterprise Strikes BackThe Enterprise Strikes Back
The Enterprise Strikes Back
 
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time APIModern Programming in Java 8 - Lambdas, Streams and Date Time API
Modern Programming in Java 8 - Lambdas, Streams and Date Time API
 

Semelhante a Xopus Application Framework

Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development toolsSimon Kim
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James NelsonGWTcon
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...Guillaume Laforge
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesRay Toal
 
Building maintainable javascript applications
Building maintainable javascript applicationsBuilding maintainable javascript applications
Building maintainable javascript applicationsequisodie
 
Java programming basics
Java programming basicsJava programming basics
Java programming basicsHamid Ghorbani
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010Rich Helton
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptRohan Chandane
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT studentsPartnered Health
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2Niti Chotkaew
 

Semelhante a Xopus Application Framework (20)

Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
A few good JavaScript development tools
A few good JavaScript development toolsA few good JavaScript development tools
A few good JavaScript development tools
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
 
"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson"Xapi-lang For declarative code generation" By James Nelson
"Xapi-lang For declarative code generation" By James Nelson
 
Java
JavaJava
Java
 
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Modeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based GamesModeling Patterns for JavaScript Browser-Based Games
Modeling Patterns for JavaScript Browser-Based Games
 
React native
React nativeReact native
React native
 
[2015/2016] JavaScript
[2015/2016] JavaScript[2015/2016] JavaScript
[2015/2016] JavaScript
 
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad PečanacJavantura v3 - ES6 – Future Is Now – Nenad Pečanac
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
 
Building maintainable javascript applications
Building maintainable javascript applicationsBuilding maintainable javascript applications
Building maintainable javascript applications
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
 
Sencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScriptSencha / ExtJS : Object Oriented JavaScript
Sencha / ExtJS : Object Oriented JavaScript
 
ES6 - JavaCro 2016
ES6 - JavaCro 2016ES6 - JavaCro 2016
ES6 - JavaCro 2016
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 

Xopus Application Framework

  • 1. Xopus Application Framework Sebastiaan Visser - Xopus B.V. sebastiaan@xopus.com January 15, 2009
  • 2. Introduction Everyone likes JavaScript!
  • 3. Introduction Everyone likes JavaScript! JavaScript is a very popular client-side language because: It is a simple language. It is a very dynamic language. It is very closely tied to the DOM.
  • 4. Introduction Everyone likes JavaScript! JavaScript is a very popular client-side language because: It is a simple language. It is a very dynamic language. It is very closely tied to the DOM. It is the only thing out there.
  • 5. Problem observation JavaScript is very well-suited for dynamic web pages. Xopus is not a web page, but an application. We observe some problems with the language: There are only functions and objects. No modules, classes, name spacing, explicit dependencies, etc. No help to structure your program. No such thing as ‘idiomatic JavaScript’.
  • 6. Existing JS Frameworks AFLAX AJAX.NET AJAXGear Toolkit AJFORM AjaxAC AjaxRequest Ajaxcaller Bajax Behaviour CPaint DOM-Drag Dojo Toolkit Engine FlashObject Flexible AJAX JSPkg MochiKit Moo.FX Nifty Corners OSFlash Flashjs PAJAJ PEAR:: HTML AJAX Plex Toolkit Prototype RSLite Rico SACK SAJAX Sardalya Sarissa Scriptaculous Solvent Symfony TOXIC Taconite ThyApi Tibet WZ DradDrop WZ jsGraphics XAJAX XHConn XOAD ZK Zephyr Zimbra dp.SyntaxHighlighter jQuery jWic libXmlRequest moo.ajax overLIB qForms qooxdoo 1 We focus on program architecture not browser integration. 1 from: http://edevil.wordpress.com/2005/11/14/javascript-libraries-roundup/
  • 7. Solving the problem Luckily JavaScript is very dynamic, why not create us a paradigm ourselves? This presentation describes: how we have created an ‘object oriented’ framework. how we could keep this framework to be pure JavaScript. how this framework can help us structure our programs. how Xopus 4 uses this framework.
  • 8. Framework The framework supports: Writing modules in an OO ‘extended subset’ of JS. Hierarchically structuring programs into packages. Some forms of program verification. Making dependencies explicit. Dependency resolution. Consistent file-system layout.
  • 9. Framework The framework supports: Writing modules in an OO ‘extended subset’ of JS. Hierarchically structuring programs into packages. Some forms of program verification. Making dependencies explicit. Dependency resolution. Consistent file-system layout. And: Server side compilation to flattened form. Serving the client efficient and possibly obfuscated code. Even more!
  • 10. Example Package(quot;com.xopus.codequot; ); Import(quot;com.xopus.code.Foodquot; ); Extends(quot;com.xopus.code.Animalquot; ); Class( function Monkey (name) { this.name = name; }, function getName () { return this.name; }, function favorite () { return new Food(quot;bananaquot; ) ; }, Static, function kind () { return quot;chimpquot; ; } );
  • 11. Example - compiled (function (Food,Animal) { var Monkey = comxopuscodeMonkey = function Monkey (name) { this.name = name; }; Monkey.prototype.Monkey = Monkey; var Monkey prototype = Monkey.prototype; Monkey prototype.getName = function Monkey getName () { return this.name; }; Monkey prototype.favorite = function Monkey favorite () { return new Food(quot;bananaquot; ); }; Monkey.kind = function Monkey kind () { return quot;chimpquot; ; }; for (var method in Monkey.prototype) Monkey.prototype[method]. class = Monkey; for (var prop in Animal.prototype) if (Monkey.prototype[prop]) Monkey.prototype[Identifier({Animal:1}) + quot;$quot; + prop] = Animal.prototype[prop]; else Monkey.prototype[prop] = Animal.prototype[prop]; }).apply(this, [comxopuscodeFood,comxopuscodeAnimal]);
  • 12. Example - construction (function (Food,Animal) { var Monkey = comxopuscodeMonkey = function Monkey (name) { this.name = name; }; Monkey.prototype.Monkey = Monkey; var Monkey prototype = Monkey.prototype; ... }).apply(this, [comxopuscodeFood,comxopuscodeAnimal]);
  • 13. Example - methods Monkey prototype.getName = function Monkey getName () { return this.name; }; Monkey prototype.favorite = function Monkey favorite () { return new Food(quot;bananaquot; ); }; Monkey.kind = function Monkey kind () { return quot;chimpquot; ; }; for (var method in Monkey.prototype) Monkey.prototype[method]. class = Monkey;
  • 15. Example - inheritance for (var prop in Animal.prototype) if (Monkey.prototype[prop]) Monkey.prototype[Identifier({Animal:1}) + quot;$quot; + prop] = Animal.prototype[prop]; else Monkey.prototype[prop] = Animal.prototype[prop];
  • 16. Compilation Server side compilation (currently) uses SpiderMonkey. Compilation entirely written in the JS framework. Uses reflection, only possible compile time. Compiler extensions for profiling, coverage, dependency visualization.
  • 17. Compilation Server side compilation (currently) uses SpiderMonkey. Compilation entirely written in the JS framework. Uses reflection, only possible compile time. Compiler extensions for profiling, coverage, dependency visualization. http://localhost/xopus/loader/test.html console.dir(Loader.modules.map);
  • 18.
  • 19. Modules The framework has support for: Fully qualified package names. Regular classes. Interfaces and abstract classes. Methods, put on prototype. Constructors, always the first method. (mandatory, constructor name defines class name)
  • 20.
  • 21. Dependencies The framework also has support for: Implementing interfaces. Extending (possibly multiple) other classes. Static decoration of other classes. Dynamic decoration of instances. No full checks on interface implementation yet, should be possible.
  • 22. Annotations Methods can be annotated with additional information: Public, Private, Protected, Static. Continuation, Test, Deprecated, API. Anonymous static functions are special: class constructors. Annotations can be used for: Documentation. Parametrize compilation. For runtime reflection.
  • 23. Unit testing Package(quot;com.xopus.test.lang.jsquot; ); Extends(quot;com.xopus.code.dev.testing.TestCasequot; ) Tests(quot;com.xopus.code.lang.js.ArrayUtilquot; ) Class( function ArrayUtilTest() { this.TestCase(); }, Static, function () { new ArrayUtilTest().start(); }, Test, function last() { var obj = {}; var arr = [1, 2, 3, obj]; this.assertTrue( quot;last() should return the last value in the arrayquot;, arr.last() === obj); } );
  • 24.
  • 25. Demo Uses runtime Test annotation. Can run entire packages - like com.xopus.* Mac mini automatically tests everything. http://localhost/xopus/tester/runner/runner.html?modules=com.xopus.test.lang&profiling=true
  • 26.
  • 27. Conclusion Advantages: More consistency, more structure Framework for abstraction. Framework for analyses. No runtime overhead. Disadvantages: Code you debug not the code you write. Minor compile-time overhead. Requires server side machinery.