SlideShare una empresa de Scribd logo
1 de 35
Suelen G o u l a r t e C a r v a l h o
suelengc@ime.usp.br
Computação Paralela e Distribuída
Profº Alfredo Goldman
Junho/2015
Go is a programming language
designed by Google to help
solve Google's problems.
What is Go?
And has big
problems!
Which (big) problems?
● Hardware is big and the software is big
● There are many millions of lines of software
● Servers mostly in C++ and lots of Java and Python
● Thousands of engineers work on the code
● And of course, all this software runs on zillions of
machines.
In short, development at
is big, can be slow, and is often
clumsy. But it is effective.
''
''
https://talks.golang.org/2012/splash.article
A lot of others people
help to bring go from
prototype to reality.
Go became a public
Open Source
project.
https://golang.org/doc/faq#history
2008 2009 2010
2007
Starts to have
adoption by other
programmers
Started and built by
Robert Griesemer,
Rob Pike and Ken
Thompson as a
part-time project.
History
● Ken Thompson (B, C, Unix, UTF-8)
● Rob Pike (Unix, UTF-8)
● Robert Griesemer (Hotspot, JVM)
...and a few others engineers at Google
Who were the founders?
2013 2014
2012
Version history
Go 1.4 (December)
Go 1.3 (June)
Go 1 (March)
Go 1.2 (December)
Go 1.1 (May)
https://golang.org/project/
● Eliminate slowness
● Eliminate clumsiness
● Improve productive
● Maintain (and improve) scale
It was designed by and for people who write, read,
debug and maintain large software systems.
Go's purpose is not to do research programming
language design.
Go's purpose is to make its designers' programming
lives better.
Why Go?
Go is a compiled, concurrent,
garbage-collected, statically typed
language developed at .
What is Go?
Others tools:
fix, fmt, get, install, list, tool,
version, vet.
build
run
clean
env
test
compile packages and dependencies
compile and run Go program
remove object files
print Go environment information
test packages and benchmarks
Go is a tool for managing Go source code...
Mainly tools:
Who are using today?
https://github.com/golang/go/wiki/GoUsers
❏ Compiled
❏ Garbage-collected
❏ Has your own runtime
❏ Simple syntax
❏ Great standard library
❏ Cross-platform
❏ Object Oriented (without inheritance)
❏ Statically and stronger typed
❏ Concurrent (goroutines)
❏ Closures
❏ Explicity dependencies
❏ Multiple return values
❏ Pointers
❏ and so on...
What will you see in Go?
Have not been implemented in
favor of efficiency.
❏ Exception handling
❏ Inheritance
❏ Generics
❏ Assert
❏ Method overload
What will you not
see in Go?
see a bit of code!
Packages
● Each Go program are compound per packages
● Programs starts from main package
● This example are using the ftm and math packages
$ go run packages.go
My favorite number is 1
● The var instruction declares a list of variables
● The type is informed at the end
● The var instruction could be in a package or in a function
● The var instruction could includes initializers, 1 per variable. In
this case, the type could be ommited because it will be inferred
Variables
$ go run variables.go
0 false false false
$ go run variables-with-initiali
1 2 true false no!
$ go run constants.go
Hello world! Happy 3.14 Day! Go rules?
● Constants are declared like variables but with keyword const
● Can not use the syntx :=
Constants
● Inside a function, the short attribution instruction :=
can be used instead of a var declaration
Short variables declarations
$ go run short-variable-declarations.go
1 2 3 true false no!
Functions
● Functions could have zero or more arguments
● Notice that the type comes after the parameter name,
like variables
$ go run functions.go
55
● A function can have multiple return values
Multiple return values
$ go run multiple-results.go
world hello
● Go has just for as looping structure
● It is very similar with C or Java code, except for ( )
● Start and end declarations can be empty
Looping For
$ go run for.go
45
$ go run for-continu
1024
$ go run for-is-go-while.go
1024
● Semicolon can be removed and you will have while
● for can run forever
Looping "while" and forever
$ go run forever.go
process took too long
● It is very similar with C or Java code, except for ( )
if Condition
$ go run if.go
1.4142135623730951 2i
$ go run switch.go
Go runs on nacl.
● It is very similar with C or Java code, except for ( )
Switch Condition
$ go run defer.go
hello world
Defer
● Postponing the execution of a function until the function returns
● The arguments of the deferred calls are evaluated immediately
What more?
● Pointer
● Struct
● Matrix
● Slice
● Range
● Map
● Value function
● Closures
● Method
● Interface
● Stringer
● Error
● and a lot of more!!!
http://go-tour-br.appspot.com
$ go run http.go
A web server
● It is just simple to build a web server with 15 lines or less!!
Could you belive that???
● To execute a goroutine, just go!
● To send or receive information between the
goroutines, use channels
● Use the GOMAXPROCS environment variable to
define the amount of threads
Concurrency (goroutines)
$ go run goroutines.go
hello
world
hello
world
hello
world
hello
world
hello
● A goroutine is a lightweight thread managed by Go runtime
Goroutines
$ go run channels.go
17 -5 12
Channels
● Channels are typed's conduit through which you can send and receive
values with the channel operator <-
Unbuffered Channels
http://www.goinggo.net/2014/02/the-nature-of-channels-in-go.html
c := make (chan int)
Buffered Channels
http://www.goinggo.net/2014/02/the-nature-of-channels-in-go.html
c := make (chan int, 10)
N o w you a r e r e a d y t o
Bibliografia
❏ http://golang.org
❏ http://go-tour-br.appspot.com/
❏ https://tour.golang.org
❏ http://www.golangbr.org/
❏ https://vimeo.com/49718712
❏ http://gophercon.com
❏ http://www.infoq.com/br/news/2014/09/go-1-3
❏
❏
❏
❏
❏
❏
❏
❏
❏
http://www.casadocodigo.com.br/products/livro-google-go
https://pt.wikipedia.org/wiki/Inferno_(sistema_operacional)
http://www.grokpodcast.com/series/a-linguagem-go/
https://pt.wikipedia.org/wiki/Go_(linguagem_de_programação)
https://gobyexample.com
http://www.goinggo.net/2014/02/the-nature-of-channels-in-go.html
http://www.goinggo.net/2013/09/detecting-race-conditions-with-go.html?m=1
https://en.wikipedia.org/wiki/Green_threads
http://www.toptal.com/go/go-programming-a-step-by-step-introductory-tutorial
Questions?

