Extending Tizen Native Framework with Node.js
-
Upload
trinhkhanh -
Category
Documents
-
view
274 -
download
5
Transcript of Extending Tizen Native Framework with Node.js
Extending
Tizen Native Framework
with Node.js
Nishant Deshpande
Hyunju Shin Ph.D.
Samsung Electronics
2
Native or Web ?
Why JavaScript, Node.js ?
Proposed Architecture
Sample Applications
Going Forward
Contents
4
Performance
Memory
Beautiful Transition
Performance
Memory
Productivity
Developer Pool
Beautiful Transition
Productivity
Developer Pool
Legacy App Legacy App
- + Native or Web
Native Web
8
• Most Popular Programming Language on the Planet
Swift
MatLab
Haskell
Go Scala
R
Shell
Perl
Objective-C
C CSS
Ruby C++
C# Python
PHP
Java
JavaScript
http://stackoverflow.com/research/developer-survey-2015
http://redmonk.com/sogrady/2015/07/01/language-rankings-6-15/
Design Decision - Why JavaScript?
60 65 70 75 80 85 90 95 100 0
60
65
70
75
80
85
90
95
100
Po
pu
larity
ran
k in
Sta
ck o
verflo
w ( #
of T
ag
s)
Top 20 Popularity Rank in GitHub (# of Projects)
9
• Most Desirable technology / language to work with in near future
http://stackoverflow.com/research/developer-survey-2015
Design Decision - Why JavaScript?
17.70%
15.40%
14.80%
14.60%
13.20%
10.50%
9.40%
8.50%
8.50%
8.00%
Android
JavaScript
Python
Node.js
AngularJS
Java
iOS
Raspverry Pi
Swift
C#
Most Desired
11
Design Decision - Why JavaScript?
• Presence everywhere from Web to Enterprise
• Now even in Drones and Robots!
12
• Easy to Develop
JavaScript
• Easy to Extend
Node add-ons
• Lightweight and Fast
Design Principles & Decision
13
Design Decision - Why Node.js?
Event Loop(Single Thread)
Requests
File System
Database
Computation
Trigger Callback
Register Callback
Operation Complete
• Popular JavaScript Runtime
• Event Driven Programming
14
• Popular JavaScript Runtime
• Event Driven Programming
• Very Active Community
• Enterprise Ready
Design Decision - Why Node.js?
http://www.modulecounts.com/
0
20000
40000
60000
80000
100000
120000
140000
160000
180000
200000
2010 2011 2012 2013 2014 2015
# of Packages
nuget (.Net)
PyPI
GoDoc
RubyGems
MavenCtrl(Java)
npm (node.js)
15
Design Decision - Why Node.js?
• Popular JavaScript Runtime
• Event Driven Programming
• Very Active Community
• Enterprise Ready
• Popular framework choice in IOT space
16
• Easy to Develop
JavaScript
• Easy to Extend
Node add-ons
• Lightweight and Fast
JavaScript binding for Native APIs
Design Principles & Decision
Native
C APIs
JS
APIs
18
Tizen Architecture
Native Framework
Native Applications
Linux Kernel & Device Drivers
App Framework
Telephony
Multimedia
Base Security System
Graphics & UI
Web Applications
Tiz
en
Web Framework
Connectivity
Messaging Web PIM
Native API
Web API
Location
Status quo
19
Proposed JavaScript Framework
Native Framework
Native(C or C++)
Applications
Linux Kernel & Device Drivers
App Framework
Telephony
Multimedia
Base Security System
Graphics & UI
Web Applications
Tiz
en
Web Framework
Connectivity
Messaging Web PIM
Native API
Web API
Location
JS Applications
JavaScript Framework
After
20
JavaScript Framework
• Native APIs via Node add-ons
Native Framework
Native Apps
Linux Kernel & Device Drivers
Web Applications
Web Framework
JS Applications
JavaScript
Framework
JS Applications
JavaScript Framework
V8 libuv
Node.js
Node add-ons
Node built-in Tizen Specific 3rd Party
21
Tizen Specific add-ons Tizen Specific add-ons
• Tizen Native Node
• DALi(3D UI Toolkit)
• Lifecycle Manager
• Event Loop Integration(gcontext)
• Logging
Tizen Specific Node add-ons
Tizen Native Node DALi
Lifecycle
Manager Event Integrator Log Utility
JS Applications
JavaScript Framework
V8 libuv
Node.js
Node add-ons
Node built-in Tizen Specific 3rd Party
22
Inside Native Node
• Interface to Native APIs
• Dynamic Plugin Loading
• API Privilege Check
• Native –JS API mapping
Native Node
Native Plugin Loader
Native Plugin- C++
Core Core Module
Native Node add-on
JavaScript API
Native Context
Privilege check
1.
2.
4.
5.
3
6 7
8
24
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
25
BT JS App JS API Plugin loader BT Plugin- C++ Bluetooth Adaptor
callSync()
Native Context
discoverDevices()
createNativePlugin()
Native node
FireEvent() BT_ADAPTOR_DEVICE_DISCOVERY
_STARTED
Load()
OnLoad()
Bluetoothadoptor_discoverDevice()
DiscoverDevices()
DiscoveryStatusChangeCB()
BT_ADAPTOR_DEVICE_DISCOVERY_
FOUND
DiscoveryStatusChangeCB()
BT_ADAPTOR_DEVICE_DISCOVERY_
FINISHED
DeviceDiscoverSuccssCallback()
FireEvent() DeviceDiscoverSuccssCallback()
FireEvent() DeviceDiscoverSuccssCallback()
checkAccess()
JS APP Node add-on Core
Bluetooth – Device Discovery Flow
27
JS application vs. Web application
0
5
10
15
20
25
30
35
JS App Web App
Node.js : 12.8 MB
(MB) (ms)
0
100
200
300
400
500
600
700
800
JS App Web App
Memory comparison Launch Time
29
Roadmap
JS Binding for
all Native APIs
JS framework
Optimization
EFL Integration VM Agnostic
Node
Sample Apps,
Test Harness
SDK support
30
JS Framework in IOT ?
• Deployable to IOT devices
• For resource constrained devices
• Node.js -> IOT.js
• V8-> Jerry Script
31
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