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
今更始めるGo言語 / techcamp04
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Yuichi Goto
January 24, 2018
Programming
3.2k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
今更始めるGo言語 / techcamp04
第4回開発合宿(2017/01/24)
Yuichi Goto
January 24, 2018
More Decks by Yuichi Goto
See All by Yuichi Goto
[Teaser] Type-Safe Lightweight DDD with Effect Schema
yasaichi
3
580
Google Cloud を用いたソフトウェア開発の内製化組織の早期立ち上げの実現 / Rapid Establishment of In-House Software Development Teams Using Google Cloud
yasaichi
1
1.7k
[EN] Robust and Scalable API Gateway Built on Effect
yasaichi
3
490
Effectで作る堅牢でスケーラブルなAPIゲートウェイ / Robust and Scalable API Gateway Built on Effect
yasaichi
9
2.5k
あるRailsエンジニアがビジネスリーダーに転身するまで
yasaichi
9
3.4k
Active Recordから考える次の10年を見据えた技術選定 / Architecture decision for the next 10 years at PIXTA
yasaichi
50
23k
Active Recordから考える次世代のRuby on Railsの方向性 / Directions for the next generation of Ruby on Rails: From the viewpoint of its Active Record
yasaichi
38
22k
ピクスタのエンジニアリングとCircleCI / Software Engineering with CircleCI at PIXTA
yasaichi
1
490
Ruby on Railsの正体と向き合い方 / What is Ruby on Rails and how to deal with it?
yasaichi
147
96k
Other Decks in Programming
See All in Programming
[DroidKaigi 26] How We Moved from Android Studio to Slack
thisaay
0
160
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
120
Jindong: Introducing Declarative Haptics in Compose Multiplatform
l2hyunwoo
0
140
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
280
PyO3 で既存 Python 評価器を Rust core 化する ー wasm-bindgen でブラウザにも配るための設計
kdash
1
290
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
「つくるAI」だけではバグは見つからない ~テストに必要な「見つけるAI」を分離させる戦略~
mfunaki
0
230
バグを直したら useEffect が消えた
colorful12
3
820
週末にAI-DLCを本気で回したら$1,600溶けた
hbashimizu
0
120
リアルな遅延を測る仕様
kota_yata
1
140
What We Talk About When We Talk About XP
m_seki
2
210
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Automating Front-end Workflow
addyosmani
1369
210k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
How to Talk to Developers About Accessibility
jct
2
530
Documentation Writing (for coders)
carmenintech
77
5.5k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
220
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
440
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Building the Perfect Custom Keyboard
takai
2
860
Rails Girls Zürich Keynote
gr2m
96
14k
Making the Leap to Tech Lead
cromwellryan
135
10k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
760
Transcript
今更始めるGo言語 Yuichi Goto (@_yasaichi) Jan 21, 2018 @ 第4回開発合宿成果発表
Agenda 背景と目的 技術概要 やったこと 所感 2
http://web-salad.hateblo.jp/entry/2018/01/15/090000 3 先日、こんなエントリを書きました
サーバーサイド開発で利用される言語のマトリックス(前述のエントリより) 4
背景1: 技術検証 • 最近考えているテーマ: モノリシックなRailsアプリ ケーションの刷新時にどの言語を選択すべきか? • 型と並行計算モデルの有無の2軸で捉えてみた • この観点においてはGoかScalaという結論に
• 判断精度向上のためにGo(未経験)を触ってみよう 5
背景2: 自身のスキル開発 • クライアントサイド: React, React Native(第3回) • サーバーサイド •
爆速モノリシック: Ruby on Rails • BFF: Node.js • マイクロサービス: ? 6 ここに当てはまる言語・フレーム ワークを抑えたい
今回の目的: 今更始めるGo言語 • 合宿で明らかにしたかったこと • 言語自体の手触りはどんな感じ? • IDEなどの周辺環境はどんな感じ? • 最終的に明らかにしたいこと
• APIサーバーを書くとしたらどんな感じ? 7
Agenda ɹ 背景と目的 技術概要 やったこと 所感 8
Go #とは • Googleが開発したプログラミング言語 • 2009年11月に公開され、最新バージョンは1.9.2 • 静的型付け • goroutineによる並行計算のサポート
• クロスコンパイルのサポート 9
サンプル: Hello, World! package main import ( "fmt" ) func
main() { fmt.Println("Hello, World!") } 10 $ go run main.go Hello, World!
Agenda ɹ 背景と目的 ɹ 技術概要 やったこと 所感 11
そうだ REPL、作ろう • REPL(Read-Eval-Print-Loop)とは • 対話型評価環境のこと、RubyでいうIRB • Goでは • 言語標準のREPLは存在しない(!)
• 数ある実装の中では motemen/gore が人気 12
デモ 13
デモでは見せませんでしたが… • 式の評価とPrettyprintしか実装できてません • 後者は k0kubun/pp を利用しているので、実質 式の評価しか実装してません • わかってはいたが、やはり題材が難しかった
• @motemen さんはすごい人(小並感) 14
仕組み • goreとだいたい同じ 1. 入力された式を評価して標準出力に表示する 一時的なソースコードを生成する 2. 1を go run
で実行して得られた結果を返す 3. 1-2をユーザーが中断するまで繰り返し 15 ここが難しいところで、具体的には AST周りをわかっていないとダメ
Agenda ɹ 背景と目的 ɹ 技術概要 ɹ やったこと 所感 16
良かったところ • 言語の手触り: 21世紀のC言語 or Better C • 言語仕様が小さくキャッチアップがしやすい •
↑とgofmtにより誰が書いても同じ感じになる • IDEなどの周辺環境: ポータブル • 標準ツールが充実しており、エディタを選ばない 17
苦しかったところ • 言語仕様の小ささや引き算の負の側面 • 例1: 例外がないので、 foo, err = …;
if err != nil のようなコードを至るところで書くことになる • 例2: mapのような高階関数がないのでfor文を 使うしかなく、愚直なコードになりがち ※ 始めたばかりなので慣れてきたらまた変わるかも 18
お疲れさまでした! 成果物: https://github.com/yasaichi-sandbox/cheney 19