SlideShare uma empresa Scribd logo
1 de 70
Kirin:
Single Page Webapps
with a Native UI
James Hugman
I am…

   • @jhugman
   • an engineer at Future Platforms
   • We make apps for clients
   • We’re technology agnostic. i.e. Web,
     Native, Whatever.


@jhugman
There Will Be Code
Kirin is…

   • A Cross Platform Toolkit for building
     mobile apps

   • Write UI in native
   • Write business logic in Javascript
   • Open source
@jhugman
Competition
“So, it’s like …”
PhoneGap



   • a bunch of device APIs
   • a webview to build out your UI


@jhugman
Titanium



   • a bunch of device APIs
   • a native UI built with its own APIs.


@jhugman
Kirin



   • a bunch of device APIs
   • a native UI built with native SDKs.


@jhugman
PhoneGap



   • Easy to start
   • Very lightweight


@jhugman
PhoneGap


   • Hard to finish to a high quality
   • UI unlikely to be good enough
   • UI tends to one-size-fits-all

@jhugman
Titanium



   • Easy to start
   • Uses native widgets


@jhugman
Titanium

   • Designers won’t like:
    • UI APIs are always playing catchup
    • Trust Titanium to make the right
       choices for platform specificity

   • Users won’t like:
    • JS engine per app
@jhugman
Kirin


   • Native SDKs. It may be hard to learn.
   • Very lightweight
   • The whole SDK is there, all the time.
   • Use existing JS Engine.

@jhugman
But seriously, tell us
about Kirin
Architecture of
       Participation

   •   “the nature of systems
       that are designed for
       user contribution”
   •                 Tim O’Reilly, 2004



@jhugman
Design Principles


   • Provide a node.js like environment
   • Bind native objects to Javascript
   • Help teams work together
   • Get out of your way

@jhugman
Design Principles


   • A node.js like environment
   • Bind native objects to Javascript
   • Help teams work together
   • Get out of your way

@jhugman
Common JS modules


   • Arrange your code into files
   • Each “module” has its own variable
     scope

   • require() and exports link
     modules together


@jhugman
Common JS/Modules

  In lib/greeter.js
  exports.greet = function (person) {
     console.log(“Hello ” + person);
  };


  In lib/entry.js
  var greeter = require(“./greeter”);

  greeter.greet(“World”); // prints Hello World to console




@jhugman
npm:
     node.js package manager


   • Distributes your library
   • Manages your dependencies
   • 10,000+ packages available

@jhugman
Installing kirin



  $ npm install kirin




@jhugman
Installing kirin



  $ kirin-create app ~/my-first-app




@jhugman
10k+ packages for kirin




              $ npm search facebook

              $ npm install facebook-graph-client




@jhugman
Design Principles


   • A node.js like environment
   • Bind native objects to Javascript
   • Help teams work together
   • Get out of your way

@jhugman
Platform SDKs & Kirin


   • Anything can Javascript
   • Lifecycles
   • Extensions
   • Threading

@jhugman
Anything can Javascript
A Typical Kirin App
           Native screen

             Javascript
           screen module


             Controller



                           Model   Your app

            Device API


           Device Access
@jhugman
Not just for screens
                                Custom UI
            Screen                                 UI Fragment
                                component

           Javascript           Javascript             Javascript



                   App Delegate              Service


                        Javascript       Javascript



       Javascript API                             Javascript API

                                                 Third Party API +
           Device API
                                                        UI

@jhugman
Consider this JS:



  // called from native screen.
  exports.importantButtonClicked = function (value) {}




@jhugman
Calling Javascript. Part I

  public void onUiButtonClick() {

      mKirinHelper.jsMethod("importantButtonClicked", 42);

  }

  - (IBAction) onUiButtonClick: (id) sender {

      [self.kirinHelper
                jsMethod: @“importantButtonClicked”
                withArgs: [NSNumber numberWithInt:42]
      ];

  }



@jhugman
Lifecycles
Lifecycles, everywhere

   • Android:
     •   onCreate, onStart, onResume,
         onPause, onStop, onDestroy

   • iOS:
     •   viewDidLoad, viewWillAppear,
         viewDidAppear, viewWillDisappear,
         viewDidUnload, dealloc