Más contenido relacionado

Similar a go language- haseeb.pptx

JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009
Mario Heiderich
 

Similar a go language- haseeb.pptx (20)

Mender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and GolangMender.io | Develop embedded applications faster | Comparing C and Golang
Mender.io | Develop embedded applications faster | Comparing C and Golang
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
Why Go Lang?
Why Go Lang?Why Go Lang?
Why Go Lang?
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Introduction to Go
Introduction to GoIntroduction to Go
Introduction to Go
 
Me&g@home
Me&g@home Me&g@home
Me&g@home
 
Golang preso
Golang presoGolang preso
Golang preso
 
JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009JavaScript From Hell - CONFidence 2.0 2009
JavaScript From Hell - CONFidence 2.0 2009
 
Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction
 
A First Look at Google's Go Programming Language
A First Look at Google's Go Programming LanguageA First Look at Google's Go Programming Language
A First Look at Google's Go Programming Language
 
Go. why it goes v2
Go. why it goes v2Go. why it goes v2
Go. why it goes v2
 
Golang workshop - Mindbowser
Golang workshop - MindbowserGolang workshop - Mindbowser
Golang workshop - Mindbowser
 
Golang nuts (by Nii Nai at DevCongress 2013)
Golang nuts (by Nii Nai at DevCongress 2013)Golang nuts (by Nii Nai at DevCongress 2013)
Golang nuts (by Nii Nai at DevCongress 2013)
 
Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?
 
Golang introduction
Golang introductionGolang introduction
Golang introduction
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
Improve the deployment process step by step
Improve the deployment process step by stepImprove the deployment process step by step
Improve the deployment process step by step
 
