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
Livesense Inc.
PRO
May 15, 2014
Programming
1
1.6k
About Go Lang
2014/5/9 Livesense SICP倶楽部LT大会にて
Goについての解説
Livesense Inc.
PRO
May 15, 2014
Tweet
Share
More Decks by Livesense Inc.
See All by Livesense Inc.
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
310
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
17
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
0
1.4k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
400
26新卒_総合職採用_会社説明資料
livesense
PRO
0
9k
株式会社リブセンス会社紹介資料 / Invent the next common.
livesense
PRO
1
28k
26新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
1
12k
中途セールス職_会社説明資料
livesense
PRO
0
250
EM候補者向け転職会議説明資料
livesense
PRO
0
120
Other Decks in Programming
See All in Programming
なぜ適用するか、移行して理解するClean Architecture 〜構造を超えて設計を継承する〜 / Why Apply, Migrate and Understand Clean Architecture - Inherit Design Beyond Structure
seike460
PRO
3
760
A full stack side project webapp all in Kotlin (KotlinConf 2025)
dankim
0
120
テストから始めるAgentic Coding 〜Claude Codeと共に行うTDD〜 / Agentic Coding starts with testing
rkaga
12
4.4k
A2A プロトコルを試してみる
azukiazusa1
2
1.4k
プロダクト志向ってなんなんだろうね
righttouch
PRO
0
190
Hack Claude Code with Claude Code
choplin
4
2k
Porting a visionOS App to Android XR
akkeylab
0
460
#kanrk08 / 公開版 PicoRubyとマイコンでの自作トレーニング計測装置を用いたワークアウトの理想と現実
bash0c7
1
770
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
650
PicoRuby on Rails
makicamel
2
130
10 Costly Database Performance Mistakes (And How To Fix Them)
andyatkinson
0
330
チームで開発し事業を加速するための"良い"設計の考え方 @ サポーターズCoLab 2025-07-08
agatan
1
420
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
The World Runs on Bad Software
bkeepers
PRO
69
11k
Art, The Web, and Tiny UX
lynnandtonic
299
21k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
32
2.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.5k
The Language of Interfaces
destraynor
158
25k
The Pragmatic Product Professional
lauravandoore
35
6.7k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
46
9.6k
Optimising Largest Contentful Paint
csswizardry
37
3.3k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
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と比べて優位性は無いように見える
終わり 質疑応答