@jhugman
Lifecycles in Javascript
  var theScreen;

  module.exports = {
    onLoad: function (ui) {
      theScreen = ui;
    },

   onUnload: function () {
     theScreen = null;
   },

   // applicable called at viewWillAppear
   onResume: function () {},

    // called by viewWillDisappear
    onPause: function () {},
  };

@jhugman
Lifecycles with objects
  function MyScreenModule () {
    this.screen = null;
  }
  module.exports = MyScreenModule;

  MyScreenModule.prototype.onLoad = function (ui) {
     this.screen = ui;
  };

  MyScreenModule.prototype.onUnload = function () {
     this.screen = null;
  };

  // applicable called at viewWillAppear
  MyScreenModule.prototype.onResume = function () {};

  // called by viewWillDisappear
  MyScreenModule.prototype. onPause = function () {};

@jhugman
Android Lifecycles


  public class MyScreenActivity extends KirinActivity {
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_my_screen);

           bindScreen("MyScreenModule");

      }
  }




@jhugman
iOS Lifecycles
  #import <KirinKit/KirinKit.h>

  @interface MyViewController : KirinUIViewController
  @end


  @implementation KirinUIViewController

  - (void) viewDidLoad {
     [super viewDidLoad];

      [self bindScreen:@“MyScreenModule”];

  }

  @end

@jhugman
Extensions
Extensions

   • Device access e.g.
     • app-preferences
     • dev-networking-alpha
     • app-databases-alpha
   • May include a UI e.g.:
    • Twitter, Facebook, Address Book
@jhugman
Extension access
     • Exposed only to Javascript
     • Can be written in JS, Native or a
         combination of both

     • May have a full-screen or popover UI
     var prefs = require(“app-preferences”),
         url = prefs.get(“imageServerUrl”);

     // applicable called at viewWillAppear
     prefs.put(“lastSuccessfulPoll”, Date.now());
     •   theScreen
     prefs.commit();


@jhugman
Threading
Transparent threading


   • You don’t have to know this:
    • Extensions run in a thread pool
    • JS engine runs in its own thread
   • Responsive UI Thread.

@jhugman
Design Principles


   • A node.js like environment
   • Bind native objects to Javascript
   • Help teams work together
   • Get out of your way

@jhugman
Conway’s Law


   • “...organizations which design
       systems ... are constrained to produce
       designs which are copies of the
       communication structures of these
       organizations.”
   •                               Melvin Conway 1968




@jhugman
Native devs value:


   • compilers doing work for them
   • IDEs doing work for them
   • build tools doing work for them

@jhugman
Javascript devs value:


   • Rapid prototyping and development
   • Expressive language constructs
   • Garbage collection

@jhugman
Type safe calling of JS
Consider the method:



  // called from native screen.
  exports.importantButtonClicked = function (value) {};




@jhugman
Obj-C calling JS
  @protocol IMyScreenModule <NSObject>

  - (void) importantButtonClicked: (int) value;

  @end

  - (void) viewDidLoad {
     // ...
     self.screenModule =
      [self bindScreen:@"MyScreenModule"
          withProtocol:@protocol(IMyScreenModule)];
     // ...
  }

  - (IBAction) onUiButtonClick: (id) sender {
     [self.screenModule importantButtonClicked: 42];
  }

@jhugman
Android calling JS
  public interface IMyScreenModule {

      void importantButtonClicked(int value);

  }

  public void onCreate(Bundle savedInstanceState) {
      // ...
      mScreenModule = bindScreen("MyScreenModule",
                                 IMyScreenModule.class);
      // ...
  }

  public void onUiButtonClick() {
      mScreenModule.importantButtonClicked(42);
  }



@jhugman
Calling Native. Part II
   In MyScreenModule.js
   var theScreen;
   function updateUi (data) {
     theScreen.displayDataAndEnableUi(data, true);
   }


   In MyScreenViewController.h
   - (void) displayData: (id<IMyScreenRequest>) data
            andEnableUi: (BOOL) flag;


   In MyScreenActivity.java
   public void displayDataAndEnableUi(IMyScreenRequest data,
                                      boolean flag);

