let's go! - wprowadzenie do go
TRANSCRIPT
![Page 1: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/1.jpg)
� LET'S GO! �Go is a programming language designed
by Google to help solve Google's problems,and Google has big problems.
Rob Pike, co-author, SPLASH 2012
![Page 2: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/2.jpg)
U gógla w 2007 roku, przykładowy projekt:
kod w C - 2000 plików4,2MB kodu źródłowego8GB z zależnościamibuild time w rozproszonym środowisku: 45min
źródło: talks.golang.org/2012/splash.article
![Page 3: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/3.jpg)
GO, CZERPIE Z:
CPythonoccamLimbo, NewsqueakPascal i podobne
![Page 4: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/4.jpg)
JEST TO JĘZYK:
proceduralnykompilowanystrukturalnywspółbieżnyimperatywnystatycznie silnie typowany
![Page 5: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/5.jpg)
OD 6 LAT NA RYNKU
Wiele platform
kompilowany do pojedynczej binarki
Ostatnio duży boom, co widać po statystykach irepozytoriach na GitHub.
15 miejsce w rankingu popularności, zaraz obok Scali iprzed Clojure
Znam ludzi którzy przeszli z Ruby do pisania w Go. (Dynport)
źródło: redmonk.com/sogrady/2015/07/01/language-rankings-6-15/
![Page 6: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/6.jpg)
CO I JAK:
Szybki:1-2 x szybszy od Pythona~10-20% wolniejszy od Javychoć niektóre corner-case’y z przewagą dla Go
Małe wymogi pamięciowemini appka serwerowa ~1,3MBAle binarki potrafią swoje ważyć - 6,2MB
![Page 7: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/7.jpg)
![Page 8: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/8.jpg)
Skromny zestaw podstawowej gramatyki:if/elseforswitchtype switchBrak operatorów innych niż matematyczne, bitowe ilogiczne:+ - * / %| & ^ << >> &^== != < > <= >=&& || !dodatkowo: * & <- (do wskaźników i kanałów)
![Page 9: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/9.jpg)
Wbudowane typy danych:
boolstringint int8 int16 int32 int64uint uint8 uint16 uint32 uint64 uintptrbyterunefloat32 float64complex64 complex128error
Rzutowanie typów explicit
Można definiować własne typy na bazie istniejących
![Page 10: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/10.jpg)
Funkcje traktowane na prawach zmiennych
możliwe anonimowe oraz domknięcia (ang. closures)
Brak wyjątków
ale ma multi-return-value dla funkcji
Odwlekanie w czasie: `defer
prawie jak javascriptowy setTimeout(..., 0)
![Page 11: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/11.jpg)
Struktury danych:arrayslicemapstruct z metodami
Ma wskaźniki, ale bez arytmetykiMa interfejsy, rozwiązywane na poziomie kompilacji lubruntime-uBrak dziedziczenia, ale ma zagnieżdżanie typów (type-embedding)
![Page 12: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/12.jpg)
Współbieżność wbudowana:goroutines i typ channel
![Page 13: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/13.jpg)
Brak wersjonowania paczek (ang. package)ale możliwe zaciąganie zależności (ang. import) np.prosto z githuba/bitbucketa
Ma GC (garbage collector)parallel mark-and-sweep
![Page 14: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/14.jpg)
Wbudowane uruchamianie testów, ale nie ma asercji.Sporo narzędzi, do profilowania kodu i code-coverageJeden styl formatowania: go fmt
wbudowany w kompilator formater (niestety oparty matabach width=8 :/)
![Page 15: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/15.jpg)
REAL CODE �https://github.com/RaVbaker/uploader-server-go
![Page 16: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/16.jpg)
PYTANIA?
![Page 17: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/17.jpg)
FAJNE LINKI:
- czemulepiej nie
- 2 lata doświadczeń
https://github.com/a8m/go-lang-cheat-sheet/http://tour.golang.org/https://golang.org/doc/effective_go.htmlhttp://golang-examples.tumblr.comhttp://blog.codeship.com/testing-in-go/https://news.ycombinator.com/item?id=7660924
http://www.darkcoding.net/software/go-lang-after-four-months/
![Page 18: Let's Go! - wprowadzenie do Go](https://reader038.vdocuments.pub/reader038/viewer/2022100508/55d3054cbb61eb353b8b46a5/html5/thumbnails/18.jpg)
DZIĘKI!Twitter: GitHub: @RaVbaker RaVbaker