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
Elixir vs Ruby vs JavaScript Syntax
Search
Maksym Verbovyi
August 23, 2020
Programming
0
370
Elixir vs Ruby vs JavaScript Syntax
Compare Elixir syntax with Ruby and JavaScript #elixirschool
Maksym Verbovyi
August 23, 2020
Tweet
Share
More Decks by Maksym Verbovyi
See All by Maksym Verbovyi
Phoenix LiveView - interactive real-time apps without writing JS
vermaxik
0
41
How I have built Telegram bot for study German
vermaxik
0
390
Other Decks in Programming
See All in Programming
Swift Updates - Learn Languages 2025
koher
2
450
速いWebフレームワークを作る
yusukebe
5
1.7k
Microsoft Orleans, Daprのアクターモデルを使い効率的に開発、デプロイを行うためのSekibanの試行錯誤 / Sekiban: Exploring Efficient Development and Deployment with Microsoft Orleans and Dapr Actor Models
tomohisa
0
240
ソフトウェアテスト徹底指南書の紹介
goyoki
1
140
「手軽で便利」に潜む罠。 Popover API を WCAG 2.2の視点で安全に使うには
taitotnk
0
740
意外と簡単!?フロントエンドでパスキー認証を実現する WebAuthn
teamlab
PRO
1
600
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
18
9.7k
「待たせ上手」なスケルトンスクリーン、 そのUXの裏側
teamlab
PRO
0
300
Namespace and Its Future
tagomoris
6
700
AIコーディングAgentとの向き合い方
eycjur
0
260
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
430
Ruby Parser progress report 2025
yui_knk
1
300
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Mobile First: as difficult as doing things right
swwweet
224
9.9k
Designing Experiences People Love
moore
142
24k
RailsConf 2023
tenderlove
30
1.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Code Reviewing Like a Champion
maltzj
525
40k
Automating Front-end Workflow
addyosmani
1370
200k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
For a Future-Friendly Web
brad_frost
180
9.9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
23
1.4k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Transcript
Elixir vs Ruby vs JavaScript Syntax Elixir School Maksym Verbovyi
August 2020, Hamburg
Disclaimer
Basics Tools and common usage
Interactive Shell iex irb jsc
Run task mix rake npm
Dependencies mix bundler npm
Debug IEX.pry binding.pry debugger
Polymorphism Protocols Polymorphism Extends
Metaprogramming Macros Metaprogramming Proxy Reflect
Popular framework Phoenix Rails React Vue.js
Syntax Be awesome
String "String" 'string'
String "String" 'string' "String" 'string'
String "String" 'Not string' # [110, 111, 116, 32, 115,
116, 114, 105, 110, 103] "String" 'string' "String" 'string'
Atom :symbol
Atom Symbol('string') :symbol
Atom Symbol('string') :symbol :atom
Boolean true || false
Boolean true || false true || false
Boolean true || false true || false true || false
List [1, :a, "b", true] *
List [1, Symbol('a'), "b", true] * [1, :a, "b", true]
*
List [1, :a, "b", true] [1, Symbol('a'), "b", true] *
[1, :a, "b", true] *
Tuple {1, :a, "b", true} [1, Symbol('a'), "b", true] *
[1, :a, "b", true] *
Map { name: "Maks", age: 32, height: 178 }
Map { name: "Maks", age: 32, height: 178 } {
name: "Maks", age: 32, height: 178 }
Map %{ name: "Maks", age: 32, height: 178 } {
name: "Maks", age: 32, height: 178 } { name: "Maks", age: 32, height: 178 }
Nil nil
Nil nil null
Nil nil nil null
Interpolation "Hello #{ruby}"
Interpolation "Hello #{ruby}" `Hello ${javascript}`
Interpolation "Hello #{ruby}" "Hello #{elixir}" `Hello ${javascript}`
Concatenation String "Elixir" + "School" "Elixir" << "School" "Elixir".concat("School")
Concatenation String "Elixir" + "School" "Elixir" << "School" "Elixir".concat("School") "Elixir"
+ "School" "Elixir".concat("School")
Concatenation String "Elixir" + "School" "Elixir" << "School" "Elixir".concat("School") "Elixir"
+ "School" "Elixir".concat("School") "Hello" <> "Elixir"
Concatenation List [1,2,3] + [4,5] # [1,2,3,4,5] [1,2] << 3
# [1,2,3]
Concatenation List [1,2,3] + [4,5] # [1,2,3,4,5] [1,2] << 3
# [1,2,3] [1,2,3].concat([4,5]) // [1,2,3,4,5]
Concatenation List [1,2,3] + [4,5] # [1,2,3,4,5] [1,2] << 3
# [1,2,3] [1,2,3].concat([4,5]) // [1,2,3,4,5] [1,2,3] ++ [4,5] # [1,2,3,4,5] [3 | [1,2]] # [3,1,2]
Range 1..5 (1..5).to_a # [1,2,3,4,5]
Range 1..5 (1..5).to_a # [1,2,3,4,5] Not available
Range 1..5 (1..5).to_a # [1,2,3,4,5] 1..5 1..5 |> Enum.to_list #
[1,2,3,4,5] Not available
If statement if true # unless puts "It's true" else
puts "It's false" end true ? "it's true" : "it's false"
If statement if (true) { console.log("It's true") } else {
console.log("It's false") } true ? "it's true" : "it's false"
If statement if true do # unless IO.puts "It's true"
else IO.puts "It's false" end if true, do: "It's true", else: "it's false"
Case case true when true "It's true" when false "It’s
false" else "Something else" end
Case switch(true) { case true: "It's true" break; case false:
"It's false" break; default: "Something else" }
Case case true do true -> "It’s true" false ->
"It’s false" _ -> "Something else" end
Pipe operator [1, 2, 3, 4, 6]. map{ |x| x*x
}. reduce{ |sum, x| sum + x }
Pipe operator [1, 2, 3, 4, 6] .map(x => x
* x) .reduce((x, sum) => sum + x) [1, 2, 3, 4, 6]. map{ |x| x*x }. reduce{ |sum, x| sum + x }
Pipe operator [1, 2, 3, 4, 6] .map(x => x
* x) .reduce((x, sum) => sum + x) [1, 2, 3, 4, 6] |> Enum.map(fn x -> x*x end) |> Enum.reduce(fn x, sum -> sum + x end) [1, 2, 3, 4, 6]. map{ |x| x*x }. reduce{ |sum, x| sum + x }
Comprehensions for x in [1,2,3] do puts x end
Comprehensions for x in [1,2,3] do puts x end for
(x in [1,2,3]) { console.log(x) }
Comprehensions for x <- [1,2,3] do IO.puts x end for
x in [1,2,3] do puts x end for (x in [1,2,3]) { console.log(x) }
Anonymous function irb(main):010:0> hello = -> what { puts "Hello
#{what}" } => #<Proc:0x00007fb13f0e8da8@(irb):10 (lambda)> irb(main):011:0> hello.("what") # hello.call("what") "Hello what" => nil
Anonymous function irb(main):010:0> hello = -> what { puts "Hello
#{what}" } => #<Proc:0x00007fb13f0e8da8@(irb):10 (lambda)> irb(main):011:0> hello.("what") # hello.call("what") "Hello what" => nil > const hello = (what) => { return `Hello ${what}`; } undefined > hello("world") 'Hello world'
Anonymous function iex(10)> hello = fn what -> IO.puts "Hello
#{what}" end #Function<7.126501267/1 in :erl_eval.expr/5> iex(11)> hello.("world") Hello world :ok irb(main):010:0> hello = -> what { puts "Hello #{what}" } => #<Proc:0x00007fb13f0e8da8@(irb):10 (lambda)> irb(main):011:0> hello.("what") # hello.call("what") "Hello what" => nil > const hello = (what) => { return `Hello ${what}`; } undefined > hello("world") 'Hello world'
Code A bit of code
Define module and function module ModuleName def hello puts "Hello
Ruby!" end end
Define module and function* class ClassName { hello() { return
`Hello from JS`; } }
Define module and function defmodule ModuleName do def hello do
puts "Hello from Elixir" end end
Syntax Sugar Sweet • Brackets • Keyword list
Companies Use the Elixir • Discord • Sketch • Pinterest
• Bleacher Report • PepsiCo • Whatsapp • Financial Times
Questions? Thank you!