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
About Go Lang
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Livesense Inc.
PRO
May 15, 2014
Programming
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
About Go Lang
2014/5/9 Livesense SICP倶楽部LT大会にて
Goについての解説
Livesense Inc.
PRO
May 15, 2014
More Decks by Livesense Inc.
See All by Livesense Inc.
Rubyはただの⾔語に⾮ず
livesense
PRO
0
500
28新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
120
27新卒_総合職採用_会社説明資料
livesense
PRO
0
6.8k
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
12k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
530
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
1
1.8k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
670
26新卒_総合職採用_会社説明資料
livesense
PRO
0
13k
株式会社リブセンス会社紹介資料 / Invent the next common.
livesense
PRO
2
73k
Other Decks in Programming
See All in Programming
使いながら育てる Claude Code — 開発フローの1コマンド化 × 繰り返し指摘の自動仕組み化
shiki_kakaku
0
1.9k
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
350
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
220
30年振りにコンパイラの定数整数除算を改善した
herumi
9
4.1k
仕様駆動開発の消費期限
watany
20
8.9k
レビュー履歴をAIに食わせて、 Compose移行を加速するs
shihochan
0
190
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
590
初めての模倣学習とVLA
natsutan
0
190
まずはプロンプトガイドを読もう、話はそれからだ
kiakiraki
1
200
KotlinConf Extended South Korea 2026 Keynote
l2hyunwoo
0
120
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
240
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
710
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
660
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
sira's awesome portfolio website redesign presentation
elsirapls
0
340
WENDY [Excerpt]
tessaabrams
11
39k
Deep Space Network (abreviated)
tonyrice
0
270
The browser strikes back
jonoalderson
0
1.5k
Building Adaptive Systems
keathley
44
3.2k
A designer walks into a library…
pauljervisheath
211
24k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
380
It's Worth the Effort
3n
188
29k
Producing Creativity
orderedlist
PRO
348
40k
A Soul's Torment
seathinner
6
3.5k
Transcript
GO言語 岡前直由
Agenda • Go言語とは • 特徴 • 言語仕様 • Interface •
並列処理の仕組み
Go言語とは • Googleが開発したコンパイラ言語 • 2009年、Robert Griesemer, Rob Pike, Ken Thompson
• 対象:大規模なシステムソフトウェア、サーバソフトウェア • 低レイヤとの親和性(プロセス管理、システムコール…) • C/C++に並ぶ実行速度 • 開発者の増大に耐える、シンプルな洗練された言語セット C/C++に代わる新しい選択肢
Go言語の特徴 • 静的型付け + 型推論 • ネイティブコードへのコンパイル • Linux, OS
X, Free BSD, Windows • DuckTyping • ガベージコレクション • 豊富なライブラリ C言語に動的型付け言語の技術を取り込んだ
言語仕様 • 基本はCの拡張 • 関数と構造体(+メソッド) • 基本文法は大きく変化 • 変数・関数宣言の型は後置 •
var message string = "hello" • 変数宣言時に型の明示が不要(型推論) • message := "hello" • ループはfor文のみ • 基本方針:シンプルかつ必要十分な言語セット
言語仕様(続き) • クラス階層が存在しない • 継承が存在しない • 簡易な委譲の仕組みが提供されている • 複数戻り値、複数同時代入 •
a, b = b, a • ポインタ演算は存在しない • 配列に対するアドレス加算などはできない • Slice • 固定長配列をラップした組み込み型 • メモリ領域の再確保などを容易に行える • 第一級関数 • クロージャが作れる • コールバック関数など • Interfaceを用いたDuckTypingの実現 • 並列処理を容易にする機能 • Goroutine, Channel
いわゆる「クラス」の表現 type!Vertex!struct!{! !!X,!Y!float64! }! !! func!(v!*Vertex)!Abs()!float64!{! !!return!math.Sqrt(v.X*v.X!+!v.Y*v.Y)! }! !! func!main()!{!
!!v!:=!&Vertex{3,!4}! !!fmt.Println(v.Abs())! }! struct メソッド +
Interface • 大体Javaと同じ • 抽象と具象を分離 • ポリモーフィズムを実現 • 実装型でimplements宣言は不要 •
DuckTypingを実現 type!Abser!interface!{! !!Abs()!float64! }! インターフェース宣言:メソッド型定義の羅列
実装型 • 必要なメソッドを実装するだけ type!Vertex!struct!{! !!X,!Y!float64! }! !! func!(v!*Vertex)!Abs()!float64!{! !!return!math.Sqrt(v.X*v.X!+!v.Y*v.Y)! }!
Vertex構造体(再掲) インターフェースAbserを実装しているとみなされる
Interface型の利用 • Interface型を引数に取る関数を定義すると... • Vertex型だけじゃなく、Abs()を実装した型はなんでも入れられ る func!showAbs(a!Abser)!{! !!fmt.Println(a.Abs())! }! 静的なDuckTypingを実現
並列処理 Foo() Bar() Baz() go Foo() go Bar() Baz() 逐次処理
並列処理 Foo(), Bar()はそれぞれ新しい Goroutineで並列実行される • Goroutine(ゴルーチン)という仕組みを使う • スレッドのようなもの
Goroutineとは • 概ねスレッドのようなもの • Goroutine != スレッド • スレッドをさらに分割したもの •
一つのスレッドに複数のGoroutine • 軽量 • たくさん立ち上げられる Goroutine プロセス スレッド スレッド Goroutine
Goroutine間の通信 • 1. 共有メモリを使う • Mutexが用意されている • 2. Channelという仕組みを使う •
Goが推奨する並行処理モデル • メッセージパッシング • Go曰く:"Do not communicate by sharing memory; instead, share memory by communicating" メモリ共有によって通信するのではなく、通信によってメモリを共有しろ
Channel func RoutineA(c chan int) {
... c <-‐ v ... } func RoutineB(c chan int) { ... var v := <-‐c ... } • 値の交換と同期を担ってくれる RoutineAが c <- v を実行するまで ブロックされる channel c
まとめ • Go言語はC/C++に動的言語の流行技術を取り込んだ • 速度が要求される低レイヤのシステムで生産性が上がりそう • DockerはGoで書かれている • Webアプリケーションとの親和性は不明 •
Rubyと比べて優位性は無いように見える
終わり 質疑応答