Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Let's Chat
Search
Garrett Heinlen
September 12, 2017
Education
1
390
Let's Chat
Ruby and Elixir. An exploration of cross language communication
Garrett Heinlen
September 12, 2017
Tweet
Share
More Decks by Garrett Heinlen
See All by Garrett Heinlen
Event Sourcing: Don't want to miss a thing
gogogarrett
0
110
Lets Program - A practical guide
gogogarrett
0
56
StudyGroups
gogogarrett
1
77
:gen_fsm meets elixir
gogogarrett
1
350
Intro into Ecto
gogogarrett
2
68
Hopscotch
gogogarrett
1
150
Ember Testing: is it a mirage?
gogogarrett
1
160
Elixir and Phoenix
gogogarrett
0
200
WTF is WF
gogogarrett
1
120
Other Decks in Education
See All in Education
中間活動報告会 人材育成WG・技術サブWG / 20250808-oidfj-eduWG-techSWG
oidfj
0
720
吉岡研究室紹介(2025年度)
kentaroy47
0
290
The knowledge panel is your new homepage
bradwetherall
0
160
Master of Applied Science & Engineering: Computer Science & Master of Science in Applied Informatics: Artificial Intelligence and Data Science
signer
PRO
0
820
Презентация "Знаю Россию"
spilsart
0
250
2026 g0v 零時政府年會啟動提案 / g0v Summit 2026 Kickstart
rschiang
0
320
QR-koodit opetuksessa
matleenalaakso
0
1.7k
『会社を知ってもらう』から『安心して活躍してもらう』までの プロセスとフロー
sasakendayo
0
270
【品女100周年企画】Pitch Deck
shinagawajoshigakuin_100th
0
7.3k
20250611_なんでもCopilot1年続いたぞ~
ponponmikankan
0
200
みんなのコード 2024年度活動報告書/ 2025年度活動計画書
codeforeveryone
0
330
ROSConJP 2025 発表スライド
f0reacharr
0
230
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
114
20k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Bash Introduction
62gerente
615
210k
GitHub's CSS Performance
jonrohan
1032
460k
The Power of CSS Pseudo Elements
geoffreycrofte
79
6k
The Language of Interfaces
destraynor
162
25k
Building Applications with DynamoDB
mza
96
6.6k
We Have a Design System, Now What?
morganepeng
53
7.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
54
3k
Building an army of robots
kneath
306
46k
Context Engineering - Making Every Token Count
addyosmani
5
190
Transcript
Let's Chat Ruby and Elixir. An exploration of cross language
communication
Hey, I'm Garre!
None
None
I work for Blake Education
We teach children
None
We use Ruby && Elixir
Why did we move? — really fast — immutable data
— parallel / concurrent — easy to isolate complexity into applications (microservices w/o http) — encourages better design — shiny — does your taxes — #1 hacker news
Agenda — Refresher on Ruby — Explain Redis — Explore
Sidekiq — Introduce Elixir — Demo — Recap
Refresher on Ruby
Ruby - Hash We use keys to unlock values
Ruby - Hash ! ! " # ! " $
! " %
Ruby - Hash ! my_house ! door_1 " # shower
! door_2 " $ living_room ! door_3 " % bedroom
Ruby - Hash my_house = { door_1: "shower", door_2: "living_room",
door_3: "bedroom", }
Ruby - Hash person = { name: "Garrett", age: 27,
hearthstone_rank: 3, fav_things: [] } person[:hearthstone_rank] # => 3 person[:fav_things] << "gummy bears" # => ["gummy bears"]
Ruby - Array An Array is a list of items
in order
Ruby - Array ! " # $ %
Ruby - Array
Ruby - Array a = [] # => [] a
<< "abc" # => ["abc"] a # => ["abc"] a.pop # => "abc" a # => []
Ruby - Array a = [] # => [] a.push("abc")
# => ["abc"] a # => ["abc"] a.pop # => "abc" a # => []
Ruby - Array Appending to a list x << y
x.push(y)
Ruby - Array Pulling items off a list x.pop(y)
Ruby - Array Push && Pop x.push(y) x.pop(y)
None
PushPop
Well, that's Ruby.
Explain Redis
Redis is a hash in the cloud.
$redis = {} # setter $redis[:thought] = "Where's the Elixir
already?" # getter $redis[:thought] # => "Where's the Elixir already?" # setter $redis[:drinks] << "little creatures" $redis[:drinks] << "150 lashes" # getter $redis[:drinks] # => ["little creatures", "150 lashes"]
$ redis-cli set thought "Where's the Elixir already?" get thought
# => "Where's the Elixir already?" rpush drinks "little creatures" rpush drinks "150 lashes" lrange drinks 0 -1 # => 1) "little creatures" # => 2) "150 lashes" lpop drinks # => "little creatures"
Redis Desktop Manager
Explore Sidekiq
Sidekiq framework for background job processing
Why do I need a Sidekiq
¯\(ϑ)/¯
Common Use cases — Emails — Expensive computation — Imagine
Processing — Reports — Etc..
None
Sidekiq is built on 3 parts — Client — push
jobs into redis — Redis — store the jobs — Server — process the jobs
Client MyWorker.perform_async({abc: "123", simple_as: "drm"}) Redis rpush queue:default "{\"class\":\"MyWorker\",\"args\":[{\"abc\":\"123\",\"simple_as\":\"drm\"], \"retry\":true,\"queue\":\"default\",
\"jid\":\"f03cd72fef59bfbbf4098890\", \"created_at\":1503728661.8513222,\"enqueued_at\":1503728661.851379}" Server class MyWorker include Sidekiq::Worker def perform(hash) puts hash.inspect # => {abc: "123", simple_as: "drm"} end end
Client class SomethingSingularOrPluarl < BigBaseController def create MyWorker.perform_async(superfriend_params) head :created
end private def superfriend_params params.permit! # {abc: "123", simple_as: "drm"} end end
Redis
Server class MyWorker include Sidekiq::Worker def perform(hash) puts hash.inspect #
=> {abc: "123", simple_as: "drm"} end end
Lets Chat, A practical application
Sidekiq - how does it work? # clients rpush "redis:jobs"
{assignee: "Audience Member", task: "Greet your neighbour"} rpush "redis:jobs" {assignee: "Audience Member", task: "Take a drink"} rpush "redis:jobs" {assignee: "Audience Member", task: "Heckle louder"} rpush "redis:jobs" {assignee: "Audience Member", task: "Do Garrett's Taxes"} # sidekiq while true job = lpop "redis:jobs" if job AudienceMember.perform(job) end end
None
Well, thats Sidekiq.
Introduce Elixir
Elixir can act as the Server.
Exq job processing library compatible with Sidekiq for Elixir
Configure Exq config :exq, host: "localhost", port: 6379, namespace: "",
concurrency: 10, queues: ["default"], poll_timeout: 200
Ruby Sidekiq Server class MyWorker include Sidekiq::Worker def perform(hash) puts
hash.inspect # => {abc: "123", simple_as: "drm"} end end
Elixir Sidekiq Server defmodule MyWorker do def perform(map) do IO.inspect(map)
# => %{abc: "123", simple_as: "drm"} end end
Demo Time !
None
Recap — Redis is a Hash — We push jobs
into a list — We pull jobs off the list — We can process the jobs with Ruby or Elixir — Exq is the Elixir Sidekiq
Thanks @gogogarre!