91
HTML5 Can’t Do That Surveying the Mobile Landscape Matt Baxter UX Designer Nathan Smith Principal UI Architect

HTML5 Can't Do That

Embed Size (px)

DESCRIPTION

Slides from a presentation I gave at these conferences: — Big Design — Front Porch — Thunder Plains — Web Afternoon I co-presented at Big Design with Matt Baxter. http://twitter.com/mbxtr

Citation preview

Page 4: HTML5 Can't Do That

I BUILD THE LEGACYAPPS OF TOMORROW!

In all honesty…

And hey, so do you. We’re creating software UI in adocument language. It’s a wonder anything works.

Page 6: HTML5 Can't Do That

NON-SCIENTIFIC SURVEY:

What is the most frequentlyused app on your phone?

(Ironically, probably not the “phone” app.)

Page 7: HTML5 Can't Do That
Page 9: HTML5 Can't Do That

NON-SCIENTIFIC SURVEY:

What is the most frequentlyused app on your computer?

Page 11: HTML5 Can't Do That
Page 12: HTML5 Can't Do That
Page 13: HTML5 Can't Do That

This is what the Web would look like if there were no native apps.

The browser is arguably the most important native app.

Page 14: HTML5 Can't Do That

Actually, this(No browser UI)

Page 15: HTML5 Can't Do That

Or, how would things lookif native “beat” the Web?

Page 16: HTML5 Can't Do That
Page 17: HTML5 Can't Do That
Page 18: HTML5 Can't Do That

…asked the headline, on a sitewith an HTML5 doctype.

Page 20: HTML5 Can't Do That
Page 21: HTML5 Can't Do That

Can’t we all just get along?

Page 22: HTML5 Can't Do That
Page 23: HTML5 Can't Do That

Firefox can run the Unrealgame engine in native JS!

Okay, so it’s not mobile.But it’s still cool, right?

Page 24: HTML5 Can't Do That
Page 26: HTML5 Can't Do That

http://finance.yahoo.com/q/is?s=amzn+income+statement&annual

Fun Fact:

Amazon’s revenue is roughly $167,378,082 per day.*

*61B total revenue in 2012. After operating expensesof 45.9B, that’s a gross profit of approximately 15.1B.

Page 27: HTML5 Can't Do That

So, at the very least…

HTML5 is what you use to buy things that don’t run in HTML5.

Page 30: HTML5 Can't Do That

How we see the mobile landscape…

Business Logic and Data Aggregation

Approaches to Mobile Development

TitaniumJavaScript API

Android, iOS

XamarinCross-platform C# API

Android, iOS,Windows Phone

NativeC#, Java, or Objective-C

Android, Blackberry, iOS,Windows Phone, etc.

PhoneGapHTML, CSS, JS

Android, Blackberry, iOS,Windows Phone, etc.

Responsive or Mobile Web App

Multiple OS (browsers)

Application Services API — JSON to/from XML, etc.

AS/400 SQL ServerOracle PostgreSQL

Web Development Native Development

Java .NET PHP Python Ruby

or or or or

MySQL

Node.js

Page 32: HTML5 Can't Do That

https://en.wikipedia.org/wiki/Uncanny_valley

In case you are unfamiliar with the term “uncanny valley”

The uncanny valley is a hypothesis in

the field of human aesthetics which

holds that when human app features

look and move almost, but not

exactly, like natural human beings

native apps, it causes a response of

revulsion among human observers.

Page 33: HTML5 Can't Do That
Page 34: HTML5 Can't Do That

Let’s talk about

PhoneGap

Page 35: HTML5 Can't Do That
Page 36: HTML5 Can't Do That

http://phonegap.com

How PhoneGap Works

— It embeds a WebView in a native app

— Native app gives access to OS API’s

— All the UI is built via HTML/CSS

— JavaScript handles everything else

— The app wrapper compiles via…

Xcode, Eclipse, Visual Studio, or“the cloud” ⇒ build.phonegap.com

Page 40: HTML5 Can't Do That
Page 41: HTML5 Can't Do That

“Topcoat is a brand new open source CSS library designed to help developers build web apps with an emphasis on speed. It evolved from the Adobe design language developed for Brackets, Edge Reflow, and feedback from the PhoneGap app developer community.”

— Brian LeRoux

Page 42: HTML5 Can't Do That
Page 43: HTML5 Can't Do That
Page 45: HTML5 Can't Do That

Let’s talk about

Titanium