@jhugman
Files required for type-
     safety
   • ScreenModule.h protocol
   • ScreenModule.java interface
   • Screen.h protocol
   • Screen.java interface
   • ScreenRequest.java interface
   • ScreenReqest.h protocol
@jhugman
Foreign Function
     Interface
                     calling native


   Implemented By
    Implemented by                        Implemented by
       Javascript
      Javascript                              Native

                     calling javascript




@jhugman
Different implementations


   Implemented by     Implemented by
     Javascript            iOS




@jhugman
Same Shaped API


   Implemented by      Implemented by
     Javascript            Android




@jhugman
“Isomorphic” “bi-layer”


   • Clean interface for JS to talk to
   • Clean interface for native to talk to
   • Everything kept in sync

@jhugman
Bi-layer problems


   • Too many moving parts
    • Easy to break
   • Difficult to document
    • Important for porting

@jhugman
The clean interface
     problem


   • Interacting components:
    • different languages
    • different contexts

@jhugman
Interface Description
     Language

   • Properties! Methods!
   • Human readable and writeable
   • Generate interface.java and
     protocol.h files



@jhugman
Interface Description
     Language
           "IMyScreen": {
               implementedBy: "native",
               methods: {
                   "displayData:andUiEnabled:": [
                       {data: "IMyScreenRequest"},
                       {flag: "boolean"}
                   ]
               }
           },

           "IMyScreenModule": {
               implementedBy: "javascript",
               methods: {
                   "onImportantButtonClick": [
                       {id: "integer"}
                   ]
               }
           },
@jhugman
IDL generates Java…
  public interface IMyScreenModule {

      void importantButtonClicked(int value);

  }
  public interface IMyScreen {

      void displayDataAndUiEnabled(IMyScreenRequest data,
                                   boolean flag);

  }

  public interface IMyScreenRequest {
      String getTitle();

      JSONArray getNames();
  }

@jhugman
IDL generates Obj-C…
  @protocol MyScreenModule <NSObject>

  - (void) importantButtonClicked: (int) value;

  @end
  @protocol IMyScreenModule <NSObject>

  // data is an id<IMyScreenRequest>
  - (void) displayData: (NSDictionary*) data;
          AndUiEnabled: (BOOL) flag;

  @end
  @protocol IMyScreenRequest

  @property(readonly, retain) NSString* title;
  @property(readonly, retain) NSArray* names;

  @end
@jhugman
Little Languages


   • Easily iterable
   • Expressive
   • The right level of abstraction

@jhugman
Design Principles


   • A node.js like environment
   • Bind native objects to Javascript
   • Help teams work together
   • Get out of your way

@jhugman
Get out of your way
How can we help you to
kick ass?
Summary!

   • Native apps with node.js goodness
   • JS apps with Native UI
   • Tools to design APIs between them
   • Tools to design APIs for device
     access


@jhugman
Things we’ve thought of
     to do next


   • Building out extensions
   • Other platforms: Chrome, WP7
   • More IDL, docs

@jhugman
Resources


   • kirinjs.org
   • github.com/kirinjs/kirin
   • cocoacontrols.com
   • Android UI Patterns app

@jhugman
Wait. You want a demo?
Thanks
kirinjs.org
@kirinjs & @jhugman

Mais conteúdo relacionado

Mais procurados

HTML5 Dev Conf 2013 Presentation
HTML5 Dev Conf 2013 PresentationHTML5 Dev Conf 2013 Presentation
HTML5 Dev Conf 2013 PresentationIker Jamardo
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript ApplicationAnis Ahmad
 
What Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsWhat Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsDoris Chen
 
High Performance JavaScript - Fronteers 2010
High Performance JavaScript - Fronteers 2010High Performance JavaScript - Fronteers 2010
High Performance JavaScript - Fronteers 2010Nicholas Zakas
 
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiYukiya Nakagawa
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture Jiby John
 
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Fwdays
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQueryAnil Kumar
 
Builda responsivetypescriptwebdriverio framework
Builda responsivetypescriptwebdriverio frameworkBuilda responsivetypescriptwebdriverio framework
Builda responsivetypescriptwebdriverio frameworkWim Selles
 
