Save 37% off PRO during our Black Friday Sale! »

[Saint-P RubyConf 2021] Rails X

[Saint-P RubyConf 2021] Rails X

Rails 7 is just around the corner. Although it brings a lot of powerful features, the new major release is not a revolution. Rails stays omakase; the Rails way is still a monolithic journey.

Let's turn the imagination mode on, and take a look at the fantastic future Rails: composable, extendable, free of core_ext, but still as easy to to use as today.

52cc8a838bf44a589d2572833b2dd1b9?s=128

Vladimir Dementyev

June 05, 2021
Tweet

Transcript

  1. 1

  2. Vova on Rails, since 2014 > 2

  3. YEARS AGO 3 The grass was greener, the light was

    brighter >
  4. Bozhidar is challenging Matz and Ruby Core team (RubyConfBY 2017)

    > 4
  5. If there is a gun hanging on the wall in

    the first act, it must fire in the last > 5
  6. NOW The idea has been on a shelf fo(u)r years

    > 6
  7. I didn't expect anyone to vote for this topic 🙀

    > 7
  8. Have I been trying to accomplish the quest for an

    ideal Rails X all these years 🤔 > 8
  9. Rails X == Rails 🤔 > 9

  10. Rails X == Hanami 😸 > 10

  11. MY RAILS X Reconsidering the past, designing the future (and

    some bikeshedding) > 11
  12. RECONSIDER rails new --skip-sprockets --skip-actiontext --skip-turbolinks --skip-actionmailbox --skip-wtf >

  13. EXTRACTION CURSE 13 A combination of extractions is not a

    framework, it's a Frankenstein 🧟 >
  14. Rails codebase is mostly an extraction (Basecamp with Shopify &

    GitHub sprinkles) Extractions are often too host-specific 14 The Extraction Curse
  15. Non-extractions Rails API Zeitwerk Active Record internals refactoring by @sgrif

    Action Cable Testing 🙂 15
  16. 16

  17. EXTRACTIONS FEATURES 17

  18. OMAKASE CURSE 18 Shut up and eat what's on the

    table! >
  19. Rails is bloating from the features most users don't need

    More code 㱺 more maintenance burden 㱺 less time for improvements 19
  20. Dead weight detected ☠ > 20

  21. SEPARATE ECOSYSTEM FROM FRAMEWORK 21

  22. 22 ⚠ Uwaga! PHP is on the next slide!

  23. 23 The student has surpassed the teacher ( >

  24. Tender age in bloom 🌸 > 24

  25. DUAL STACK CURSE 25 Two heads are better worse than

    one >
  26. 26 "The first thing we do is tell them to

    do a bunch of configuration."-Steve Klabnik > 2021
  27. 27 rails new --test-with=rspec and/or

  28. IMAGINARY FUTURE 28 It's time to turn imagination mode on!

    >
  29. 29

  30. 30 # app/services/purchaser.rb class Purchaser < ActiveService ::Base needs :payment_transaction

    needs :order_mailer def purchase!(customer:, card:, order:) transaction = payment_transaction.new(card,order.amount) if transaction.success? order_mailer.receipt_email(customer,order).deliver_later else order_mailer.card_failed(customer,order,transaction).deliver_later end end end # config/initializers/braintree.rb service :payment_transaction do Braintree ::Transaction.new(api_key: ENV["BRAINTREE_API_KEY"]) end
  31. 31

  32. My Rails X Unbundled & Separated Environment-friendly More abstractions, less

    implementations (More) Developer happiness Scalable codebase For the web and beyond Modern 32
  33. UNBUNDLED 33 Pieces of the puzzle must fit >

  34. Unbundled Upgrade individual parts Use sub-frameworks independently Avoid unneeded dependencies

    34
  35. 35 >= 5.1 -> nokogiri ( >= 1.6) actionpack (6.1.3.1)

    actionview (= 6.1.3.1) activesupport (= 6.1.3.1) rack ( ~> 2.0, >= 2.0.9) rack-test ( >= 0.6.3) rails-dom-testing ( ~> 2.0) rails-html-sanitizer ( ~> 1.0, >= 1.2.0) "actiondispatch" *
  36. ActionPack 36 Router 🤯 *

  37. 37 🤔

  38. ENVIRONMENT 38 Stop polluting the environment >

  39. stop_core_ext_everywhere > 39

  40. ABSTRACTIONS VS. IMPLEMENTATIONS 40 Replace leaking implementations with non-leaking abstractions

    >
  41. Rails 3-4: Sprockets Rails 5: Sprockets + Webpacker Rails 6:

    Webpacker + Sprockets Rails 7: ??? 41
  42. If you can’t decide, ship with zero options instead of

    two! 42
  43. 43 Interfaces not implementations for the outside world dependencies >

  44. 44 actiontrix

  45. DEVELOPER EXPERIENCE 45 Supporting tools are becoming more and more

    important than the language itself.–Matz >
  46. My typical Rails journey starts like this > 46

  47. DX Plug-n-play development environment 47

  48. 48

  49. Shall we sail, too? > 49

  50. DX Plug-n-play development environment Quick setup for new projects 50

  51. 51 open https: //railsnew.io >

  52. Oh, it's aiready a year old! > 52

  53. DX Plug-n-play development environment Quick setup for new projects Project-specific

    generators 53
  54. Generators Generator could only be useful if it fits your

    project needs Make a generator a part of the project Generate the generators! 54
  55. DX Plug-n-play development environment Quick setup for new projects Project-specific

    generators 55
  56. DX Plug-n-play development environment Quick setup for new projects Project-specific

    generators Deployment-ready 56
  57. 57 ActiveHeroku, ActionKubernetes, ActuallyCapistranoIsStillAlive ... >

  58. github.com/lewagon/seatrain 58 Under the sea, under the sea, darling, it's

    better, down where it's wetter >
  59. SCALABLE CODEBASE 59 Rails scales, and you? >

  60. 60 The promise of the new bright future >

  61. MAJESTIC MONOLITH 61 We all want to build majestic monoliths

    and citadels ... >
  62. SHIT-ESTIC MONOLITH 62 But usually that turns out as ...

    >
  63. 63 Cutting the application in slices 🔪 >

  64. Modular architecture Engines should become an official way to extract

    components Engines must be supported by all sub-frameworks 64
  65. 65

  66. Modular architecture Engines should become an official way to extract

    components Engines must be supported by all sub-frameworks Engines should just work! 66
  67. 67 github.com/palkan/engems One can dare to use engines today >

  68. Modular architecture Cross-component communication out-of-the-box 68

  69. 69 Did I show you enough reasons to choose PHP

    for the next project? 😄 >
  70. engines/ core/ app/ events/ core/ users/ registered.rb chat/ app/ subscribers/

    core/ users/ on_registered/ create_chat_account.rb github.com/palkan/active_event_store Event store the Rails way > 70
  71. BEYOND WEB 71 Can Rails break out of the Web

    world? >
  72. 72 Server is a terrible abstraction (Daniel Azuma, RailsConf 2021)

    >
  73. Beyond Web 🚀 HTTP server should be just one of

    the possible entry-points (e.g., gRPC, cables, serverless) Both request-response and events (streaming) based communication supported AbstractController should be really abstract! > 73
  74. MODERN 74 Is it 2021 or what? >

  75. Modern Ractor-ready Async-ready RBS-ready 75

  76. 76 github.com/pocke/rbs_rails Shouldn't Rails itself generate RBS for Rails 🤔

    >
  77. And a lot more... Improved instrumentation 77

  78. 78 Good company always worth the time >

  79. And a lot more... Improved instrumentation Improved testing tools (benchmarks,

    property- based, factories along with fixtures) Improved views 79
  80. Views X Isolated (no instance vars leaking) Components-first (view_component) UI

    kits or alike 80
  81. Improved instrumentation Improved testing tools (benchmarks, property- based, factories along

    with fixtures) Improved views Improved configuration (anyway_config) 81 And a lot more...
  82. And a lot more... Improved instrumentation Improved testing tools (benchmarks,

    property- based, factories along with fixtures) Improved views Improved configuration (anyway_config) Improved Rails commands 82
  83. Full-features CLI instead of Rake Fast start time (no application

    loading) First-class support for custom commands 83 Rails Commands X
  84. INVARIANTS 84 Some things should never change >

  85. SIMPLE STAY SIMPLE 85 Blog in 5 minutes without DI,

    algebraic effects and monads ⏱ >
  86. SAFETY FIRST 86 Make it hard to shoot yourself in

    the foot >
  87. AM I A DREAMER? 87

  88. discuss.rubyonrails.org 88 Your journey starts here! >

  89. We are hiring. We are hiring. I am hiring. I

    am herring 🐟 > evl.ms/jobs
  90. THANKS! 90 Exclusively for Saint-P Ruby Conf 2021 by Vladimir

    Dementyev, Evil Martians >
  91. DISCUSSION TIME 91 What do YOU want to fix in

    Rails? >