Page 46: HTML5 Can't Do That
Page 47: HTML5 Can't Do That

http://appcelerator.com/titanium

Benefits of Titanium

— Native UI (not necessarily look & feel)

— Code organization: Alloy MVC approach

— Views are XML, JS for Models/Controllers

— Build for iOS, Android, and Blackberry

— Some code reuse across platforms

— Entirely JavaScript based

— Uses CommonJS’s AMD approach

— Except for WebView (+HTML/CSS)

Page 48: HTML5 Can't Do That

http://appcelerator.com/titanium

Drawbacks of Titanium

— Slow apps… I end up using WebViews

— Workflow: code, compile, rinse, repeat

— It’s XML/JS, but no DOM traversal

— No first-party way to test your code

— Regression testing is difficult

— Added file size, due to Ti framework

— Non-transferrable support license

— Can’t hand off to a coworker

Page 49: HTML5 Can't Do That

Abstraction layers tend to be harder to debug than “native” languages: C#, Objective-C, or Java — when using an IDE such as Visual Studio, Xcode, Eclipse, or Android Studio.

With “the web,” you have familiar developer tools, built into all major browsers.

Page 50: HTML5 Can't Do That

Let’s talk about

Xamarin

Page 51: HTML5 Can't Do That
Page 52: HTML5 Can't Do That

http://xamarin.com

Benefits of Xamarin

— Speed… It compiles to native code

— 1:1 mapping of native API’s to C#

— Code reuse: Android, iOS, Windows

— Visual IDE, lets designers see the UI

— Big-name apps use it (Rdio, anyone?)

— Transferrable support license

Page 53: HTML5 Can't Do That
Page 55: HTML5 Can't Do That

Let’s talk about

“Native”

Page 56: HTML5 Can't Do That

http://developer.android.com — http://developer.apple.com — http://developer.windowsphone.com

Developer Sites for Various Platforms

Page 57: HTML5 Can't Do That

http://developer.android.com — http://developer.apple.com — http://developer.windowsphone.com

Benefits of Native Development

— Default OS look & feel (UI conventions)

— Performance (“closer to the metal”)

— Access to device hardware (GPS, etc)

— Benefit from latest OS enhancements

— Able to hire specialists in that area

Page 58: HTML5 Can't Do That

http://developer.android.com — http://developer.apple.com — http://developer.windowsphone.com

Drawbacks of Native Development

— Tied to the particular OS you built for

— Maintaining a multi OS team/skill-set

— Keeping app in sync with OS updates

— Having multiple devices for testing

Page 59: HTML5 Can't Do That

Let’s talk about

The Web(This applies to PhoneGap, too)

Page 60: HTML5 Can't Do That

wtfmobileweb.tumblr.com

Page 63: HTML5 Can't Do That
Page 64: HTML5 Can't Do That

http://www.dafont.com/idautomationhc39m.font

A serendipitous use of HTML5

HTML5 Cant Do ThatLast year, we were anticipating writing a lot of JavaScript to generate a barcode for a mobile app. To my surprise, I found a barcode font: “IDAutomationHC39M.” What would’ve taken days was mere minutes, adjusting font-size.

Page 65: HTML5 Can't Do That

But what about JavaScript? — Glad you asked! :)

Helpful utility libraries:

— jQuery or Zepto¬ jquery.com¬ zeptojs.com

— Underscore or LoDash¬ underscorejs.org¬ lodash.com

— Handlebars¬ handlebarsjs.com

Page 66: HTML5 Can't Do That

*MVC: Model, View, Controller — MVVM: Model, View, View Model, etc.

There are also plenty of JavaScript MV* Frameworks

— Angular¬ angularjs.org

— Backbone¬ backbonejs.org

— Ember¬ emberjs.com

— Knockout& Durandal¬ knockoutjs.com¬ durandaljs.com

We’ve  begun  using  this

>

Page 68: HTML5 Can't Do That

And now, justa few caveats

Page 69: HTML5 Can't Do That
Page 71: HTML5 Can't Do That
Page 74: HTML5 Can't Do That

How we see the mobile landscape (revised)…

Business Logic and Data Aggregation

Approaches to Mobile Development

TitaniumJavaScript API

Android, iOS

XamarinCross-platform C# API

Android, iOS,Windows Phone

NativeC#, Java, or Objective-C

Android, Blackberry, iOS,Windows Phone, etc.

PhoneGapHTML, CSS, JS

