titanium: native mobile apps with javascript

26
BUILD NATIVE MOBILE APPS WITH JAVASCRIPT Leo Farias

Upload: leonardo-farias

Post on 12-Apr-2017

1.180 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Titanium: Native Mobile Apps with Javascript

BUILD NATIVE MOBILE APPS WITH JAVASCRIPTLeo Farias

Page 2: Titanium: Native Mobile Apps with Javascript

ABOUT ME

CO-FOUNDERLEO FARIAS

http://about.me/leofarias

Page 3: Titanium: Native Mobile Apps with Javascript

WHAT DO YOU USE TO BUILD MOBILE APPS?

Page 4: Titanium: Native Mobile Apps with Javascript

ATWOOD’S LAW

any application that can be written in JavaScript, will eventually be written in JavaScript.

- Jeff Atwood - 2007 (Stack Overflow & Coding Horror)

The Rule of least Power http://www.w3.org/2001/tag/doc/leastPower.html

Page 5: Titanium: Native Mobile Apps with Javascript

!=

Page 6: Titanium: Native Mobile Apps with Javascript

• Titanium is a platform to build native iOS, Android, and Windows

• Titanium apps are written in Javascript.• Created by Appcelerator • Alloy (MVC Framework) • Open Source

WHAT IS TITANIUM?

Page 7: Titanium: Native Mobile Apps with Javascript

ABSTRACTION LAYER• A way of hiding the implementation details of a

particular set of functionality

• Assertions• There is a core of mobile development APIs which

can be normalized across platforms. These areas should be targeted for code reuse.

• There are platform-specific APIs, UI conventions, and features which developers should incorporate when developing for that platform. Platform-specific code should exist for these use cases to provide the best possible experience.

Page 8: Titanium: Native Mobile Apps with Javascript

Native APIs

Native-JavaScript Bridge (Kroll)

JavaScript runtime (JavaScriptCore, V8)

Application Code - JavaScript

Titanium API, Custom Modules

OS SDK

HOW DOES IT WORK?

Crossing the Bridge

Page 9: Titanium: Native Mobile Apps with Javascript

Native APIs

Native-JavaScript Bridge (Kroll)

JavaScript runtime (JavaScriptCore, V8)

Application Code - JavaScript

Titanium API, Custom Modules

OS SDK

HOW DOES IT WORK?

Crossing the Bridge

Page 10: Titanium: Native Mobile Apps with Javascript

ACCESS NATIVE SDK• Geolocation • Camera • In-App Purchases • Calendar • Contact • Media / Photo Gallery • Gesture / Accelerometer • Maps • Notifications • TouchID / WatchOS • Custom Modules

Page 11: Titanium: Native Mobile Apps with Javascript

DEV ENVIRONMENT

Studio

• Use any IDE with Titanium SDK Node-based CLI • Appcelerator Studio is fully integrated Eclipse-based

IDE with code profiler, debugger and analyzer • iOS Simulator / Genymotion / Devices • LiveView - Allows to see changes near real time in

native platform. TiShadow Open Source Equivalent.

Sublime Text

Page 12: Titanium: Native Mobile Apps with Javascript

MVC FRAMEWORK

View

Model

Controller.xml

.tss

.js

.js

Page 13: Titanium: Native Mobile Apps with Javascript

VIEWS & STYLES

Page 14: Titanium: Native Mobile Apps with Javascript

CONTROLLERS

Page 15: Titanium: Native Mobile Apps with Javascript

MODELS• Inherits from Backbone • Keep models in memory & synced to a store • Easily extend BackboneJS classes • Local storage sync adapters • Migrations • Model-View binding

Page 16: Titanium: Native Mobile Apps with Javascript

BUILT INTO ALLOY• Underscore.js • Moment.js • Common.js Modules* • Widgets • Themes • Free and Open Source

Page 17: Titanium: Native Mobile Apps with Javascript

CODE REUSE• 100% of non-UI code is reusable • 80-85% of UI code (Alloy) is reusable • The more experience, the more code reuse

(experience and patterns)

Page 18: Titanium: Native Mobile Apps with Javascript

ADVANTAGES / PROS• Smaller learning curve for JS Devs • Native Interface Controls • Reduce Maintenance for multiple platform apps • Easier and faster development because of

normalization of APIs and environment. • Community Support • Great Documentation

Page 19: Titanium: Native Mobile Apps with Javascript

NOT WRITE ONCE RUN ANYWHERE!

WRITE ONCE ADAPT ANYWHERE

LEARN ONCE, WRITE ANYWHERE

OR

Page 20: Titanium: Native Mobile Apps with Javascript

DISADVANTAGES / CONS • Not 100% API Coverage • New feature & bug fix delays • Hard to troubleshoot Titanium SDK bugs • Performance?

Page 21: Titanium: Native Mobile Apps with Javascript

PERFORMANCE• JavaScript is not thread safe. • Single threaded execution • Crossing the bridge takes a “toll”. When a

Titanium.* element is called in JS • Follow best practices

Page 22: Titanium: Native Mobile Apps with Javascript

APPCELERATOR PLATFORM• Appcelerator University • Mobile Analytics / Insights • Push Notifications • Arrow (MBaas)

• Arrow Builder (Build APIs) • Arrow Cloud (Elastic cloud service)

• App Preview (AdHoc App Deployments) • App Designer (drag-and-drop UI

Designer for Studio) • Hyperloop

Page 23: Titanium: Native Mobile Apps with Javascript

HYPERLOOP• 100% Native API coverage • Converts JavaScript code into Native code / Compiler • Created to speed up Appcelerator Titanium

Development / 4th Generation • Made available to community as preview (labs) • Use within Titanium

Page 24: Titanium: Native Mobile Apps with Javascript

HYPERLOOPAPPLE TOUCH ID EXAMPLE

Page 25: Titanium: Native Mobile Apps with Javascript

WHAT’S NEXT?• http://www.appcelerator.com/ • http://tidev.io - Titanium Community News Site • http://gitt.io - NPM for Titanium Modules and Widgets • TiSlack - Titanium Slack Community

Page 26: Titanium: Native Mobile Apps with Javascript

THANK YOU! QUESTIONS?

AND SWAG