Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
今更始めるGo言語 / techcamp04
yasaichi
January 24, 2018
Programming
0
2.7k
今更始めるGo言語 / techcamp04
第4回開発合宿(2017/01/24)
yasaichi
January 24, 2018
Tweet
Share
More Decks by yasaichi
See All by yasaichi
Active Recordから考える次の10年を見据えた技術選定 / Architecture decision for the next 10 years at PIXTA
yasaichi
46
17k
Active Recordから考える次世代のRuby on Railsの方向性 / Directions for the next generation of Ruby on Rails: From the viewpoint of its Active Record
yasaichi
36
16k
ピクスタのエンジニアリングとCircleCI / Software Engineering with CircleCI at PIXTA
yasaichi
1
260
Ruby on Railsの正体と向き合い方 / What is Ruby on Rails and how to deal with it?
yasaichi
131
75k
SSR以後の世界へ / techcamp05
yasaichi
3
1.3k
サービス開発の現場からOSSを生み出す思考技術 / genbaweb04
yasaichi
3
770
Capybaraで変更に強いE2Eテストを書く / TokyuRubyKaigi12
yasaichi
5
1.3k
とある企業のモバイル対応 / Rails Developers Meetup 2017
yasaichi
1
3.2k
テスト駆動開発と私 / TechBookWalk TDD
yasaichi
3
1.6k
Other Decks in Programming
See All in Programming
ベストプラクティス・ドリフト
sssssssssssshhhhhhhhhh
1
210
Register-based calling convention for Go functions
cjamhe01385
0
410
パスワードに関する最近の動向
kenchan0130
1
330
2022 - COSCUP - 打造高速 Ruby 專案開發流程
elct9620
0
100
10歳の minne から、これから長く続くプロダクトを作るすべての人へ
tsumichan
9
3.7k
Pythonで鉄道指向プログラミング
usabarashi
0
130
Now in Android Overview
aosa4054
1
410
There's an API for that!
mariatta
PRO
0
110
WindowsコンテナDojo: 第4回 Red Hat OpenShift Localを使ってみよう
oniak3ibm
PRO
0
190
SRE NEXT 2022に学ぶこれからのSREキャリア
fukubaka0825
2
390
Atomic Design とテストの○○な話
takfjp
2
820
クラウド KMS の活用 / TOKYO BLOCKCHAIN TECH MEETUP 2022
odanado
PRO
0
190
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
27
1.6k
Designing Experiences People Love
moore
130
22k
The Brand Is Dead. Long Live the Brand.
mthomps
46
2.7k
Debugging Ruby Performance
tmm1
65
10k
Making the Leap to Tech Lead
cromwellryan
113
7.4k
YesSQL, Process and Tooling at Scale
rocio
157
12k
BBQ
matthewcrist
74
7.9k
Writing Fast Ruby
sferik
612
57k
Bash Introduction
62gerente
598
210k
Faster Mobile Websites
deanohume
294
28k
Principles of Awesome APIs and How to Build Them.
keavy
113
15k
Happy Clients
brianwarren
89
5.6k
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