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
0
98
コードで遊ぼう 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
160
コードで遊ぼう Haskell #2.0
wooyoowaan
0
87
コードで遊ぼう Haskell #2.1
wooyoowaan
0
87
LTだよ!!全員集合!!
wooyoowaan
0
120
Other Decks in Programming
See All in Programming
生成 AI 時代のスナップショットテストってやつを見せてあげますよ(α版)
ojun9
0
200
Understanding Apache Lucene - More than just full-text search
spinscale
0
120
ふつうのRubyist、ちいさなデバイス、大きな一年 / Ordinary Rubyists, Tiny Devices, Big Year
chobishiba
1
460
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
530
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
560
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
110
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
580
AI Assistants for Your Angular Solutions
manfredsteyer
PRO
0
140
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.9k
受け入れテスト駆動開発(ATDD)×AI駆動開発 AI時代のATDDの取り組み方を考える
kztakasaki
2
590
AI時代のシステム設計:ドメインモデルで変更しやすさを守る設計戦略
masuda220
PRO
5
1k
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
990
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
740
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.1k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
160
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
310
Context Engineering - Making Every Token Count
addyosmani
9
750
The Curse of the Amulet
leimatthew05
1
10k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
74
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
130
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
92
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 ࠓͰ͢ʂʂ ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