47
JAVASCRIPT? IN MY IOS APP?

JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

JAVASCRIPT? IN MY IOS APP?

Page 2: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

MIKELAZER-WALKER

@LAZERWALKER

Page 3: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and
Page 4: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

JAVASCRIPT? IN MY IOS APP?

Page 5: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

OR, SOMETIMES TO REDUCE COMPLEXITY YOU MUST ADD COMPLEXITY

Page 6: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

1. What the project was2. How it was architected

3. Why JavaScript?

Page 7: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

LOCATION-BASED STORYTELLING

Page 8: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and
Page 9: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

HER LONG-BLACK HAIRHTTPS://PHIFFER.ORG/HLBH/

Page 10: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT'S HARD ABOUT THIS?

Page 11: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT'S HARD ABOUT THIS?

1. Data Sensors!

Page 12: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and
Page 13: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT'S HARD ABOUT THIS?

1. Data Sensors!2. Narrative Models!

Page 14: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

DIRECTED NODE GRAPHE.G. TWINE

Page 15: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

http://aliendovecote.com/uploads/twine/kesha.html

Page 16: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and
Page 17: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

RULE- / EVENT-BASED SYSTEM

E.G. LEFT 4 DEAD 2

Page 18: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and
Page 19: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

"AI-Driven Dynamic Dialog Through Fuzzy Pattern Matching"

http://gdcvault.com/play/1015528/AI-driven-Dynamic-Dialog-through

Page 20: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and
Page 21: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT DID I BUILD?

https://github.com/lazerwalker/storyboardhttps://github.com/lazerwalker/storyboard-ios

Page 22: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

PhoneGap

Page 23: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

PhoneGapReact Native

Page 24: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

JAVASCRIPTCOREINTRODUCED (SORT OF) IN IOS 7

Page 25: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

new Game(content)

Game.start()Game.stop()

Game.addOutput("type", function(content, passageId) { ... });Game.receiveInput("type", "value");

// --

Game.receiveMomentaryInput("type", "value");Game.completePassage(passageId);

Page 26: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

import Foundation

typealias SensorInputBlock = (AnyObject) -> Void

protocol SensorInput { /* As a SensorInput, you should store this callback * and call it whenever your data changes. * * By convention, your implementation of onChange should immediately call * the passed callback with the current/initial value of your sensor. */ var onChange:SensorInputBlock? { get set }

let type:String}

Page 27: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

import Foundationimport CoreMotion

class AltimeterSensor : SensorInput { let type = "altitude"

let altimeter = CMAltimeter()

var onChange:SensorInputBlock?

init() { if let queue = OperationQueue.current { altimeter.startRelativeAltitudeUpdates(to: queue) { (altitudeData, error) -> Void in if let data = altitudeData, let cb = self.onChange { cb(data.relativeAltitude) } } } }}

game.receiveInput("altitude", data.relativeAltitude)

Page 28: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHY?

Page 29: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

SHORT FEEDBACK

LOOPS

Page 30: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

SHORT FEEDBACK LOOPS

1. Test Location-Based Content Without a Device

Page 31: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

SHORT FEEDBACK LOOPS

1. Test Location-Based Content Without a Device2. Test New Content Without A Recompile

Page 32: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

SHORT FEEDBACK LOOPS

1. Test Location-Based Content Without a Device2. Test New Content Without A Recompile

3. Test Core Engine Work Quickly

Page 33: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

CROSS-PLATFORM

1. Production use in non-iOS contexts

Page 34: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and
Page 35: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

CROSS-PLATFORM

1. Run in non-iOS contexts2. Authoring tools

Page 36: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

LANGUAGE FEATURES

1. Dynamism

Page 37: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

{ "nodeId": "4", "passages": [{ "passageId": "6", "type": "speech", "content": "I didn't tell you to go back down!" }], "predicate": { "altitude": { "lte": "graph.previousChoice.predicate.altitude.gte" } }}

Page 38: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

LANGUAGE FEATURES

1. Dynamism2. Community

Page 39: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT SUCKED?

1. JS interop and ES6 was trickier than it should be

Page 40: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

IN PRACTICE

private func addInput(type:String, sensor:SensorInput) { sensor.onChange = { (value) -> Void in self.context.setObject(value, forKeyedSubscript: "input") self.context.setObject(type, forKeyedSubscript: "sensor") self.context.evaluateScript("game.receiveInput(sensor, input)") } }

Page 41: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT SUCKED?

1. JS interop and ES6 was trickier than it should be2. Potential performance issues?

Page 42: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT SUCKED?

1. JS interop and ES6 was trickier than it should be2. Potential performance issues?

3. Swift and Objective-C are pretty nice!

Page 43: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

WHAT SUCKED?

1. JS interop and ES6 was trickier than it should be2. Potential performance issues?

3. Swift and Objective-C are pretty nice!4. Context switching is minorly annoying

Page 44: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

"SO, I SHOULD OBVIOUSLY JUST WRITE EVERYTHING IN JAVASCRIPT, RIGHT?"

Page 45: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

SOMETIMES TO REDUCE COMPLEXITY YOU MUST

ADD COMPLEXITY

Page 46: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

PROGRAMMING LANGUAGES ARE TOOLS"If all you have is truisms about only having a hammer..."

Page 47: JAVASCRIPT? IN MY IOS APP? · Swift and Objective-C are pretty nice! WHAT SUCKED? 1. JS interop and ES6 was trickier than it should be 2. Potential performance issues? 3. Swift and

Thanks!

@lazerwalker