Dark side of Android apps modularization
Dark side of Android apps modularizationDark side of Android apps modularization
Dark side of Android apps modularizationDavid Bilík
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular jsAndrew Alpert
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeedYonatan Levin
 
Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)Ariya Hidayat
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in ComponentsFITC
 
Web Components v1
Web Components v1Web Components v1
Web Components v1Mike Wilcox
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015Matt Raible
 
Open social gadgets in ibm connections
Open social gadgets in ibm connectionsOpen social gadgets in ibm connections
Open social gadgets in ibm connectionsVincent Burckhardt
 

Mais procurados (20)

HTML5 Dev Conf 2013 Presentation
HTML5 Dev Conf 2013 PresentationHTML5 Dev Conf 2013 Presentation
HTML5 Dev Conf 2013 Presentation
 
Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
 
Building Large Scale Javascript Application
Building Large Scale Javascript ApplicationBuilding Large Scale Javascript Application
Building Large Scale Javascript Application
 
What Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 AppsWhat Web Developers Need to Know to Develop Windows 8 Apps
What Web Developers Need to Know to Develop Windows 8 Apps
 
High Performance JavaScript - Fronteers 2010
High Performance JavaScript - Fronteers 2010High Performance JavaScript - Fronteers 2010
High Performance JavaScript - Fronteers 2010
 
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigiReact Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
React Nativeはクロスプラットフォームモバイルアプリ開発の夢を見るか #DroidKaigi
 
Mlocjs buzdin
Mlocjs buzdinMlocjs buzdin
Mlocjs buzdin
 
crashing in style
crashing in stylecrashing in style
crashing in style
 
jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture jQquerysummit - Large-scale JavaScript Application Architecture
jQquerysummit - Large-scale JavaScript Application Architecture
 
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
 
Starting with jQuery
Starting with jQueryStarting with jQuery
Starting with jQuery
 
Builda responsivetypescriptwebdriverio framework
Builda responsivetypescriptwebdriverio frameworkBuilda responsivetypescriptwebdriverio framework
Builda responsivetypescriptwebdriverio framework
 
Dark side of Android apps modularization
Dark side of Android apps modularizationDark side of Android apps modularization
Dark side of Android apps modularization
 
Building scalable applications with angular js
Building scalable applications with angular jsBuilding scalable applications with angular js
Building scalable applications with angular js
 
A friend in need - A JS indeed
A friend in need - A JS indeedA friend in need - A JS indeed
A friend in need - A JS indeed
 
Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)Build HTML5 App (Intel Elements 2011)
Build HTML5 App (Intel Elements 2011)
 
Thinking in Components
Thinking in ComponentsThinking in Components
Thinking in Components
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
 
Open social gadgets in ibm connections
Open social gadgets in ibm connectionsOpen social gadgets in ibm connections
Open social gadgets in ibm connections
 

Semelhante a Kirin: Build Native Mobile Apps with Javascript

Make Cross Platform Apps that Suck Less
Make Cross Platform Apps that Suck LessMake Cross Platform Apps that Suck Less
Make Cross Platform Apps that Suck Lessjhugman
 
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and AngularNativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and AngularTodd Anglin
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development FlowRitesh Kumar
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]Sittiphol Phanvilai
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOSfpatton
 
Angular 2 and NativeScript
Angular 2 and NativeScriptAngular 2 and NativeScript
Angular 2 and NativeScriptJen Looper
 
React Native - DILo Surabaya
React Native -  DILo SurabayaReact Native -  DILo Surabaya
React Native - DILo SurabayaDILo Surabaya
 
Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToGlobalLogic Ukraine
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...Matt Spradley
 
Mobile developer is Software developer
Mobile developer is Software developerMobile developer is Software developer
Mobile developer is Software developerEugen Martynov
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648Eing Ong
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentReto Meier
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDXJussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDXJussi Pohjolainen
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsersSergey Shekyan
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump StartHaim Michael
 
Beginning iPhone Development
Beginning iPhone DevelopmentBeginning iPhone Development
Beginning iPhone Developmentsgleadow
 

Semelhante a Kirin: Build Native Mobile Apps with Javascript (20)

