Slide 1

Slide 1 text

Alex Coles | Tropical Ruby, Recife Frontend Choices

Slide 2

Slide 2 text

oi Recife ;-)

Slide 3

Slide 3 text

lusófono

Slide 4

Slide 4 text

s/tu/você/

Slide 5

Slide 5 text

Alex Coles | Tropical Ruby, Recife Frontend Choices F5

Slide 6

Slide 6 text

not really about choice

Slide 7

Slide 7 text

Slide 8

Slide 8 text

quem sou eu?

Slide 9

Slide 9 text

I’m a backend guy living in a frontend world “

Slide 10

Slide 10 text

@myabc Alex Coles Berlin, Germany Finn GmbH

Slide 11

Slide 11 text

openproject.org Create a demo instance at
 start.openproject.com

Slide 12

Slide 12 text

@myabc eurucamp.org eurucamp.org jrubyconf.eu

Slide 13

Slide 13 text

euruko2015.org Salzburg, Austria | October 17 - 18

Slide 14

Slide 14 text

10 years ago 2014 2013 2012 2011 2010 2009 2008 2007 2006 2005 2004

Slide 15

Slide 15 text

10 years ago what was I doing?

Slide 16

Slide 16 text

10 years ago what was the world doing?

Slide 17

Slide 17 text

10 years ago what was Brazil doing?

Slide 18

Slide 18 text

10 years ago what were you doing? ?

Slide 19

Slide 19 text

10 years ago what was Apple doing?

Slide 20

Slide 20 text

10 years ago what was the web doing?

Slide 21

Slide 21 text

10 years ago there was no jQuery!

Slide 22

Slide 22 text

10 years ago the end of 2004 was to mark a transition

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

…we mostly had “websites”

Slide 26

Slide 26 text

yahoo.com Yahoo! 2004

Slide 27

Slide 27 text

bindows.net Bindows 2004

Slide 28

Slide 28 text

gmail.com Gmail pre-β 2002-4 http://techcrunch.com/2008/06/06/the-evolution-of-pre-launch-gmail-in-screenshots/

Slide 29

Slide 29 text

where we are now

Slide 30

Slide 30 text

…we have “applications”

Slide 31

Slide 31 text

soundcloud.com Soundcloud

Slide 32

Slide 32 text

Single Page Application Architecture

Slide 33

Slide 33 text

chunking controller templating routing real-time communicaton local storage Single Page Application Architecture - +

Slide 34

Slide 34 text

The Rails (UI) Way

Slide 35

Slide 35 text

Rails is so 2005 “

Slide 36

Slide 36 text

“Rails Way” for views back in 2005 •Server Generated HTML (ERB, etc.) •Prototype •Scriptaculous •RJS

Slide 37

Slide 37 text

http://slash7.com/assets/2006/10/8/RJS-Demistified_Amy-Hoy-slash7_1.pdf RJS

Slide 38

Slide 38 text

RJS
  <%=  link_to_remote  'Add  to  cart',  url:  {  controller:  'cart',  action:   'add_to_cart'  }%> erb view class  CartController  <  ActionController::Base      def  add_to_cart          @item  =  CartItem.new          @cart.items  <<  @item      end   end controller page.insert_html    :bottom,  :items,  partial:  'item',  object:  @item   page.replace_html  :items_count,  I18n.t(:item,  count:  @cart.items.count)   rjs view

Slide 39

Slide 39 text

“Rails Way” for views now • Server Generated HTML (ERB, Slim, HAML etc.) • jQuery • jQuery UI • Server generated JavaScript Responses (SJR)

Slide 40

Slide 40 text

meanwhile

Slide 41

Slide 41 text

JavaScript has grown up

Slide 42

Slide 42 text

JavaScript has grown up percentage of total JS developer jobs has doubled from 2005 to 2010 indeed.com

Slide 43

Slide 43 text

JavaScript has grown up Server-side usage of JS has been multiplied by 6 from Jan 2012 to Oct 2014 W3Techs.com

Slide 44

Slide 44 text

no backend nobackend.org

Slide 45

Slide 45 text

hood.ie Hoodie

Slide 46

Slide 46 text

meteor.com Meteor 50 UPCOMING EVENTS 4224 PACKAGES 9915 STACK OVERFLOW QUESTIONS 254K UNIQUE INSTALLS 12 PROFESSIONAL SERVICE PROVIDERS Meteor is a complete open source platform Build apps that are a delight to use, faster than you ever thought possible I N S TA L L M E T E O R I N S TA L L M E T E O R 1 .0. 3 . 2 1 .0. 3 . 2 Star Star Follow Follow @meteorjs @meteorjs 36.8K followers 22945 22945 TUTORIAL DOCS SUBPROJECTS PACKAGES THE METEOR PROJECT BLOG SIGN IN

Slide 47

Slide 47 text

isomorphism

Slide 48

Slide 48 text

plethora of frontend frameworks

Slide 49

