80

SproutCore and the Future of Web Apps

Embed Size (px)

DESCRIPTION

Mike Subelsky of OtherInbox.com discusses the SproutCore JavaScript framework for building desktop web applications that run inside the browser.

Citation preview

Page 1: SproutCore and the Future of Web Apps
Page 2: SproutCore and the Future of Web Apps

2.0

Page 3: SproutCore and the Future of Web Apps

2.03F

Page 4: SproutCore and the Future of Web Apps

Future of Web AppsFast, fluid, and feature-rich

Page 5: SproutCore and the Future of Web Apps

Future of Web AppsLess web, more app

Page 6: SproutCore and the Future of Web Apps

Future of Web AppsProbably client-server

Page 7: SproutCore and the Future of Web Apps

Future of Web AppsWeb-native, no plugins

Page 8: SproutCore and the Future of Web Apps

Future of Web AppsOpen source

Page 9: SproutCore and the Future of Web Apps

Building 3F Apps with SproutCore

Mike SubelskyOtherInbox.com

IgniteBaltimore.com

Page 10: SproutCore and the Future of Web Apps
Page 11: SproutCore and the Future of Web Apps

Use SproutCore to build web clientsthat feel like desktop apps

Page 12: SproutCore and the Future of Web Apps

Use whatever you want to build the server

Page 13: SproutCore and the Future of Web Apps

Not a competitor or replacementof jQuery, Prototype, etc.

Page 14: SproutCore and the Future of Web Apps
Page 15: SproutCore and the Future of Web Apps

Not a competitor or replacement

of jQuery, Prototype, etc.

Page 16: SproutCore and the Future of Web Apps

Why client-server?

Page 17: SproutCore and the Future of Web Apps

Users Want More

Page 18: SproutCore and the Future of Web Apps
Page 19: SproutCore and the Future of Web Apps
Page 20: SproutCore and the Future of Web Apps
Page 21: SproutCore and the Future of Web Apps
Page 22: SproutCore and the Future of Web Apps
Page 23: SproutCore and the Future of Web Apps

Impossible with “traditional” web 2.0

techniques

Page 24: SproutCore and the Future of Web Apps

