SlideShare una empresa de Scribd logo
1 de 68
History
"What should a modern, practical programming language look like?"
History
Design began in late 2007.
History
system programming.
10 November 2009: Go was released. (78c47c3)
The Release
Open Source
"Go is an open source programming language that makes
it easy to build simple, reliable, and efficient software."
What is Go?
https://golang.org/
Why Go?
https://talks.golang.org/2016/applicative.slide#6
Why Go?
• Problem 1: System Scale
• designed to scale to 10⁶⁺ machines
• everyday jobs run on 1000s of machines
• jobs coordinate, interact with others in the system
• lots going on at once
• Solution: great support for concurrency
• Problem 2: Engineering Scale
• 5000+ developers across 40+ offices
• 20+ changes per minute
• 50% of code base changes every month
• 50 million test cases executed per day
• single code tree
• Solution: design the language for large code bases
Who uses Go at Google?
• Hundreds of projects. Thousands of Go programmers. Millions of lines of Go code.
• Public examples:
• Flywheel: SPDY proxy for Chrome on mobile devices
• dl.google.com: Download server for Chrome, ChromeOS, Android SDK, Earth, etc.
• Vitess: YouTube MySQL balancer
• Seesaw: Linux Virtual Server (LVS) based load balancer
• Lingo: Logs analysis in Go, migrated from Sawzall
• The target is networked servers, but Go is a great general-purpose language.
"Go: 90% Perfect, 100% of the time" -bradfitz, 2014
2016 Skills On the Rise
http://www.payscale.com/data-packages/job-skills?utm_content=bufferf478a&utm_medium=social&utm_source=linkedin.com&utm_campaign=buffer
• 빠른 개발속도
• 모듈화를 위한 의존성
• 정적타입이지만 동적타입 언어의 속성도 가진 언어
• 가비지 컬렉션 (Garbage Collection) // No VM
• 쉬운 병렬처리 (Parallelism)
• 빠른 컴파일 속도
• 소스코드 UTF-8
The feature of Go
• No classes
• No inheritance
• No constructors
• No final
• No exceptions
• No annotations
• No user-defined generics
Not the feature of Go
Go 는 Object-Oriented 언어인가?
• 맞기도 하고 아니기도 하다.
• http://golang.org/doc/faq#Is_Go_an_object-oriented_language
• 아닌 이유
• 상속관계가 없다. No subclass
• 맞는 이유
• object-oriented 스타일의 프로그래밍을 허용한다. interface제공.
• object-oriented 스타일의 프로그래밍?
• 상속은 제공하지 않으며 interface만 제공.
• implements"라는 선언 필요없음.
• 단순히 해당 인터페이스의 메소드를 구현하기만 하면 인터페이스 사용가능
Interpreted Language?
Statically compiled language
Fast compilation times
Fast compilation times
• 빠른 컴파일 속도는 Go의 설계 목표중 하나였다.
• 문법이 compiler가 분석하기 용이하게 설계되었고 symbol table없이 구문분석이 가
• Go는 각각의 파일에서 선언한 패키지를 사용하지 않으면 에러가 발생하므로
종속성 트리를 계산하는게 효율적이다.
• Go는 templates과 선언파일(ex .h) 이없다.
• 패키지들이 선형종속성이므로 병렬 컴파일 가능.
• gc compiler
• gccgo compiler
gcc is required only if you plan to use cgo.
Godoc
Go is fast
https://www.techempower.com/benchmarks/#section=data-r12&hw=peak&test=db
Concurrency is not parallelism
Lock Condition
Actor
Communicating Sequential Processes
Actor와 다른점은 Actor 는 pid에게 전달을 하지만 CSP는 anonymous로 channel로 전달함
Channel
Unbuffered Channels
Buffered Channels
Go루틴(Goroutines)
• OS 쓰레드보다 경량화된 Go 쓰레드
• 같은 메모리 공간을 공유해서 다른 Goroutines을 병렬로 실행한다.
• 스택에서 작은 메모리로 시작 필요에 따라 힙 메모리에 할당/해제
• 프로그래머는 쓰레드를 처리하지 않고 마찬가지로 OS도 Goroutine의 존재를 모른
• OS관점에서는 Goroutine은 C program의 event-driven형식처럼 작동한다.
Goroutines vs OS threads
Goroutines OS threads
Memory consumption 2kb 1mb
Setup and teardown
costs
pretty cheap high-priced
Switching costs
(saved/restored)
Program Counter,
Stack Pointer and DX.
ALL registers, that is, 16 general
purpose registers, PC (Program
Counter), SP (Stack Pointer),
segment registers, 16 XMM
registers, FP coprocessor state,
16 AVX registers, all MSRs etc.Goroutine stack size was decreased from 8kB to 2kB in Go 1.4.
Goroutines blocking
• network input
• sleeping
• channel operations or
• blocking on primitives in the sync package.
• call function (case by case)
Go Scheduler
https://www.goinggo.net/2015/02/scheduler-tracing-in-go.html
Go Scheduler
• M: OS threads.
• P: Context to run Go routines.
• G: Go routine.
M0
P
G0
G
G
G
Blocking syscalls
M1
P
G1
(syscall)
G2
G3
G4
M1
P G3
G4
G2
(running)
M2
G1
(wait)
M1
P
G1
(running)
G2
G3
G4
M2
storage
Runtime
Poller
Network I/O call
M1
P
G1
(I/O)
G2
G3
G4
M2M1
P G3
G4G2
G1
(I/O)
M1
P
G1
(I/O)
G2
G3
G4
GOMAXPROCS
GOMAXPROCS = 2
M0
P
G0
G
G
G
Go 언어는 메모리를 관리해주는 가비지 컬렉터(Garbage Collector)가
실행 파일(runtime)안에 내장되어 있습니다.
Garbage Collector
Go isn’t Java: GC Related Go Differences
Garbage Collector
Garbage Collector
Garbage Collector
Garbage Collector
Garbage Collector
Garbage Collector
Garbage Collector
JSON: Increasing Heap Size == Better Performance
Five things that make Go fast
• Values
• Inlining
• Escape Analysis
• Goroutines
• segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
Escape analysis
• Funtion안에 변수가 레퍼런스 타입으로 선언되었는지에 따라 영향받음.
• 만약 레퍼런스 타입이 아니라면 변수는 스택에 안전하게 저장할 수 있다
• 스택에 저장되어있는 값은 할당과 해제 할 필요없다.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
Escape analysis example
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
Escape analysis example
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
Memory model
• Go에서 각 변수는 참조가 존재하는 한 계속 남아 있다.
• 가능하면 Go 컴파일러는 변수를 함수의 스택 프레임(stack frame)에 있는
함수에 지역변수로 할당한다.
• 컴파일러가 함수가 리턴되고 난 후에 변수가 참조되지 않는다는 것을 증명할
수 없다면 컴파일러는 dangling pointer 오류를 피하기 위해서 가비지 콜렉션
이 되는 힙에 변수를
할당해야만 한다.
segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
• No gurd pages
• Check for available stack space is done as part of the function call
• Inital stack size very small, currently 2kb
• Grows as needed
segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
segmented/copying stacks.
http://dave.cheney.net/2014/06/07/five-things-that-make-go-fast
Defer
http://golang.site/go/article/20-Go-defer%EC%99%80-panic
Panic
http://golang.site/go/article/20-Go-defer%EC%99%80-panic
Recover
http://golang.site/go/article/20-Go-defer%EC%99%80-panic
For