Slide 49 text

frontend (MV*) frameworks AngularJS Ember.js KnockoutJS

Slide 50

Slide 50 text

ReactJS ExtJS Backbone View (alone) frontend (component) frameworks Ractive.js

Slide 51

Slide 51 text

TodoMVC todomvc.com

Slide 52

Slide 52 text

but I <3 Ruby !

Slide 53

Slide 53 text

back to the question…

Slide 54

Slide 54 text

Slide 55

Slide 55 text

is there room for Rails?

Slide 56

Slide 56 text

“ – Marcin Stecki @madsheepPL at wroc_love.rb Not his [DHH’s] responsibility to tell us how to do these things.

Slide 57

Slide 57 text

single page vs. traditional HTML

Slide 58

Slide 58 text

naturally content-dependent

Slide 59

Slide 59 text

what is your content? Information pages Closed systems Membership sites general personal

Slide 60

Slide 60 text

content criteria • authentication • how real is real-time • caching • indexing (SEO)

Slide 61

Slide 61 text

how unique is the view to be rendered? how many combinations of a unique set of data? • a blog with comments • a hotel page with reviews • a dashboard

Slide 62

Slide 62 text

if it is curated content Rails way →

Slide 63

Slide 63 text

other ways are better if it is SPA →

Slide 64

Slide 64 text

some tips

Slide 65

Slide 65 text

what is most like Rails? tip 1: familiarity Ember.js is most like Rails

Slide 66

Slide 66 text

Ember.js is most like Rails • everything should inherit from main object ActiveRecord::Base.inherited Ember.Object Plain Old JavaScript Objects

Slide 67

Slide 67 text

Ember.js is most like Rails • routing DSL built-in routing not in core, third party solutions built-in routing

Slide 68

Slide 68 text

Ember.js is most like Rails • vocabulary (templates, partials, etc.) Dependency Injection, Factories, Services, Providers,
 Transclusion Models, Controllers, Views, Initializers Models, Controllers, Views, Initializers

Slide 69

Slide 69 text

how to make things work with Rails?

Slide 70

Slide 70 text

using asset pipeline / sprockets tip 2: Rails “the non-Rails way

Slide 71

Slide 71 text

use Bower

Slide 72

Slide 72 text

3 options for using Bower

Slide 73

Slide 73 text

gem install bower-rails 1 option gem

Slide 74

Slide 74 text

config.assets.paths << File.join(Rails.root, ‘bower_components') Rails 4 (Sprockets 2+) 2 option

Slide 75

Slide 75 text

rails-assets.org rails-assets.org 3 option

Slide 76

Slide 76 text

ember-rails-api github.com/dockyard/ember-appkit-rails

Slide 77

Slide 77 text

the app/assets/javascripts silo

Slide 78

Slide 78 text

what is the way forward? →

Slide 79

Slide 79 text

voltframework.com Volt Framework Volt is a framework for building data rich web applications shockingly fast. Play Video ! Get Started " Home Getting Started Docs API Blog Community #

Slide 80

Slide 80 text

Volt
      {{  page._cart_items.each  do  |item|  }}  
  •        {{  item._name  }}      
  •   {{  end  }}  
view class  CartController  <  Volt::ModelController      model  :cart      def  add_to_cart          page._cart_items  =  {  name:  page._new_item  }              page._new_item  <<  ''      end   controller

Slide 81

Slide 81 text

eu não gosto de monólitos

Slide 82

Slide 82 text

RJS
  <%=  link_to_remote  'Add  to  cart',  url:  {  controller:  'cart',  action:   'add_to_cart'  }%> erb view class  CartController  <  ActionController::Base      def  add_to_cart          @item  =  CartItem.new          @cart.items  <<  @item      end   end controller page.insert_html    :bottom,  :items,  partial:  'item',  object:  @item   page.replace_html  :items_count,  I18n.t(:item,  count:  @cart.items.count)   rjs view

Slide 83

Slide 83 text

(IMHO)

Slide 84

Slide 84 text

split completely ! tip 3: split

Slide 85

Slide 85 text

applications 2 frontend = 1 API + 1

Slide 86

Slide 86 text

frontend API Rails Sinatra JS workflows Lotus.rb

Slide 87

Slide 87 text

client-server model works

Slide 88

Slide 88 text

monolingualism is bad

Slide 89

Slide 89 text

JavaScript tooling

Slide 90

Slide 90 text

alternative build-pipelines

Slide 91

Slide 91 text

surprisingly well testable (and fast)

Slide 92

Slide 92 text

isomorphism is possible http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/

Slide 93

Slide 93 text

http://nerds.airbnb.com/isomorphic-javascript-future-web-apps/

Slide 94

Slide 94 text

ember-fast-boot

Slide 95

Slide 95 text

will the SPA kill Rails?

Slide 96

Slide 96 text

muito obrigado!

Slide 97

Slide 97 text

perguntas?

Slide 98

Slide 98 text

@myabc