SlideShare una empresa de Scribd logo
1 de 27
Descargar para leer sin conexión
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.

Más contenido relacionado

La actualidad más candente

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
Anton Arhipov
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracer
rahulrevo
 
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
Anton 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 conventions
walkmod
 

La actualidad más candente (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
 

Similar a Xopus Application Framework

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 Up
David 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 Games
Ray Toal
 
Intro Java Rev010
Intro Java Rev010Intro Java Rev010
Intro Java Rev010
Rich Helton
 
High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2High Performance Ajax Applications 1197671494632682 2
High Performance Ajax Applications 1197671494632682 2
Niti Chotkaew
 

Similar 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

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Último (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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, ...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

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.