Make Cross Platform Apps that Suck Less
Make Cross Platform Apps that Suck LessMake Cross Platform Apps that Suck Less
Make Cross Platform Apps that Suck Less
 
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and AngularNativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
NativeScript: Cross-Platform Mobile Apps with JavaScript and Angular
 
Android class provider in mumbai
Android class provider in mumbaiAndroid class provider in mumbai
Android class provider in mumbai
 
React Native: The Development Flow
React Native: The Development FlowReact Native: The Development Flow
React Native: The Development Flow
 
JavaScript on the Desktop
JavaScript on the DesktopJavaScript on the Desktop
JavaScript on the Desktop
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
 
Intro To webOS
Intro To webOSIntro To webOS
Intro To webOS
 
Angular 2 and NativeScript
Angular 2 and NativeScriptAngular 2 and NativeScript
Angular 2 and NativeScript
 
React Native - DILo Surabaya
React Native -  DILo SurabayaReact Native -  DILo Surabaya
React Native - DILo Surabaya
 
Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How To
 
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
How We Built a Mobile Electronic Health Record App Using Xamarin, Angular, an...
 
Mobile developer is Software developer
Mobile developer is Software developerMobile developer is Software developer
Mobile developer is Software developer
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648
 
Presentation1
Presentation1Presentation1
Presentation1
 
Being Epic: Best Practices for Android Development
Being Epic: Best Practices for Android DevelopmentBeing Epic: Best Practices for Android Development
Being Epic: Best Practices for Android Development
 
Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
Detecting headless browsers
Detecting headless browsersDetecting headless browsers
Detecting headless browsers
 
Android Jump Start
Android Jump StartAndroid Jump Start
Android Jump Start
 
Beginning iPhone Development
Beginning iPhone DevelopmentBeginning iPhone Development
Beginning iPhone Development
 

Último

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
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 Processorsdebabhi2
 
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 WorkerThousandEyes
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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 CVKhem
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

