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
YooWaan
October 02, 2015
Programming
0
91
コードで遊ぼう Go #1
source Code
https://bitbucket.org/BP-YooWaan/enjoycode
YooWaan
October 02, 2015
Tweet
Share
More Decks by YooWaan
See All by YooWaan
極限までGoogleに迎合した エコシステムの話 やり込み出来てない版
wooyoowaan
0
120
擬人化アーキテクチャ(あんまり擬人擬人してないけど)
wooyoowaan
0
140
コードで遊ぼう Haskell #2.0
wooyoowaan
0
78
コードで遊ぼう Haskell #2.1
wooyoowaan
0
79
LTだよ!!全員集合!!
wooyoowaan
0
110
Other Decks in Programming
See All in Programming
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
650
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
310
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
距離関数を極める! / SESSIONS 2024
gam0022
0
300
Macとオーディオ再生 2024/11/02
yusukeito
0
380
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
210
Ethereum_.pdf
nekomatu
0
470
カンファレンスの「アレ」Webでなんとかしませんか? / Conference “thing” Why don't you do something about it on the Web?
dero1to
1
110
CSC509 Lecture 12
javiergs
PRO
0
160
React への依存を最小にするフロントエンド設計
takonda
15
4.1k
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
120
Figma Dev Modeで変わる!Flutterの開発体験
watanave
0
150
Featured
See All Featured
Facilitating Awesome Meetings
lara
50
6.1k
4 Signs Your Business is Dying
shpigford
180
21k
Thoughts on Productivity
jonyablonski
67
4.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Building Your Own Lightsaber
phodgson
103
6.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
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 ࠓͰ͢ʂʂ ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