Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Future of Rails - Take 2

The Future of Rails - Take 2

The 2nd version of my talk on the Future of Rails. A more streamlined version.

Be66f1ccc28a6a3dfb248454b8513b17?s=128

Ryan Bigg

May 10, 2018
Tweet

Transcript

  1. Mentor / Author / Developer

  2. FUTURE PREDICTIONS ARE OFTEN WRONG

  3. ISN’T RAILS THE FUTURE OF RAILS AS YOU KNOW IT

    TODAY
  4. TO KNOW THE FUTURE LOOK TO THE PAST

  5. APIs

  6. APPLICATION PROGRAMMING INTERFACE

  7. APIs ARE HOW PROGRAMS TALK TO EACH OTHER

  8. Your App API Third Party App

  9. APIs ARE AN AGREED CONTRACT

  10. Your App Third Party App API “Can you give me

    data about employees?”
  11. API “Sure, here’s my data” Third Party App Your App

  12. SOAP

  13. “Please send me all your employee data” In the past…

    (1998) SOAP APIs
  14. <?xml version='1.0' encoding='UTF-8'?> <S:Envelope xmlns:S="http:// schemas.xmlsoap.org/soap/ envelope/"> <S:Body> <GetEmployeeData />

    </S:Body> </S:Envelope> In the past… (1998) SOAP APIs
  15. --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Type: text/xml <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http:// schemas.xmlsoap.org/soap/envelope/"><S:Body /></S:Envelope> --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd

    Content-Id:<parameters=redacted@example.com> Content-Type: application/octet-stream Content-Transfer-Encoding: binary "User/Employee ID","First Name","Employment Details Hire Date","Username","Division","Company Country","Location","Department","Cost Center","Team","Supervisor","Manager User Sys ID","Contract Type","Gender" --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd-- In the past… (1998) SOAP APIs
  16. --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Type: text/xml <?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http:// schemas.xmlsoap.org/soap/envelope/"><S:Body /></S:Envelope> --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd

    Content-Id:<parameters=redacted@example.com> Content-Type: application/octet-stream Content-Transfer-Encoding: binary "User/Employee ID","First Name","Employment Details Hire Date","Username","Division","Company Country","Location","Department","Cost Center","Team","Supervisor","Manager User Sys ID","Contract Type","Gender" --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd-- SOAP APIs In the past… (1998)
  17. SOAP SIMPLE

  18. Retrieved: Tuesday, 8th May, 2018. --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Type: text/xml <?xml version='1.0'

    encoding='UTF-8'?><S:Envelope xmlns:S="http:// schemas.xmlsoap.org/soap/envelope/"><S:Body /></S:Envelope> --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd Content-Id:<parameters=redacted@example.com> Content-Type: application/octet-stream Content-Transfer-Encoding: binary "User/Employee ID","First Name","Employment Details Hire Date","Username","Division","Company Country","Location","Department","Cost Center","Team","Supervisor","Manager User Sys ID","Contract Type","Gender" --uuid:1fe211a2-9207-4981-b1ba-95c51dc9dadd--
  19. SOAP IS NOT A GOOD API

  20. Q: “DO YOU KNOW SOAP?” A: NOPE NOPE NOP

  21. None
  22. None
  23. None
  24. None
  25. JSON IS GOOD

  26. [ { "User/Employee ID": "ryan001", "First Name": "Ryan", "Username": "ryanbigg",

    . . . } . . . ] And then… (circa 2001)
  27. JSON JAVASCRIPT

  28. JSON Third Party App Your App “Can you give me

    data about employees?”
  29. JSON “Sure, here’s my data” Third Party App Your App

    [ { "User/Employee ID": "ryan001", "First Name": "Ryan", "Username": "ryanbigg", . . . } . . . ]
  30. HAPPENED THEN RAILS HAPPENED

  31. A browser JavaScript, CSS, Images, and Rails The Monolith And

    then and then (circa 2011) Database Makes your app look great Makes your app do stuff
  32. A browser React App Frontend App Backend App Now… (2018)

    The Duolith Database Rails App
  33. A browser React App Frontend App Backend App Now… (2018)

    Database Rails App Makes your app look great Makes your app do stuff
  34. A browser React App Frontend App Backend App Now… (2018)

    Database Rails App SeparaEon of Concerns
  35. Rails Apps In the past

  36. Rails Apps Now

  37. A browser React App Frontend App Backend App The Duolith

    Database Rails App Now… (2018)
  38. A browser Frontend App Backend App “Views”, CSS, JS, etc.

    Controllers, models, etc. React App Database Rails App Now… (2018)
  39. HOW DO THESE THINGS
 TALK ? A browser React App

    ??? Database Rails App
  40. APIs ARE HOW PROGRAMS TALK TO EACH OTHER Slide #7:

  41. A browser React App JSON API Recently… Database Rails App

  42. A browser React App “Show me a post” Recently… Database

    Rails App
  43. A browser React App “Okay, here’s the post” Recently… Database

    Rails App
  44. JSON APIs POST COMMENT #1 COMMENT #2 GET /api/posts/1 GET

    /api/posts/1/comments
  45. GET /api/posts/1 { "id": 1, "title": "Hello World", "body": "This

    is my blog's first post." "author": "Ryan Bigg" } JSON APIs
  46. GET /api/posts/1/comments [ { text: "Great first post!", by: "Totally

    not Ryan" }, ... ] JSON APIs
  47. A browser React App /api/posts/:id /api/comments … Currently… JSON APIs

    Need to build lots of these… Database Rails App /api/posts
  48. EVERYONE DOES THIS

  49. EVEN FACEBOOK

  50. WELL… THEY DID

  51. GET /api/posts/1 { "id": 1, "title": "Hello World", "body": "This

    is my blog's first post." "author": "Ryan Bigg" } JSON APIs Problem #1
  52. GET /api/posts/1 { "id": 1, "title": "Hello World", "body": "This

    is my blog's first post." "author": "Ryan Bigg”, “comments”: [ { “id”: 1, ... } ] } JSON APIs Problem #2
  53. JSON APIs POST COMMENT #1 COMMENT #2 GET /api/posts/1 GET

    /api/posts/1/comments
  54. Facebook iOS App Facebook Servers 1. Get news feed items

    2. Here are your items 3. Get comments 4. Here are the comments 5. Fetch user data 6. Here are the users
  55. JSON IS GOOD BUT WE CAN DO BETTER

  56. None
  57. /graphql Now (and the future) Only one endpoint (born 2012)

    Database Rails App A browser React App
  58. Fetching a Post query postQuery { post(id: 1) { id

    title body author } } { "data": { "post": { "id": 1, "title": "Hello World", "body": "First post!”, "author": "Ryan Bigg", } } } Query Response GRAPHQL
  59. query postQuery { post(id: 1) { id title body author

    } } { "data": { "post": { "id": 1, "title": "Hello World", "author": "Ryan Bigg", } } } Query Response GRAPHQL Ignoring a field
  60. Post + Comments query postQuery { post(id: 1) { id

    title body author comments { text by } } } { "data": { "post": { "id": 1, "title": "Hello World", "body": "First post!”, "author": "Ryan Bigg", "comments": [ { text: "Great first post!", by: "Totally not Ryan" }, ... ] } } } Query Response GRAPHQL
  61. GRAPHQL POST COMMENT #1 COMMENT #2 POST /graphql

  62. query postQuery { ... } query commentQuery { comment(id: 1)

    { text user } } { "data": { “post”: { ... }, “comment”: { text: "Great first post!", user: "Totally not Ryan” } } } Query Response GRAPHQL Two queries at the same Eme
  63. Facebook iOS App Facebook Servers 1. Get news feed items,

    their comments and their users 2. Here’s everything
  64. GRAPHQL IS BEST

  65. ISN’T RAILS THE FUTURE OF RAILS AS YOU KNOW IT

    TODAY
  66. Rails Apps Now

  67. The future… A browser React App Frontend App Backend App

    Database Rails App
  68. ✉: me@ryanbigg.com Thanks! : @ryanbigg ▶: hIp:/ /bit.ly/radar-for

  69. hIps:/ /developer.github.com/v3/ API Examples REST + JSON hIps:/ /developer.github.com/v4/ GRAPHQL

  70. hIps:/ /www.howtographql.com/ Learn these: GraphQL hIps:/ /reactjs.org/tutorial/tutorial.html React

  71. hIps:/ /www.sandimetz.com/99boIles/ Read these: 99 BOTTLES hIps:/ /www.poodr.com PRACTICAL OBJECT-ORIENTED

    DESIGN IN RUBY
  72. hIps:/ /bit.ly/exploding-rails-talk hIps:/ /speakerdeck.com/radar/exploding-rails hIps:/ /leanpub.com/exploding-rails Exploding Rails hIps:/ /github.com/radar/twist-v2

    MY EXAMPLE APPLICATION