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 #1
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
YooWaan
October 02, 2015
Programming
98
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
コードで遊ぼう Go #1
source Code
https://bitbucket.org/BP-YooWaan/enjoycode
YooWaan
October 02, 2015
More Decks by YooWaan
See All by YooWaan
極限までGoogleに迎合した エコシステムの話 やり込み出来てない版
wooyoowaan
0
120
擬人化アーキテクチャ(あんまり擬人擬人してないけど)
wooyoowaan
0
160
コードで遊ぼう Haskell #2.0
wooyoowaan
0
88
コードで遊ぼう Haskell #2.1
wooyoowaan
0
88
LTだよ!!全員集合!!
wooyoowaan
0
120
Other Decks in Programming
See All in Programming
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
510
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
540
dRuby over BLE
makicamel
2
330
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
190
Mujeres en SEO Summit 2026 - Greatest Disaster Hits en Web Performance
guaca
0
170
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
正しくソフトウェアを作る、前提を疑うための認知の視点 / doubt-premise
minodriven
21
6.6k
AI 時代のソフトウェア設計の学び方
masuda220
PRO
29
12k
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
570
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
190
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.5k
Hunting Vulnerabilities in Symfony with LLMs
vinceamstoutz
0
540
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
190
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Thoughts on Productivity
jonyablonski
76
5.2k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
For a Future-Friendly Web
brad_frost
183
10k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
290
The Curse of the Amulet
leimatthew05
1
13k
We Have a Design System, Now What?
morganepeng
55
8.2k
Transcript
ίʔυͰ༡΅͏ #ͦͷ̍ Go
ࠓͷ Go ͍͍ͱ͜Ζ ΘΔ͍ͱ͜Ζ →ωοτͷ·ͱΊͷ·ͱΊ ͦΕΆ͍ C++ͱൺֱ͠ͳ͕Βɾɾɾ ίʔυͪ͜Β͔Β https://bitbucket.org/BP-YooWaan/enjoycode/src
͍͍ͱ͜Ζ ΘΔ͍ͱ͜Ζ
͍͍ͱ͜Ζ GoogleͰ࡞ͬͯ·͢ ʢ৴པͰ͖Δ͎ʙʣ ҎԼʹରॲ - ιϑτΣΞ։ൃ - ѻ͍ʹ͍͘λΠϓ - Multiple
core/concurrency ػೳ - ੩తϦϯΫωΠςΟϒόΠφϦ - GC (ΨϕʔδίϨΫγϣϯ) - ڧ͍ܕ͚ - Gorutines / Channels ͱ͔ - Structs (ߏମ) / Interface
ΘΔ͍ͱ͜Ζ Go ͰάάΔͱݴޠͱؔͳ͍݁Ռ͕ग़ͯ͘Δɾɾɾ ൚༻ϓϩάϥϛϯά ݴޠ֦ுੑ ܕਪ ෆมੑ ৄࡉͪ͜ΒʰGoݴޠ͕μϝͳཧ༝ ʱ(
http://postd.cc/why-go-is-not-good/ ) ੍ޚϑϩʔߏ ΈࠐΈϓϩάϥϛϯά
ͦΕͬΆ͍
։ൃڥతͳ͜ͱ Go C proj.gyp # gyp ઃఆϑΝΠϧ inc/ # ϔομʔϑΝΠϧ
src/ # ιʔεϑΝΠϧ out/Default build.ninja # gyp ੜϑΝΠϧ gyp-mac-tool # ಉ͡ obj/ <target>.ninja # ϦϯΫΦϓγϣϯͱ͔ *.o # ΦϒδΣΫτϑΝΠϧ
ίϚϯυϦϑΝϨϯε Go C # ϏϧυσΟΫϨτϦੜ $ GYP_GENERATORS=ninja gyp proj.gyp
--toplevel-dir=. —depth=0 # build $ cd out/Default ; ninja # ࣮ߦ ./bin/{ exe file } # ࣮ߦίϚϯυදࣔ $ ninja -t command # ࡞ۀσΟϨΫτϦͷઃఆ $ export GOPATH={path to dir} # build $ go install {package name} # ࣮ߦ $ ./bin/{ exe file } # ใදࣔ $ go env
ྫ Goͷ߹ GOPATH ʢ࡞ۀσΟϨΫτϦʣઃఆ όΠφϦ࡞ ࣮ߦ όΠφϦ
ྫ C++ͷ߹ ϏϧυσΟϨΫτϦ࡞ Ϗϧυ όΠφϦ
ߏจతͳʂʁ ίʔσΟϯά ʮϊϦLL͚ͩͲࠢCʯͱ͍͏ײ͡ ϙΠϯλ༗Γ·͢ ྻɺϚοϓ༗Γ·͢ Τϥʔϋϯυϧɺฒྻॲཧ ಠࣗͰ͢
ϙΠϯλΫϦιπ C++(C) Go
ྻ/Mapૢ࡞ C++(C) Go Goָ͕͚ͩͲ ѹউײͳ͍
Τϥʔϋϯυϧ C++(C) ׂѪ Go جຊతʹΓఆ panic ϥϯλΠϜΤϥʔ༻ recover() Ͱ෮چ
ߏମɺΠϯλʔϑΣΠε Ϋϥεແ͍͚ͲɺΧϓηϧԽՄೳʂʁ ଟଶੑ͋ΔΑ ʢμοΫλΠϐϯάʣ ߏମͷϝιου͋ΔΑ ΠϯλʔϑΣΠεͷϙΠϯλ৽
ߏମ Go ߏମఆٛ ϝιουఆٛ ຒΊࠐΜͰϑΟʔϧυՃ
ߏମ C++(C) Ϋϥεఆٛ Ϋϥε::ϝιουఆٛ Ϋϥεఆٛ Ϋϥε::ϝιουఆٛ λΠϓྔͺͳ͍
ΠϯλʔϑΣΠε C++(C) Go ͓·͡ͳ͍Ͱͳ͘ ҙຯ͕͋Δ
main() C++(C) Go ϝϞϦϙΠϯλΛཧղ͠ͳ͍ͱμϝ ໊લۭؒͱ͔ . or -> ͳͷ͔ͱ͔ཧղ͠ͳ͍ͱμϝ
࣮ߦ C++(C) Go ϙΠϯλͷࢀর͕ΧϯτΞοϓ είʔϓΛൈ͚ΔͱσετϥΫλΛ࣮ߦ int64ͱFloatͰܭࢉ݁Ռ͕ҟͳΔ
ฒߦɺνϟϯωϧ CPUͱ͔ߟ͑ͣʹ͍͍ײ͡ʹฒߦॲཧͯ͘͠Ε·͢ ফඅϝϞϦ͘͢ͳ͍Α
C++(C) Go go Ͱ࣮ߦ join Ͱ͢ΑͶʔ SleepͳΓ ϧʔϓ͠ͳ ͍ͱɾɾɾ mutexͱ͔͍ΔΑͶ
ίʔυࣗମ ͲͬͪͲͬͪ
࣮ߦ C++(C) Go ՈͷMac mini ͰޮՌ͕͋ͬͨ Macbook Pro Ͱٯʹ͍ɾɾɾ thread
͏ͱ͍Ͷ ฒߦॲཧʹ ͢ΔͱͲͬͪ fib(30)͕ ࠷ॳʹྃ
ิ C++(C) Go out/Default/obj/run_thread.ninja ʹ flags_cc = -std=c++11 ͕ͳ͍ͱμϝ mainؔଆͷfor
ͷ close(ch) , beak ΛίϝϯτΞτ ͢Δͱ deadlock ͯ͠ϓΪϟΕΔΑ (mainؔ୭௨͠ͳ͘ͳͨͷͰ)
ґଘؔ ࣗͰղܾ C,C++ͱ͔(άάͬͨΒclibͱ͔ग़͖ͯͨ…) πʔϧͰղܾ java (maven, gradle, sbt) ݴޠσϑΝΫτཧπʔϧ npm,
pip, gem, cpan (JS, python, ruby,perl) ͋ΔΑ Go (ศརͱݴͬͯͳ͍) $ go get <package name>
ߟʢࢲͷ߹ʣ ٕज़తʹઑͬͨཁ͕݅ͳ͚Ε Go Ͱ͍͍ͱࢥ͏ ΨνҙతͰͳ͍ʢΑ͏ʹݟ͑Δʣ ϓϩάϥϜݴޠΛ͖ͪΜͱධՁͨ͠Γɺཧղͨ͠Γ͍ͨ͠ਓɺ ผ్͓ษڧ͕ඞཁ ৽ਓݚमͱ͔͜ΕͰ͍͍͔ ʢJavaΑΓɾɾɾʣ CʴʴΛٱ͠ͿΓʹॻ͘ͱؾ͍͍࣋ͪ
ߟʢωοτͷ߹ʣ
ߟʢωοτͷ߹ʣ
ߟʢωοτͷ߹ʣ
ࢀߟ Go Features and Case Studies https://speakerdeck.com/ianlewis/go-features-and-case-studies Google’s Go Language
http://functionspace.com/topic/2961/Google--039;s-Go-Language Goݴޠ͕μϝͳཧ༝ http://postd.cc/why-go-is-not-good/ Goίʔυͷॻ͖ํ http://golang-jp.org/doc/code.html
ࢀߟ Go Docs http://golang-jp.org/doc/ Go FAQ https://golang.org/doc/faq Less is exponentially
more (ωοτͷݪจ) http://commandcenter.blogspot.jp/2012/06/less-is-exponentially-more.html Go : Γ্͕Γײ (hype) Λ࣮ྗʹ͢Δ͜ͱ͕ॏཁ ʢҾ༻ݩʣ http://wazanova.jp/post/63408341634/go-hype
Go Go Go ࠓͰ͢ʂʂ ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