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

[ITeaConf 2021] Как дела, Руби?

[ITeaConf 2021] Как дела, Руби?

https://iteaconf.ru

----

Вакансии Злых марсиан: https://career.habr.com/companies/evilmartians

Vladimir Dementyev

November 14, 2021
Tweet

More Decks by Vladimir Dementyev

Other Decks in Programming

Transcript

  1. WHAT'S UP,
    RUBY?
    by Vladimir Dementyev

    View Slide

  2. palkan_tula
    palkan
    Почему про Ruby?
    2
    github.com/palkan
    evilmartians.com

    View Slide

  3. palkan_tula
    palkan
    Место Ruby
    в мире веб-разработки
    3
    jetbrains.com/lp/devecosystem-2021/

    View Slide

  4. palkan_tula
    palkan
    Место Ruby
    в мире веб-разработки
    4
    redmonk.com/sogrady/2021/08/05/language-rankings-6-21/

    View Slide

  5. palkan_tula
    palkan
    Под капотом — Ruby
    5

    View Slide

  6. palkan_tula
    palkan
    6
    Язык для чтения

    View Slide

  7. palkan_tula
    palkan
    7
    No bothersome semicolons to type
    mechanically at the end of each line
    No troublesome type declarations to
    keep in sync (especially in separate files)
    No unnecessary words just
    to keep the compiler happy
    No error-prone framework code

    View Slide

  8. palkan_tula
    palkan
    8
    Ruby is designed to make programmers happy
    It allows you to concentrate on the creative
    side of programming, with less stress
    Matz (Yukihiro Matsumoto)

    View Slide

  9. palkan_tula
    palkan
    Родословная
    9
    rigaux.org/language-study/diagram.html

    View Slide

  10. palkan_tula
    palkan
    Доска почёта
    10
    2008
    RSpec
    2005
    2007
    2011
    2006

    View Slide

  11. palkan_tula
    palkan
    Доска почёта
    11
    2008
    RSpec
    2005
    2007
    2011
    2006
    2005

    View Slide

  12. palkan_tula
    palkan
    Йеси-паси
    12

    View Slide

  13. palkan_tula
    palkan
    Атака Rails клонов
    13

    View Slide

  14. palkan_tula
    palkan
    Ruby заражает
    14

    View Slide

  15. palkan_tula
    palkan
    Так как там Ruby?
    15
    isrubydead.com

    View Slide

  16. palkan_tula
    palkan
    Ruby 2021
    16
    def beach(*temperature)
    case temperature
    in :celcius | :c, (20 ..45)
    :favorable
    in :kelvin | :k, (293 ..318)
    :scientifically_favorable
    in :fahrenheit | :f, (68 ..113)
    :favorable_in_us
    else
    :avoid_beach
    end
    end

    View Slide

  17. palkan_tula
    palkan
    Ruby 2021
    17
    RBS (Type Signatures for Ruby)

    View Slide

  18. palkan_tula
    palkan
    Ruby 2021
    18
    server = Ractor.new do
    puts "Server sends: ping"
    Ractor.yield 'ping'
    received = Ractor.receive
    puts "Server received: #{received}"
    end
    client = Ractor.new(server) do |srv|
    received = srv.take
    puts "Client received: #{received}"
    puts "Client sends: pong"
    srv.send 'pong'
    end
    [client, server].each(&:take)
    Ractor — Ruby actor

    View Slide

  19. palkan_tula
    palkan
    Ruby — вампир 🤔
    19

    View Slide

  20. palkan_tula
    palkan
    Ruby Type Signatures
    20
    I hate type annotations
    Аннотации типов — это костыль
    Если мы добавим типы в язык, то
    их сложно будет убрать из него в
    будущем, когда вывод типов будет
    полностью автоматическим

    View Slide

  21. palkan_tula
    palkan
    TypeProf
    21
    github.com/ruby/typeprof

    View Slide

  22. evl.ms/chronicles/climbing-steep-hills-or-adopting-ruby-types

    View Slide

  23. palkan_tula
    palkan
    Пессимисты
    23
    sorbet.org

    View Slide

  24. palkan_tula
    palkan
    24

    View Slide

  25. palkan_tula
    palkan
    Ractor
    25
    Настоящий параллелизм, или прощай GIL
    brandur.org/nanoglyphs/018-ractors

    View Slide

  26. palkan_tula
    palkan
    Ruby-трёшка
    26

    View Slide

  27. palkan_tula
    palkan
    Ractor
    27
    Не любит делиться — сложно ему будет в нашем мире
    Ractor.shareable?(1) # => true
    Ractor.shareable?('foo') # => false
    Ractor.shareable?('foo'.freeze) # => true

    View Slide

  28. palkan_tula
    palkan
    Ruby-трёшка+
    28

    View Slide

  29. palkan_tula
    palkan
    Fiber
    29
    Кооперативная многозадачность

    View Slide

  30. palkan_tula
    palkan
    Fiber
    30
    От полностью ручного управления к автоматическому
    Ruby 2
    Ruby 3

    View Slide

  31. palkan_tula
    palkan
    Fiber Scheduler
    31
    Интерфейс, не реализация

    View Slide

  32. palkan_tula
    palkan
    Fiber Scheduler
    32
    Интерфейс, не реализация
    Without changing existing code 🙀

    View Slide

  33. palkan_tula
    palkan
    Приоритеты
    33

    View Slide

  34. palkan_tula
    palkan
    Совместимость
    34

    View Slide

  35. palkan_tula
    palkan
    Совместимость
    35
    В обе стороны 🙃
    evilmartians.com/blog/ruby-next-make-all-rubies-quack-alike

    View Slide

  36. palkan_tula
    palkan
    От Ruby к Rails
    36

    View Slide

  37. palkan_tula
    palkan
    Just-in-Time
    37
    rubykaigi.org/2021-takeout/presentations/maximecb.html

    View Slide

  38. palkan_tula
    palkan
    Rails 7
    38

    View Slide

  39. palkan_tula
    palkan
    Rails 7 frontend
    39

    View Slide

  40. palkan_tula
    palkan
    Кризис веб-разработки
    40

    View Slide

  41. palkan_tula
    palkan
    Rails 2021
    41
    Full-stack возвращается
    noti.st/palkan/v01SxZ/frontend-bez-frontenda

    View Slide

  42. palkan_tula
    palkan
    Full-stack Rails
    42
    HTML-over-the-Wire

    View Slide

  43. palkan_tula
    palkan
    NEW MAGIC
    43
    hotwired.dev

    View Slide

  44. palkan_tula
    palkan
    Hotwire
    44
    Turbo Drive (ex-Turbolinks) и Frames — SPA «для бедных»
    Turbo Streams — обновление HTML через WebSockets
    Stimulus — «живая вода» для HTML

    View Slide

  45. palkan_tula
    palkan
    Stimulus
    45

    View Slide

  46. palkan_tula
    palkan
    Hotwire
    46
    evilmartians.com/blog/hotwire-reactive-rails-with-no-javascript

    View Slide

  47. palkan_tula
    palkan
    Stimulus Reflex
    47
    docs.stimulusreflex.com
    Hotwire для взрослых

    View Slide

  48. palkan_tula
    palkan
    Sockpuppet
    48
    github.com/jonathan-s/django-sockpuppet

    View Slide

  49. palkan_tula
    palkan
    View Component
    49
    HTML компоненты на Ruby
    viewcomponent.org

    View Slide

  50. palkan_tula
    palkan
    View Component
    50
    # app/components/button/component.rb
    class Button ::Component < ViewComponent ::Base
    attr_reader :label, :icon
    def initialize(label:, icon: nil)
    @label = label
    @icon = icon
    end
    alias icon? icon
    end
    # app/components/button/component.html.erb






    View Slide

  51. palkan_tula
    palkan
    Монолит или..?
    51

    View Slide

  52. palkan_tula
    palkan
    Модульный монолит
    52

    View Slide

  53. palkan_tula
    palkan
    Rails Engines
    53

    View Slide

  54. palkan_tula
    palkan
    Shopify
    54
    shopify.engineering/shopify-monolith

    View Slide

  55. palkan_tula
    palkan
    Hanami
    55
    Не Рельсами едиными
    hanamirb.org

    View Slide

  56. palkan_tula
    palkan
    Подготовка к запуску
    56
    Вы всё ещё используете Capistrano?..

    View Slide

  57. palkan_tula
    palkan
    Kuby
    57
    getkuby.io

    View Slide

  58. palkan_tula
    palkan
    Kuby
    58
    Kuby.define("anycable-rails-demo") do
    environment(:production) do
    app_creds = read_creds(:production)
    docker do
    credentials do
    username app_creds[:do_token]
    password app_creds[:do_token]
    end
    image_url "registry.digitalocean.com/anycable/anycable-rails-demo"
    end
    kubernetes do
    add_plugin :rails_app do
    hostname "kuby-demo.anycable.io"
    end
    add_plugin :anycable_rpc
    add_plugin :anycable_go
    provider :digitalocean do
    access_token app_creds[:do_token]
    cluster_id app_creds[:do_cluster_id]
    end
    end
    end
    end
    На выходе сотни строк кода
    для Docker и Kubernetes
    kuby setup && kuby build && kuby push && kuby deploy

    View Slide

  59. palkan_tula
    palkan
    Пост-Ruby
    59

    View Slide

  60. СПАСИБО!
    @palkan
    @palkan_tula
    evilmartians.com
    @evilmartians

    View Slide