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
Golang for Rubyists
Search
Nihad Abbasov
April 13, 2019
Programming
1
93
Golang for Rubyists
Nihad Abbasov
April 13, 2019
Tweet
Share
More Decks by Nihad Abbasov
See All by Nihad Abbasov
Performance Optimization 101 for Ruby developers
narkoz
1
120
Other Decks in Programming
See All in Programming
[DevinMeetupTokyo2025] コード書かせないDevinの使い方
takumiyoshikawa
2
220
Google I/O Extended Incheon 2025 ~ What's new in Android development tools
pluu
1
200
抽象化という思考のツール - 理解と活用 - / Abstraction-as-a-Tool-for-Thinking
shin1x1
1
890
iOS開発スターターキットの作り方
akidon0000
0
220
Amazon Q CLI開発で学んだAIコーディングツールの使い方
licux
3
120
階層化自動テストで開発に機動力を
ickx
1
440
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
570
Prompt Engineeringの再定義「Context Engineering」とは
htsuruo
0
110
状態遷移図を書こう / Sequence Chart vs State Diagram
orgachem
PRO
3
300
Streamlitで実現できるようになったこと、実現してくれたこと
ayumu_yamaguchi
2
240
MCP連携で加速するAI駆動開発/mcp integration accelerates ai-driven-development
bpstudy
0
150
オンコール⼊⾨〜ページャーが鳴る前に、あなたが備えられること〜 / Before The Pager Rings
yktakaha4
2
1.2k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
329
21k
4 Signs Your Business is Dying
shpigford
184
22k
GitHub's CSS Performance
jonrohan
1031
460k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
Writing Fast Ruby
sferik
628
62k
Scaling GitHub
holman
461
140k
Become a Pro
speakerdeck
PRO
29
5.4k
RailsConf 2023
tenderlove
30
1.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
Transcript
GOLANG FOR RUBYISTS RUBY WINE, APR 13 2019
! RUBY SUX — GOLANG RULEZ!!!11 DISCLAIMER
! RUBY SUX — GOLANG RULEZ!!!11 DISCLAIMER
whoami Nihad Abbasov github.com/narkoz
[email protected]
Agenda Introduction 01 Why Golang Comparing syntax and features Additional
resources 02 03 04
None
Go is a modern, general purpose language.
Created in 2009 SECTION ONE
by Google for Google SECTION ONE
Go’s Creators • Ken Thompson (B, C, Unix, UTF-8) •
Rob Pike (Unix, UTF-8) • Robert Griesmer (V8, HotSpot, JVM)
Go Today
Rewrite from Java to Go https://twitter.com/rob_pike/status/878412416127606784
Why Golang? SECTION TWO
“Go at Google: Language Design in the Service of Software
Engineering” https://talks.golang.org/2012/splash.article SECTION TWO
Key points • must work at scale • must be
familiar, roughly C-like • must be modern
Enter Go + Fast: fast compilation like interpreted language +
Safe: strongly and statically typed and garbage collected + Easy: concise, easy to read + Modern: built in support for multi-core networked distributed applications
Popular areas where Go is used https://blog.golang.org/survey2018-results
Software written in Go https://blog.golang.org/survey2018-results
Getting started SECTION THREE
PROJECT LAYOUT https://golang.org/doc/code.html#Workspaces
HELLO WORLD package main import "fmt" func main() { fmt.Println("Hello,
World!") }
RUNNING THE CODE go build hello-world.go ./hello-world
RUNNING THE CODE go run hello-world.go
Basic syntax SECTION THREE
Keywords https://golang.org/ref/spec#Keywords The following keywords are reserved and may not
be used as identifiers.
Data types SECTION THREE
Data Types • Boolean types: true, false • Numeric types:
integers, floats • String types • Derived types: pointers, arrays, structs, functions, slices, interfaces, maps, channels
Variables SECTION THREE
VARIABLES var x float64 x = 20.0 // same as
above var x float64 = 20.0 foo := 42 var a, b, c = 3, 4, "foo" Static Declaration Dynamic Declaration Mixed Declaration
Conditionals SECTION THREE
CONDITIONALS if 7%2 == 0 { fmt.Println("7 is even") }
else { fmt.Println("7 is odd") } if/else if 8%4 == 0 { fmt.Println("8 is divisible by 4") } if statement without an else
CONDITIONALS t := time.Now() switch { case t.Hour() < 12:
fmt.Println("It’s before noon") default: fmt.Println("It’s after noon") } switch
Loops SECTION THREE
{ LOOPS for for loop until while
LOOPS i := 1 for i <= 3 { fmt.Println(i)
i = i + 1 } single condition for i := 0, i < 3; i++ { fmt.Println(i) } initial/condition/after
LOOPS for { fmt.Println("loop") break } for without a condition
Slices SECTION THREE
SLICES s := make([]string, 3) s[0] = "a" s[1] =
"b" s[2] = "c" s = append(s, "d", "e")
Maps SECTION THREE
MAPS m := map[string]int{ "foo": 1, "bar": 2 } fmt.Println(m["foo"])
Functions SECTION THREE
FUNCTIONS func FunctionName([parameter_name type]) [return_types] { // body of the
function } func plus(a int, b int) int { return a + b } sum := plus(1, 2)
FUNCTIONS func vals() (int, int) { return 3, 7 }
Exceptions SECTION THREE
EXCEPTIONS result, err:= Sqrt(-1) if err != nil { fmt.Println(err)
}
Concurrency SECTION THREE
Concurrency != Parallelism SECTION THREE https://blog.golang.org/concurrency-is-not-parallelism
Concurrency is the composition of independently executed processes, while parallelism,
is the simultaneous execution. Rob Pike
GOROUTINES func f(n int) { for i := 0; i
< 10; i++ { fmt.Println(n, ":", i) } } func main() { go f(0) var input string fmt.Scanln(&input) }
CHANNELS func main() { messages := make(chan string) go func()
{ messages <- "ping" }() msg := <-messages fmt.Println(msg) }
Is Go object oriented? SECTION THREE
STRUCTS type Person struct { name string age int }
p := Person{"John", 20} fmt.Println(p.name)
INTERFACES type Animal interface { Speak() string } type Cat
struct { } func (c Cat) Speak() string { return "Meow!" }
Resources SECTION FOUR
RESOURCES The Go Programming Language by Alan Donovan Brian Kernighan
RESOURCES List of Golang books https://github.com/dariubs/GoBooks
RESOURCES A curated list of awesome Go frameworks, libraries and
software https://github.com/avelino/awesome-go https://awesome-go.com/
RESOURCES Go Playground https://play.golang.org/ Go Tour https://tour.golang.org/
RESOURCES A weekly newsletter about the Go programming language https://golangweekly.com/
RESOURCES “Goby is an object-oriented interpreter language deeply inspired by
Ruby as well as its core implementation by 100% pure Go” https://github.com/goby-lang/goby
Thanks! THE END