Extending Tizen Native Framework with Node.js Nishant Deshpande Hyunju Shin Ph.D. Samsung Electronics
Contents Native or Web? Why JavaScript, Node.js? Proposed Architecture Sample Applications Going Forward 2
API Choices Native or Web? 3
Native or Web - + Web Native Performance Performance Memory Memory Beautiful Transition Beautiful Transition Productivity Productivity Developer Pool Developer Pool Legacy App Legacy App 4
API Choices Is there any Alternative? 5
Design Principles Easy to Develop Easy to Extend Lightweight and Fast 6
Design Principles & Decision Easy to Develop JavaScript Easy to Extend Lightweight and Fast 7
Design Decision - Why JavaScript? Most Popular Programming Language on the Planet 100 Popularity rank in Stack overflow ( # of Tags) 95 90 85 80 75 70 65 60 Swift Go MatLab Haskell R Scala Shell Perl C# Ruby C CSS Objective-C C++ Java PHP Python JavaScript 0 60 65 70 75 80 85 90 95 100 Top 20 Popularity Rank in GitHub (# of Projects) http://stackoverflow.com/research/developer-survey-2015 http://redmonk.com/sogrady/2015/07/01/language-rankings-6-15/ 8
Design Decision - Why JavaScript? Most Desirable technology / language to work with in near future Most Desired Android JavaScript Python Node.js AngularJS Java ios Raspverry Pi Swift C# 10.50% 9.40% 8.50% 8.50% 8.00% 15.40% 14.80% 14.60% 13.20% 17.70% http://stackoverflow.com/research/developer-survey-2015 9
Design Decision - Why JavaScript? Presence everywhere from Web to Enterprise 10
Design Decision - Why JavaScript? Presence everywhere from Web to Enterprise Now even in Drones and Robots! 11
Design Principles & Decision Easy to Develop JavaScript Easy to Extend Node add-ons Lightweight and Fast 12
Design Decision - Why Node.js? Popular JavaScript Runtime Event Driven Programming Register Callback Requests File System Event Loop (Single Thread) Database Computation Trigger Callback Operation Complete 13
Design Decision - Why Node.js? Popular JavaScript Runtime Event Driven Programming Very Active Community Enterprise Ready # of Packages 200000 180000 160000 140000 120000 100000 80000 60000 40000 20000 0 2010 2011 2012 2013 2014 2015 nuget (.Net) PyPI GoDoc RubyGems MavenCtrl(Java) npm (node.js) http://www.modulecounts.com/ 14
Design Decision - Why Node.js? Popular JavaScript Runtime Event Driven Programming Very Active Community Enterprise Ready Popular framework choice in IOT space 15
Design Principles & Decision Easy to Develop JavaScript Easy to Extend Node add-ons JS APIs Lightweight and Fast JavaScript binding for Native APIs Native C APIs 16
Extending Tizen Proposed Architecture 17
Tizen Architecture Status quo Native Applications Web Applications Web Framework Web API Native API Native Framework Tizen App Framework Graphics & UI Multimedia Messaging PIM Web Security System Base Connectivity Telephony Location Linux Kernel & Device Drivers 18
Proposed JavaScript Framework After JS Applications Web Applications Native(C or C++) Applications JavaScript Framework Web Framework Web API Native API Native Framework Tizen App Framework Graphics & UI Multimedia Messaging PIM Web Security System Base Connectivity Telephony Location Linux Kernel & Device Drivers 19
JavaScript Framework Native APIs via Node add-ons JS Applications JavaScript Framework Node add-ons Node built-in Tizen Specific 3rd Party Node.js V8 libuv Native Apps JS Applications JavaScript Framework Native Framework Web Applications Web Framework Linux Kernel & Device Drivers 20
Tizen Specific add-ons Tizen Native Node DALi(3D UI Toolkit) Tizen Native Node Tizen Specific Node add-ons DALi Lifecycle Manager Lifecycle Manager Event Integrator Log Utility Event Loop Integration(gcontext) Logging JS Applications JavaScript Framework Node add-ons Node built-in Tizen Specific 3rd Party Node.js V8 libuv 21
Inside Native Node JavaScript API Interface to Native APIs Native Node add-on 1. Native Node 8 Dynamic Plugin Loading 2. Native Plugin Loader 3 Native Context API Privilege Check 4. Native Plugin- C++ 5. Native JS API mapping 6 Privilege check 7 Core Core Module 22
JS Apps Sample JS Applications 23
Bluetooth Object Push Scenarios: 1. Bluetooth Activation / Deactivation 2. Bluetooth Device Discovery 3. Device bonding, service connection 4. Object transfer and object receive using Object Push Profile 24
Bluetooth Device Discovery Flow BT JS App JS API Native node Plugin loader Native Context BT Plugin- C++ Bluetooth Adaptor JS APP Node add-on Core discoverdevices() callsync() Load() createnativeplugin() OnLoad() checkaccess() Bluetoothadoptor_discoverDevice() DiscoverDevices() DeviceDiscoverSuccssCallback() FireEvent() DiscoveryStatusChangeCB() BT_ADAPTOR_DEVICE_DISCOVERY _STARTED DeviceDiscoverSuccssCallback() DeviceDiscoverSuccssCallback() FireEvent() FireEvent() DiscoveryStatusChangeCB() BT_ADAPTOR_DEVICE_DISCOVERY_ FOUND BT_ADAPTOR_DEVICE_DISCOVERY_ FINISHED 25
2. DALi JS App - Demo 26
JS application vs. Web application (MB) 35 30 25 Memory comparison (ms) 800 700 600 Launch Time 20 500 15 10 5 0 JS App Web App 400 300 200 100 0 JS App Web App Node.js : 12.8 MB 27
Roadmap Going Forward 28
Roadmap JS Binding for all Native APIs Sample Apps, Test Harness JS framework Optimization EFL Integration SDK support VM Agnostic Node 29
JS Framework in IOT? Deployable to IOT devices For resource constrained devices Node.js -> IOT.js V8-> Jerry Script 30
To Sum up.. Whole Nine Yards of Native Framework to JavaScript Developer Seamless extension to libraries /packages of developer s choice Easier & Faster Application Development More developers contributing to Tizen Eco-System 31
Thank You!
Q & A