Android, Blackberry, iOS,Windows Phone, etc.

Responsive or Mobile Web App

Multiple OS (browsers)

Application Services API — JSON to/from XML, etc.

AS/400 SQL ServerOracle PostgreSQL

Web Development Native Development

Java .NET PHP Python Ruby

or or or or

MySQL

Node.js

XUncanny  valley

Page 76: HTML5 Can't Do That

Why Durandal& Knockout?

Page 77: HTML5 Can't Do That

WWWW WVV

Page 78: HTML5 Can't Do That

http://knockoutjs.com

Highlights of Knockout.js

— Model, View, View Model (MVVM)

— Two-way data binding

— If user interacts with page, you can

— reflect these changes in your data

— Declarative UI: in markup, not in JS

— Observables: If data changes, UI updates

Page 80: HTML5 Can't Do That

http://durandaljs.com

Highlights of Durandal.js

— Built on KO, picks up where it left off

— Routing: based on changes to URL

— View/state change transitions

— Async data fetching, with Promises

— Manage code modules with Require.js

— Enforces consistent code structure

Page 82: HTML5 Can't Do That

DEMOhttp://github.com/nathansmith/ko-table

Page 83: HTML5 Can't Do That
Page 84: HTML5 Can't Do That

Below a certain width,

the layout switches

to a “mobile” view.

The table rows & cells

are display:block, and

text from each <th>

is inserted as a label,

preceding the data.

Page 85: HTML5 Can't Do That

<thead> <tr> <th scope="col" data-key="first_name"> <div class="cell"> <a href="#">First Name</a> </div> </th> <th scope="col" data-key="last_name"> <div class="cell"> <a href="#">Last Name</a> </div> </th> <th scope="col" data-key="character_first_name"> <div class="cell"> <a href="#">Character First Name</a> </div> </th> <th scope="col" data-key="character_last_name"> <div class="cell"> <a href="#">Character Last Name</a> </div> </th> </tr></thead>

Page 86: HTML5 Can't Do That

<tbody data-bind="foreach: data"> <tr> <td data-th="First Name:"> <span data-bind="text: first_name || '&mdash;'"></span> </td> <td data-th="Last Name:"> <span data-bind="text: last_name || '&mdash;'"></span> </td> <td data-th="Character First Name:"> <span data-bind="text: character_first_name || '&mdash;'"></span> </td> <td data-th="Character Last Name:"> <span data-bind="text: character_last_name || '&mdash;'"></span> </td> </tr></tbody>

Page 87: HTML5 Can't Do That

// In a real app, this data would potentially be dynamic.// But for the purposes of this demo, is hard-coded here.

[ { "first_name": "Amy", "last_name": "Poehler", "character_first_name": "Leslie", "character_last_name": "Knope" }, { "first_name": "Nick", "last_name": "Offerman", "character_first_name": "Ron", "character_last_name": "Swanson" }, { "first_name": "Aziz", "last_name": "Ansari", "character_first_name": "Tom", "character_last_name": "Haverford" },

...]

Page 88: HTML5 Can't Do That

// Extend KO array, to make it sortableko.observableArray.fn.sort_by = function(key, reverse) { var self = this;

self.sort(function(a, b) { var a_key = String(a[key]); var b_key = String(b[key]); var n, val;

if (reverse) { n = a_key - b_key; val = !isNaN(n) ? n : b_key.localeCompare(a_key); } else { n = b_key - a_key; val = !isNaN(n) ? n : a_key.localeCompare(b_key); }

return val; });};

Page 89: HTML5 Can't Do That

// APP.modelsmodels: { // APP.models.table_view_model table_view_model: function() { var self = this;

// This data comes from "/json/data.js" APP.data = APP.data || ko.observableArray(DATA_JSON); self.data = APP.data; }},...

Page 90: HTML5 Can't Do That

// APP.init.sort_bysort_by: function(key) { var event = 'click.sort_by'; var str = '.table-data th[data-key] a';

body.off(event).on(event, str, function(ev) { var el = $(this); var th = el.closest('th'); var th_other = th.siblings('th'); var key = th.attr('data-key'); var sort = th.attr('data-sort'); var asc = 'ascending'; var desc = 'descending'; var dir = asc;

if (!sort || sort === asc) { dir = desc; }

var reverse = dir !== asc;

th.addClass(on).attr('data-sort', dir); th_other.removeClass(on).removeAttr('data-sort'); APP.data.sort_by(key, reverse); });},