Kirin: Build Native Mobile Apps with Javascript

  • 1. Kirin: Single Page Webapps with a Native UI James Hugman
  • 2. I am… • @jhugman • an engineer at Future Platforms • We make apps for clients • We’re technology agnostic. i.e. Web, Native, Whatever. @jhugman
  • 4. Kirin is… • A Cross Platform Toolkit for building mobile apps • Write UI in native • Write business logic in Javascript • Open source @jhugman
  • 6. PhoneGap • a bunch of device APIs • a webview to build out your UI @jhugman
  • 7. Titanium • a bunch of device APIs • a native UI built with its own APIs. @jhugman
  • 8. Kirin • a bunch of device APIs • a native UI built with native SDKs. @jhugman
  • 9. PhoneGap • Easy to start • Very lightweight @jhugman
  • 10. PhoneGap • Hard to finish to a high quality • UI unlikely to be good enough • UI tends to one-size-fits-all @jhugman
  • 11. Titanium • Easy to start • Uses native widgets @jhugman
  • 12. Titanium • Designers won’t like: • UI APIs are always playing catchup • Trust Titanium to make the right choices for platform specificity • Users won’t like: • JS engine per app @jhugman
  • 13. Kirin • Native SDKs. It may be hard to learn. • Very lightweight • The whole SDK is there, all the time. • Use existing JS Engine. @jhugman
  • 14. But seriously, tell us about Kirin
  • 15. Architecture of Participation • “the nature of systems that are designed for user contribution” • Tim O’Reilly, 2004 @jhugman
  • 16. Design Principles • Provide a node.js like environment • Bind native objects to Javascript • Help teams work together • Get out of your way @jhugman
  • 17. Design Principles • A node.js like environment • Bind native objects to Javascript • Help teams work together • Get out of your way @jhugman
  • 18. Common JS modules • Arrange your code into files • Each “module” has its own variable scope • require() and exports link modules together @jhugman
  • 19. Common JS/Modules In lib/greeter.js exports.greet = function (person) { console.log(“Hello ” + person); }; In lib/entry.js var greeter = require(“./greeter”); greeter.greet(“World”); // prints Hello World to console @jhugman
  • 20. npm: node.js package manager • Distributes your library • Manages your dependencies • 10,000+ packages available @jhugman
  • 21. Installing kirin $ npm install kirin @jhugman
  • 22. Installing kirin $ kirin-create app ~/my-first-app @jhugman
  • 23. 10k+ packages for kirin $ npm search facebook $ npm install facebook-graph-client @jhugman
  • 24. Design Principles • A node.js like environment • Bind native objects to Javascript • Help teams work together • Get out of your way @jhugman
  • 25. Platform SDKs & Kirin • Anything can Javascript • Lifecycles • Extensions • Threading @jhugman
  • 27. A Typical Kirin App Native screen Javascript screen module Controller Model Your app Device API Device Access @jhugman
  • 28. Not just for screens Custom UI Screen UI Fragment component Javascript Javascript Javascript App Delegate Service Javascript Javascript Javascript API Javascript API Third Party API + Device API UI @jhugman
  • 29. Consider this JS: // called from native screen. exports.importantButtonClicked = function (value) {} @jhugman
  • 30. Calling Javascript. Part I public void onUiButtonClick() { mKirinHelper.jsMethod("importantButtonClicked", 42); } - (IBAction) onUiButtonClick: (id) sender { [self.kirinHelper jsMethod: @“importantButtonClicked” withArgs: [NSNumber numberWithInt:42] ]; } @jhugman
  • 32. Lifecycles, everywhere • Android: • onCreate, onStart, onResume, onPause, onStop, onDestroy • iOS: • viewDidLoad, viewWillAppear, viewDidAppear, viewWillDisappear, viewDidUnload, dealloc @jhugman
  • 33. Lifecycles in Javascript var theScreen; module.exports = { onLoad: function (ui) { theScreen = ui; }, onUnload: function () { theScreen = null; }, // applicable called at viewWillAppear onResume: function () {}, // called by viewWillDisappear onPause: function () {}, }; @jhugman
  • 34. Lifecycles with objects function MyScreenModule () { this.screen = null; } module.exports = MyScreenModule; MyScreenModule.prototype.onLoad = function (ui) { this.screen = ui; }; MyScreenModule.prototype.onUnload = function () { this.screen = null; }; // applicable called at viewWillAppear MyScreenModule.prototype.onResume = function () {}; // called by viewWillDisappear MyScreenModule.prototype. onPause = function () {}; @jhugman
  • 35. Android Lifecycles public class MyScreenActivity extends KirinActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_my_screen); bindScreen("MyScreenModule"); } } @jhugman
  • 36. iOS Lifecycles #import <KirinKit/KirinKit.h> @interface MyViewController : KirinUIViewController @end @implementation KirinUIViewController - (void) viewDidLoad { [super viewDidLoad]; [self bindScreen:@“MyScreenModule”]; } @end @jhugman
  • 38. Extensions • Device access e.g. • app-preferences • dev-networking-alpha • app-databases-alpha • May include a UI e.g.: • Twitter, Facebook, Address Book @jhugman
  • 39. Extension access • Exposed only to Javascript • Can be written in JS, Native or a combination of both • May have a full-screen or popover UI var prefs = require(“app-preferences”), url = prefs.get(“imageServerUrl”); // applicable called at viewWillAppear prefs.put(“lastSuccessfulPoll”, Date.now()); • theScreen prefs.commit(); @jhugman
  • 41. Transparent threading • You don’t have to know this: • Extensions run in a thread pool • JS engine runs in its own thread • Responsive UI Thread. @jhugman
  • 42. Design Principles • A node.js like environment • Bind native objects to Javascript • Help teams work together • Get out of your way @jhugman
  • 43. Conway’s Law • “...organizations which design systems ... are constrained to produce designs which are copies of the communication structures of these organizations.” • Melvin Conway 1968 @jhugman
  • 44. Native devs value: • compilers doing work for them • IDEs doing work for them • build tools doing work for them @jhugman
  • 45. Javascript devs value: • Rapid prototyping and development • Expressive language constructs • Garbage collection @jhugman
  • 47. Consider the method: // called from native screen. exports.importantButtonClicked = function (value) {}; @jhugman
  • 48. Obj-C calling JS @protocol IMyScreenModule <NSObject> - (void) importantButtonClicked: (int) value; @end - (void) viewDidLoad { // ... self.screenModule = [self bindScreen:@"MyScreenModule" withProtocol:@protocol(IMyScreenModule)]; // ... } - (IBAction) onUiButtonClick: (id) sender { [self.screenModule importantButtonClicked: 42]; } @jhugman
  • 49. Android calling JS public interface IMyScreenModule { void importantButtonClicked(int value); } public void onCreate(Bundle savedInstanceState) { // ... mScreenModule = bindScreen("MyScreenModule", IMyScreenModule.class); // ... } public void onUiButtonClick() { mScreenModule.importantButtonClicked(42); } @jhugman
  • 50. Calling Native. Part II In MyScreenModule.js var theScreen; function updateUi (data) { theScreen.displayDataAndEnableUi(data, true); } In MyScreenViewController.h - (void) displayData: (id<IMyScreenRequest>) data andEnableUi: (BOOL) flag; In MyScreenActivity.java public void displayDataAndEnableUi(IMyScreenRequest data, boolean flag); @jhugman
  • 51. Files required for type- safety • ScreenModule.h protocol • ScreenModule.java interface • Screen.h protocol • Screen.java interface • ScreenRequest.java interface • ScreenReqest.h protocol @jhugman
  • 52. Foreign Function Interface calling native Implemented By Implemented by Implemented by Javascript Javascript Native calling javascript @jhugman
  • 53. Different implementations Implemented by Implemented by Javascript iOS @jhugman
  • 54. Same Shaped API Implemented by Implemented by Javascript Android @jhugman
  • 55. “Isomorphic” “bi-layer” • Clean interface for JS to talk to • Clean interface for native to talk to • Everything kept in sync @jhugman
  • 56. Bi-layer problems • Too many moving parts • Easy to break • Difficult to document • Important for porting @jhugman
  • 57. The clean interface problem • Interacting components: • different languages • different contexts @jhugman
  • 58. Interface Description Language • Properties! Methods! • Human readable and writeable • Generate interface.java and protocol.h files @jhugman
  • 59. Interface Description Language "IMyScreen": { implementedBy: "native", methods: { "displayData:andUiEnabled:": [ {data: "IMyScreenRequest"}, {flag: "boolean"} ] } }, "IMyScreenModule": { implementedBy: "javascript", methods: { "onImportantButtonClick": [ {id: "integer"} ] } }, @jhugman
  • 60. IDL generates Java… public interface IMyScreenModule { void importantButtonClicked(int value); } public interface IMyScreen { void displayDataAndUiEnabled(IMyScreenRequest data, boolean flag); } public interface IMyScreenRequest { String getTitle(); JSONArray getNames(); } @jhugman
  • 61. IDL generates Obj-C… @protocol MyScreenModule <NSObject> - (void) importantButtonClicked: (int) value; @end @protocol IMyScreenModule <NSObject> // data is an id<IMyScreenRequest> - (void) displayData: (NSDictionary*) data; AndUiEnabled: (BOOL) flag; @end @protocol IMyScreenRequest @property(readonly, retain) NSString* title; @property(readonly, retain) NSArray* names; @end @jhugman
  • 62. Little Languages • Easily iterable • Expressive • The right level of abstraction @jhugman
  • 63. Design Principles • A node.js like environment • Bind native objects to Javascript • Help teams work together • Get out of your way @jhugman
  • 64. Get out of your way
  • 65. How can we help you to kick ass?
  • 66. Summary! • Native apps with node.js goodness • JS apps with Native UI • Tools to design APIs between them • Tools to design APIs for device access @jhugman
  • 67. Things we’ve thought of to do next • Building out extensions • Other platforms: Chrome, WP7 • More IDL, docs @jhugman
  • 68. Resources • kirinjs.org • github.com/kirinjs/kirin • cocoacontrols.com • Android UI Patterns app @jhugman
  • 69. Wait. You want a demo?

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. Any web developer can do it.\n
  10. - Hard to finish, to a high quality (webkit bugs, fragmentation)\n - UI isn&apos;t good enough yet: only imitating native, not performant.\n - UI tends towards one-size-fits all, not platform specific.\n
  11. + Easy to start. You don&apos;t even need CSS or DOM. \n
  12. Catchup: so difficult to style. Your designer won&apos;t like this.\n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n