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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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新卒_総合職採用_会社説明資料
livesense
PRO
0
2.5k
27新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
0
6.4k
株式会社リブセンス・転職会議 採用候補者様向け資料
livesense
PRO
0
170
株式会社リブセンス 会社説明資料(報道関係者様向け)
livesense
PRO
0
1.6k
データ基盤の負債解消のためのリプレイス
livesense
PRO
0
550
26新卒_総合職採用_会社説明資料
livesense
PRO
0
12k
株式会社リブセンス会社紹介資料 / Invent the next common.
livesense
PRO
2
51k
26新卒_Webエンジニア職採用_会社説明資料
livesense
PRO
1
13k
中途セールス職_会社説明資料
livesense
PRO
0
290
Other Decks in Programming
See All in Programming
AI & Enginnering
codelynx
0
110
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
6k
CSC307 Lecture 06
javiergs
PRO
0
680
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
160
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
520
Lambda のコードストレージ容量に気をつけましょう
tattwan718
0
110
2026年 エンジニアリング自己学習法
yumechi
0
130
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
16
6k
AI巻き込み型コードレビューのススメ
nealle
1
140
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.8k
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
150
Featured
See All Featured
My Coaching Mixtape
mlcsv
0
47
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.4k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.6k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
0
1.1k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
So, you think you're a good person
axbom
PRO
2
1.9k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
410
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
72
How to Ace a Technical Interview
jacobian
281
24k
How to train your dragon (web standard)
notwaldorf
97
6.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と比べて優位性は無いように見える
終わり 質疑応答