DevRomagna - Golang - Introduzione al linguaggio

25
GOLANG INTRODUZIONE AL LINGUAGGIO

Transcript of DevRomagna - Golang - Introduzione al linguaggio

Page 1: DevRomagna - Golang - Introduzione al linguaggio

GOLANGINTRODUZIONE AL LINGUAGGIO

Page 2: DevRomagna - Golang - Introduzione al linguaggio

VOLANO

WIKIPEDIA

▸ “Go (often referred to as golang) is a programming

language created at Google[12] in 2009 by Robert

Griesemer, Rob Pike, and Ken Thompson."

Page 3: DevRomagna - Golang - Introduzione al linguaggio

INTRODUCTION

ABSTRACT

▸Late 2012

▸Solve

▸Multicore processor

▸Networking system

▸Massive computation cluster

▸Web programming

▸Built-in

▸Concurrency

▸Garbage collection

▸Dependency management

▸Testing

Page 4: DevRomagna - Golang - Introduzione al linguaggio

PAIN IN GOOGLE

PAINS

▸Slow build

▸Uncontrolled dependencies

▸Different subset of language

▸Poor program understanding

▸Difficulty of writing automatic tools

Page 5: DevRomagna - Golang - Introduzione al linguaggio

PAIN IN GOOGLE

PAINS

▸Development

▸Slow

▸Clumsy

▸Go

▸Faster

▸ Improve

▸Scalability

▸Productivity

▸Designed for

▸Large scale software

Page 6: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

FEATURES

▸Compiled

▸Garbage collected

▸Statically typed

▸Open source

▸Google uses public repository

▸BSD Licence

Page 7: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

GOALS

▸Scalable

▸Familiar

▸Modern

Page 8: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

DEPENDENCIES

▸Compile time

▸40x faster than C

▸Unused #include/import

▸Warning (C) - Error (Go)

Page 9: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

PACKAGES

▸ Install

▸Go get github.com/foo/bar

▸Usare

▸ import “foo/bar”

▸ import alias “vendor/package”

Page 10: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

PACKAGES

Page 11: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

SYNTAX

▸Few keywords

▸Declaration

▸Explicit

▸ Idiomatic :=

▸Function

▸Name

▸Receiver

▸No defaults

Page 12: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

NAMING

▸Public

▸private

▸Scope

▸Universe

▸God?

▸Package

▸File

▸Function

▸Block

Page 13: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

SEMANTIC

▸C-Like

▸Changes

▸No pointer arithmetic

▸With some “accrocchio” se po’ fa!

▸No implicit numeric conversion

▸No type aliases

▸Some kind of alias were introduced in 1.8

▸More

▸Concurrency

▸Garbage collection

▸ Interface type

▸Reflection

Page 14: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

CONCURRENCY

▸CSP

▸Communicating

▸Sequential

▸Process

▸A model of concurrency in which values are passed between

independent activities

Page 15: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

BANNING …

▸Ternary operator

▸While

▸ Implicit conversion

▸ Inheritance

Page 16: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

COMPOSITION NOT INHERITANCE

▸Allow methods in any type

▸No subclassing

▸ Interfaces

▸ Implicit

Page 17: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

TOOLS

▸Go build

▸Go test

▸Go fmt -w filename

Page 18: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

RESOURCES … ?

Page 19: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

LINKS

▸https://www.cheatography.com/explore/search/?q=golang

▸https://github.com/sensorario/awesome-go

▸https://github.com/sensorario/go-design-patterns

▸https://gobyexample.com/

▸https://tour.golang.org/welcome/1

▸https://talks.golang.org/2012/splash.article

▸https://golang.org/

▸https://gophers.slack.com (#italy)

Page 20: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

FRAMEWORKS … ?

Page 21: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

FRAMEWORKS

Page 22: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

CODE … ?

Page 23: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

TESTINGFizz buzz is a group word

game for children to teach

them

about division.[1] Players

take turns to count

incrementally, replacing

any number divisible by

three with the word "fizz",

and any number divisible

by five with the word

"buzz".

Page 24: DevRomagna - Golang - Introduzione al linguaggio

GOLANG

Page 25: DevRomagna - Golang - Introduzione al linguaggio

GOLANG