Golang (Go Programming Language)
Golang (Go Programming Language)Golang (Go Programming Language)
Golang (Go Programming Language)
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
How go makes us faster (May 2015)
How go makes us faster (May 2015)How go makes us faster (May 2015)
How go makes us faster (May 2015)
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Último (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

go language- haseeb.pptx

  • 1. Suelen G o u l a r t e C a r v a l h o suelengc@ime.usp.br Computação Paralela e Distribuída Profº Alfredo Goldman Junho/2015
  • 2. Go is a programming language designed by Google to help solve Google's problems. What is Go? And has big problems!
  • 3. Which (big) problems? ● Hardware is big and the software is big ● There are many millions of lines of software ● Servers mostly in C++ and lots of Java and Python ● Thousands of engineers work on the code ● And of course, all this software runs on zillions of machines.
  • 4. In short, development at is big, can be slow, and is often clumsy. But it is effective. '' '' https://talks.golang.org/2012/splash.article
  • 5. A lot of others people help to bring go from prototype to reality. Go became a public Open Source project. https://golang.org/doc/faq#history 2008 2009 2010 2007 Starts to have adoption by other programmers Started and built by Robert Griesemer, Rob Pike and Ken Thompson as a part-time project. History
  • 6. ● Ken Thompson (B, C, Unix, UTF-8) ● Rob Pike (Unix, UTF-8) ● Robert Griesemer (Hotspot, JVM) ...and a few others engineers at Google Who were the founders?
  • 7. 2013 2014 2012 Version history Go 1.4 (December) Go 1.3 (June) Go 1 (March) Go 1.2 (December) Go 1.1 (May) https://golang.org/project/
  • 8. ● Eliminate slowness ● Eliminate clumsiness ● Improve productive ● Maintain (and improve) scale It was designed by and for people who write, read, debug and maintain large software systems. Go's purpose is not to do research programming language design. Go's purpose is to make its designers' programming lives better. Why Go?
  • 9. Go is a compiled, concurrent, garbage-collected, statically typed language developed at . What is Go?
  • 10. Others tools: fix, fmt, get, install, list, tool, version, vet. build run clean env test compile packages and dependencies compile and run Go program remove object files print Go environment information test packages and benchmarks Go is a tool for managing Go source code... Mainly tools:
  • 11. Who are using today? https://github.com/golang/go/wiki/GoUsers
  • 12. ❏ Compiled ❏ Garbage-collected ❏ Has your own runtime ❏ Simple syntax ❏ Great standard library ❏ Cross-platform ❏ Object Oriented (without inheritance) ❏ Statically and stronger typed ❏ Concurrent (goroutines) ❏ Closures ❏ Explicity dependencies ❏ Multiple return values ❏ Pointers ❏ and so on... What will you see in Go?
  • 13. Have not been implemented in favor of efficiency. ❏ Exception handling ❏ Inheritance ❏ Generics ❏ Assert ❏ Method overload What will you not see in Go?
  • 14. see a bit of code!
  • 15. Packages ● Each Go program are compound per packages ● Programs starts from main package ● This example are using the ftm and math packages $ go run packages.go My favorite number is 1
  • 16. ● The var instruction declares a list of variables ● The type is informed at the end ● The var instruction could be in a package or in a function ● The var instruction could includes initializers, 1 per variable. In this case, the type could be ommited because it will be inferred Variables $ go run variables.go 0 false false false $ go run variables-with-initiali 1 2 true false no!
  • 17. $ go run constants.go Hello world! Happy 3.14 Day! Go rules? ● Constants are declared like variables but with keyword const ● Can not use the syntx := Constants
  • 18. ● Inside a function, the short attribution instruction := can be used instead of a var declaration Short variables declarations $ go run short-variable-declarations.go 1 2 3 true false no!
  • 19. Functions ● Functions could have zero or more arguments ● Notice that the type comes after the parameter name, like variables $ go run functions.go 55
  • 20. ● A function can have multiple return values Multiple return values $ go run multiple-results.go world hello
  • 21. ● Go has just for as looping structure ● It is very similar with C or Java code, except for ( ) ● Start and end declarations can be empty Looping For $ go run for.go 45 $ go run for-continu 1024
  • 22. $ go run for-is-go-while.go 1024 ● Semicolon can be removed and you will have while ● for can run forever Looping "while" and forever $ go run forever.go process took too long
  • 23. ● It is very similar with C or Java code, except for ( ) if Condition $ go run if.go 1.4142135623730951 2i
  • 24. $ go run switch.go Go runs on nacl. ● It is very similar with C or Java code, except for ( ) Switch Condition
  • 25. $ go run defer.go hello world Defer ● Postponing the execution of a function until the function returns ● The arguments of the deferred calls are evaluated immediately
  • 26. What more? ● Pointer ● Struct ● Matrix ● Slice ● Range ● Map ● Value function ● Closures ● Method ● Interface ● Stringer ● Error ● and a lot of more!!! http://go-tour-br.appspot.com
  • 27. $ go run http.go A web server ● It is just simple to build a web server with 15 lines or less!! Could you belive that???
  • 28. ● To execute a goroutine, just go! ● To send or receive information between the goroutines, use channels ● Use the GOMAXPROCS environment variable to define the amount of threads Concurrency (goroutines)
  • 29. $ go run goroutines.go hello world hello world hello world hello world hello ● A goroutine is a lightweight thread managed by Go runtime Goroutines
  • 30. $ go run channels.go 17 -5 12 Channels ● Channels are typed's conduit through which you can send and receive values with the channel operator <-
  • 33. N o w you a r e r e a d y t o
  • 34. Bibliografia ❏ http://golang.org ❏ http://go-tour-br.appspot.com/ ❏ https://tour.golang.org ❏ http://www.golangbr.org/ ❏ https://vimeo.com/49718712 ❏ http://gophercon.com ❏ http://www.infoq.com/br/news/2014/09/go-1-3 ❏ ❏ ❏ ❏ ❏ ❏ ❏ ❏ ❏ http://www.casadocodigo.com.br/products/livro-google-go https://pt.wikipedia.org/wiki/Inferno_(sistema_operacional) http://www.grokpodcast.com/series/a-linguagem-go/ https://pt.wikipedia.org/wiki/Go_(linguagem_de_programação) https://gobyexample.com http://www.goinggo.net/2014/02/the-nature-of-channels-in-go.html http://www.goinggo.net/2013/09/detecting-race-conditions-with-go.html?m=1 https://en.wikipedia.org/wiki/Green_threads http://www.toptal.com/go/go-programming-a-step-by-step-introductory-tutorial