Más contenido relacionado

La actualidad más candente

2019 공개SW Contributon NNStreamer 발표자료
2019 공개SW Contributon NNStreamer 발표자료2019 공개SW Contributon NNStreamer 발표자료
2019 공개SW Contributon NNStreamer 발표자료HwanSeokJang1
 
[Live coding] 4회 6 6 (camp-exam_font_test, weather)
[Live coding] 4회 6 6 (camp-exam_font_test, weather)[Live coding] 4회 6 6 (camp-exam_font_test, weather)
[Live coding] 4회 6 6 (camp-exam_font_test, weather)동욱 하
 
그루비로 안드로이드 앱 개발하기
그루비로 안드로이드 앱 개발하기그루비로 안드로이드 앱 개발하기
그루비로 안드로이드 앱 개발하기Sangkyoon Nam
 
How to use Python in Video streaming service - PyCon Korea 2020
How to use Python in Video streaming service - PyCon Korea 2020How to use Python in Video streaming service - PyCon Korea 2020
How to use Python in Video streaming service - PyCon Korea 2020AeYeong Kim
 
Popular Convention 개발기
Popular Convention 개발기Popular Convention 개발기
Popular Convention 개발기JeongHun Byeon
 
[devil's camp] - Crack me (김민재)
[devil's camp] - Crack me (김민재)[devil's camp] - Crack me (김민재)
[devil's camp] - Crack me (김민재)NAVER D2
 
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+githubGit 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+githubJunyoung Lee
 
PyCon 2015 - 업무에서 빠르게 활용하는 PyQt
PyCon 2015 - 업무에서 빠르게 활용하는 PyQtPyCon 2015 - 업무에서 빠르게 활용하는 PyQt
PyCon 2015 - 업무에서 빠르게 활용하는 PyQt덕규 임
 
PyCon2020 NLP beginner's BERT challenge
PyCon2020 NLP beginner's BERT challengePyCon2020 NLP beginner's BERT challenge
PyCon2020 NLP beginner's BERT challengeYoongi Kim
 
제 5회 Lisp 세미나 - Graphics Programming in Clojure
제 5회 Lisp 세미나 - Graphics Programming in Clojure제 5회 Lisp 세미나 - Graphics Programming in Clojure
제 5회 Lisp 세미나 - Graphics Programming in ClojureNAVER D2
 
테스트 주도 개발 By googletest 1장 다중 통화를 지원하는 money 객체
테스트 주도 개발 By googletest   1장 다중 통화를 지원하는 money 객체테스트 주도 개발 By googletest   1장 다중 통화를 지원하는 money 객체
테스트 주도 개발 By googletest 1장 다중 통화를 지원하는 money 객체Mickey SJ Lee
 

La actualidad más candente (11)

2019 공개SW Contributon NNStreamer 발표자료
2019 공개SW Contributon NNStreamer 발표자료2019 공개SW Contributon NNStreamer 발표자료
2019 공개SW Contributon NNStreamer 발표자료
 
[Live coding] 4회 6 6 (camp-exam_font_test, weather)
[Live coding] 4회 6 6 (camp-exam_font_test, weather)[Live coding] 4회 6 6 (camp-exam_font_test, weather)
[Live coding] 4회 6 6 (camp-exam_font_test, weather)
 
그루비로 안드로이드 앱 개발하기
그루비로 안드로이드 앱 개발하기그루비로 안드로이드 앱 개발하기
그루비로 안드로이드 앱 개발하기
 
How to use Python in Video streaming service - PyCon Korea 2020
How to use Python in Video streaming service - PyCon Korea 2020How to use Python in Video streaming service - PyCon Korea 2020
How to use Python in Video streaming service - PyCon Korea 2020
 
Popular Convention 개발기
Popular Convention 개발기Popular Convention 개발기
Popular Convention 개발기
 
[devil's camp] - Crack me (김민재)
[devil's camp] - Crack me (김민재)[devil's camp] - Crack me (김민재)
[devil's camp] - Crack me (김민재)
 
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+githubGit 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
Git 더하기 GitHub(Git클라이언트 활용) / Getting started with git+github
 
PyCon 2015 - 업무에서 빠르게 활용하는 PyQt
PyCon 2015 - 업무에서 빠르게 활용하는 PyQtPyCon 2015 - 업무에서 빠르게 활용하는 PyQt
PyCon 2015 - 업무에서 빠르게 활용하는 PyQt
 
PyCon2020 NLP beginner's BERT challenge
PyCon2020 NLP beginner's BERT challengePyCon2020 NLP beginner's BERT challenge
PyCon2020 NLP beginner's BERT challenge
 
제 5회 Lisp 세미나 - Graphics Programming in Clojure
제 5회 Lisp 세미나 - Graphics Programming in Clojure제 5회 Lisp 세미나 - Graphics Programming in Clojure
제 5회 Lisp 세미나 - Graphics Programming in Clojure
 
테스트 주도 개발 By googletest 1장 다중 통화를 지원하는 money 객체
테스트 주도 개발 By googletest   1장 다중 통화를 지원하는 money 객체테스트 주도 개발 By googletest   1장 다중 통화를 지원하는 money 객체
테스트 주도 개발 By googletest 1장 다중 통화를 지원하는 money 객체
 

Similar a Introduction to Golang v2

(책 소개) Tucker의 Go 언어 프로그래밍
(책 소개) Tucker의 Go 언어 프로그래밍(책 소개) Tucker의 Go 언어 프로그래밍
(책 소개) Tucker의 Go 언어 프로그래밍Jay Park
 
[DS Meetup] iPad로 가벼운 분석환경 구축해보기
[DS Meetup] iPad로 가벼운 분석환경 구축해보기[DS Meetup] iPad로 가벼운 분석환경 구축해보기
[DS Meetup] iPad로 가벼운 분석환경 구축해보기Minho Lee
 
오픈소스 번역 기여하기 v2
오픈소스 번역 기여하기 v2오픈소스 번역 기여하기 v2
오픈소스 번역 기여하기 v2Changwoo Ryu
 
초보 개발자/학생들을 위한 오픈소스 트랜드
초보 개발자/학생들을 위한 오픈소스 트랜드 초보 개발자/학생들을 위한 오픈소스 트랜드
초보 개발자/학생들을 위한 오픈소스 트랜드 YoungSu Son
 
IT 서비스 개발 15년 _ IT service 15 years
IT 서비스 개발 15년 _ IT service 15 yearsIT 서비스 개발 15년 _ IT service 15 years
IT 서비스 개발 15년 _ IT service 15 years연지 김
 
[IGC2017] Protocol:hyperspace Diver 개발 포스트모템
[IGC2017] Protocol:hyperspace Diver 개발 포스트모템[IGC2017] Protocol:hyperspace Diver 개발 포스트모템
[IGC2017] Protocol:hyperspace Diver 개발 포스트모템Young Soo Kim
 
오픈소스 번역 기여하기 v3
오픈소스 번역 기여하기 v3오픈소스 번역 기여하기 v3
오픈소스 번역 기여하기 v3Changwoo Ryu
 
AngularJS In Production
AngularJS In ProductionAngularJS In Production
AngularJS In ProductionMooYeol Lee
 
[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템
[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템
[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템강 민우
 
Golang+on+analytics+and+blockchain
Golang+on+analytics+and+blockchainGolang+on+analytics+and+blockchain
Golang+on+analytics+and+blockchainNAVER Engineering
 
[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기
[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기
[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기CONNECT FOUNDATION
 
The Future of C# and .NET Framework
The Future of C# and .NET FrameworkThe Future of C# and .NET Framework
The Future of C# and .NET Framework명신 김
 
HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기
HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기
HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기Miyu Park
 
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019devCAT Studio, NEXON
 
오픈소스 컨트리뷰톤 2020 backend.ai 발표자료
오픈소스 컨트리뷰톤 2020 backend.ai 발표자료오픈소스 컨트리뷰톤 2020 backend.ai 발표자료
오픈소스 컨트리뷰톤 2020 backend.ai 발표자료지원 정
 
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기PgDay.Seoul
 
청강대 특강 - 프로젝트 제대로 해보기
청강대 특강 - 프로젝트 제대로 해보기청강대 특강 - 프로젝트 제대로 해보기
청강대 특강 - 프로젝트 제대로 해보기Chris Ohk
 
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기Sumin Byeon
 
클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)Sang-Kyu Park
 

Similar a Introduction to Golang v2 (20)

(책 소개) Tucker의 Go 언어 프로그래밍
(책 소개) Tucker의 Go 언어 프로그래밍(책 소개) Tucker의 Go 언어 프로그래밍
(책 소개) Tucker의 Go 언어 프로그래밍
 
[DS Meetup] iPad로 가벼운 분석환경 구축해보기
[DS Meetup] iPad로 가벼운 분석환경 구축해보기[DS Meetup] iPad로 가벼운 분석환경 구축해보기
[DS Meetup] iPad로 가벼운 분석환경 구축해보기
 
오픈소스 번역 기여하기 v2
오픈소스 번역 기여하기 v2오픈소스 번역 기여하기 v2
오픈소스 번역 기여하기 v2
 
초보 개발자/학생들을 위한 오픈소스 트랜드
초보 개발자/학생들을 위한 오픈소스 트랜드 초보 개발자/학생들을 위한 오픈소스 트랜드
초보 개발자/학생들을 위한 오픈소스 트랜드
 
IT 서비스 개발 15년 _ IT service 15 years
IT 서비스 개발 15년 _ IT service 15 yearsIT 서비스 개발 15년 _ IT service 15 years
IT 서비스 개발 15년 _ IT service 15 years
 
[IGC2017] Protocol:hyperspace Diver 개발 포스트모템
[IGC2017] Protocol:hyperspace Diver 개발 포스트모템[IGC2017] Protocol:hyperspace Diver 개발 포스트모템
[IGC2017] Protocol:hyperspace Diver 개발 포스트모템
 
Anatomy of an android
Anatomy of an androidAnatomy of an android
Anatomy of an android
 
오픈소스 번역 기여하기 v3
오픈소스 번역 기여하기 v3오픈소스 번역 기여하기 v3
오픈소스 번역 기여하기 v3
 
AngularJS In Production
AngularJS In ProductionAngularJS In Production
AngularJS In Production
 
[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템
[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템
[IGC 2017] 넥스트플로어 김영수 - Protocol:hyperspace Diver 개발 포스트모템
 
Golang+on+analytics+and+blockchain
Golang+on+analytics+and+blockchainGolang+on+analytics+and+blockchain
Golang+on+analytics+and+blockchain
 
[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기
[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기
[부스트캠프 Tech Talk] 최재필_P 스테이지에서 Git으로 협업하기
 
The Future of C# and .NET Framework
The Future of C# and .NET FrameworkThe Future of C# and .NET Framework
The Future of C# and .NET Framework
 
HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기
HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기
HTML5/JSON 을 이용해 범용 2D 맵에디터 제작하기
 
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019
전형규, SilvervineUE4Lua: UE4에서 Lua 사용하기, NDC2019
 
오픈소스 컨트리뷰톤 2020 backend.ai 발표자료
오픈소스 컨트리뷰톤 2020 backend.ai 발표자료오픈소스 컨트리뷰톤 2020 backend.ai 발표자료
오픈소스 컨트리뷰톤 2020 backend.ai 발표자료
 
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
[Pgday.Seoul 2020] 포스트그레스큐엘 자국어화 이야기
 
청강대 특강 - 프로젝트 제대로 해보기
청강대 특강 - 프로젝트 제대로 해보기청강대 특강 - 프로젝트 제대로 해보기
청강대 특강 - 프로젝트 제대로 해보기
 
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기
[야생의 땅: 듀랑고] 지형 관리 완전 자동화 - 생생한 AWS와 Docker 체험기
 
클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)클로져 소개 강의 (한국정보통신산업노동조합)
클로져 소개 강의 (한국정보통신산업노동조합)
 

Introduction to Golang v2