remove_messages: function(message_ids,block) { OtherInbox.undo_stack.push(new UndoAction(message_ids,Mailbox.current_id,block)) $('undo').writeAttribute('disabled',null)

var affected_mailboxes = $H() var highest_position = null var msg_count = 0 message_ids.each(function(id) { $('msg_row_' + id).remove() var msg = Message.instances.unset(id) var position = Message.ordered_instance_keys.indexOf(Number(id)) Message.ordered_instance_keys.splice(position,1)

if ((highest_position == null) || (highest_position < position)) highest_position = position msg_count++ })

Mailbox.update_message_count(msg_count)

Page 25: SproutCore and the Future of Web Apps
Page 26: SproutCore and the Future of Web Apps
Page 27: SproutCore and the Future of Web Apps

3F Means You Need Client-Server

Page 28: SproutCore and the Future of Web Apps

OI.executeAjax('/refresh', { method: 'get', parameters: parameters, onSuccess: function(transport) { OI._parseRefresh(transport);

}});

removeMessages: function(msgs) { SC.Store.destroyRecords(msgs);};

Page 29: SproutCore and the Future of Web Apps

class RefreshController < ApplicationController before_filter :signin_required

def index render :text => JSON.generate(Refresher.new(params).to_hash) end

end

Page 30: SproutCore and the Future of Web Apps

{"recordTypes":["Mailbox","User","Folder"],"deleted":{},"flash":[],"changed":{"User":[{"name":"forfun","preferences":null,"guid":3,"type":"User","admin":true,"invitationsRemaining":1,"login":"testuser","state":"completed"}],

"created":{"Mailbox" [{"name":"Freeslide","unreadCount":null,"guid":"12","folder":"3","priority":"2","type": "Mailbox"}]}}}

Page 31: SproutCore and the Future of Web Apps
Page 32: SproutCore and the Future of Web Apps
Page 33: SproutCore and the Future of Web Apps

HTM

L

CSSJavaScript

Flash

Page 34: SproutCore and the Future of Web Apps

3F Means You Need To Think Like a

Desktop Developer

Page 35: SproutCore and the Future of Web Apps
Page 36: SproutCore and the Future of Web Apps

Kill me now

Page 37: SproutCore and the Future of Web Apps

- Charles Jolley

“...writing an app in Javascript on the web is akin to writing C on the desktop: it is just one level above the 'bare metal’.”

Page 38: SproutCore and the Future of Web Apps

SproutCore does 80%(just like Rails)

Page 39: SproutCore and the Future of Web Apps

Feels a bit like Rails

Page 40: SproutCore and the Future of Web Apps

Feels a bit like RailsConvention over configuration

Page 41: SproutCore and the Future of Web Apps

Feels a bit like RailsConfiguring components

Page 42: SproutCore and the Future of Web Apps

Feels a bit like RailsUses Ruby helpers and ERB or Haml

Page 43: SproutCore and the Future of Web Apps

Except totally different

Page 44: SproutCore and the Future of Web Apps

Except totally different

Inspired by Cocoa

Page 45: SproutCore and the Future of Web Apps

Except totally different

More functionally-oriented (little or no state)

Page 46: SproutCore and the Future of Web Apps

Except totally different

Everything is a binding

Page 47: SproutCore and the Future of Web Apps

Except totally different

Trust but verifyif (foo && foo.get(‘importantValue’))

Page 48: SproutCore and the Future of Web Apps

Except totally different

By all means, repeat yourself

Page 49: SproutCore and the Future of Web Apps

Except totally differentJavaScript is awesome

(just avoid the bad parts)

Page 50: SproutCore and the Future of Web Apps

Except totally different

MVC !== MVC

Page 51: SproutCore and the Future of Web Apps

What does it look like?

Page 52: SproutCore and the Future of Web Apps
Page 53: SproutCore and the Future of Web Apps

sc-configclients

Page 54: SproutCore and the Future of Web Apps

sc-config c[:build_mode] = :production c[:minify_javascript] = :production c[:combine_javascript] = :production c[:combine_stylesheets] = :production c[:include_fixtures] = :development

Page 55: SproutCore and the Future of Web Apps

clients

Page 56: SproutCore and the Future of Web Apps

Models

Page 57: SproutCore and the Future of Web Apps

Modelsrequire('core');require('models/record');

OI.Mailbox = OI.Record.extend({ dataSource: SC.Store, _messages: null, isLoading: false, init: function() { this._messages = { value: [] }; },

lowerCaseName: function() { var name = this.get('name'); if (name) { return name.toLowerCase(); } }.property('name'),

Page 58: SproutCore and the Future of Web Apps

Modelsrequire('core');require('models/record');

OI.Mailbox = OI.Record.extend({ dataSource: SC.Store, _messages: null, isLoading: false, init: function() { this._messages = { value: [] }; },

lowerCaseName: function() { var name = this.get('name'); if (name) { return name.toLowerCase(); } }.property('name'),

Build commands

Page 59: SproutCore and the Future of Web Apps

Modelsrequire('core');require('models/record');

OI.Mailbox = OI.Record.extend({ dataSource: SC.Store, _messages: null, isLoading: false, init: function() { this._messages = { value: [] }; },

lowerCaseName: function() { var name = this.get('name'); if (name) { return name.toLowerCase(); } }.property('name'),

Build commands

Computed property

Page 60: SproutCore and the Future of Web Apps

Controllers

Page 61: SproutCore and the Future of Web Apps

Controllers

Page 62: SproutCore and the Future of Web Apps

Controllers

Observer

Page 63: SproutCore and the Future of Web Apps

Views

Page 64: SproutCore and the Future of Web Apps

Views

Page 65: SproutCore and the Future of Web Apps

Tests

SproutCore has good built-in testing

Page 66: SproutCore and the Future of Web Apps

Tests

Page 67: SproutCore and the Future of Web Apps

Tests

Page 68: SproutCore and the Future of Web Apps

english.lproj

Page 69: SproutCore and the Future of Web Apps

english.lproj

Page 70: SproutCore and the Future of Web Apps

english.lproj

ERB Goodness

Page 71: SproutCore and the Future of Web Apps

main.js

Page 72: SproutCore and the Future of Web Apps

main.js

Page 73: SproutCore and the Future of Web Apps

main.js

Timer awesomeness

Page 74: SproutCore and the Future of Web Apps

What gets downloaded?

javascript.js*stylesheet.cssindex.htmlimages (sprite for bonus)

All can be cached

Page 75: SproutCore and the Future of Web Apps

SC generates these files on the flyin development mode

Served by Merb

Page 76: SproutCore and the Future of Web Apps

SC builds these files as staticassets in production mode

Served by Apache, Varnish, CDN, etc.

Rails-style asset tags

Page 77: SproutCore and the Future of Web Apps

Demo

Page 78: SproutCore and the Future of Web Apps

Other Topics

Learning curve

Should you use it?

Other frameworks

The Uberfunction

Build system

Page 79: SproutCore and the Future of Web Apps

Join our team

• Ruby on Rails Developer• Ruby on Rails Intern

Open Positions• Smart, fun people• Startup environment• Cutting edge tech• Competitive pay• Stock options

Upgrade your job

We pay $1,000 for successful referrals!

Page 80: SproutCore and the Future of Web Apps

Thank [email protected]

subelsky.com - ignitebaltimore.com@subelsky @ignitebaltimore