SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
So you think you know ‘Go’? 
The Go Programming Language 
Presented by John Potocny @ATO 2014
About Me 
Backend Developer at VividCortex, BCE from Kettering University 
Programming Experience: Mainly C#/Java, Embedded C/C++, some Python 
Twitter: @JohnPotocny1 
Email: johnp@vividcortex.com
A Brief History 
● Created in 2007 by Robert Griesemer, Rob Pike, & Ken Thompson 
● Developed by Google 
● Open Source - since Nov 10, 2009 (Public Announcement) 
● Currently v1.3.3 (Stable)
What Kind of Language is Go?
Language Features
Actually, It’s More Like This
Great Tools Built-In
Compiles Quickly - Native Binary
Garbage Collected
Statically Typed
Interfaces and Composition
Concurrency
What Did Go Get Rid Of?
Remember The Goals!
Enough Chat, Let’s See Some Code!
A “Modern” Hello World
A “Modern” Hello World
How About a Real Example?
How About a Web Server? 
http://play.golang.org/p/r-__BazPxE
How About a Web Server? 
http://play.golang.org/p/r-__BazPxE 
Or Even:
Server With Limited Connections? 
http://play.golang.org/p/OMian3YwlD
No Language Is Perfect...
A Fun Example 
http://play.golang.org/p/kPFCYuNTTG
Other Things?
No Generics
Go Has Complex Numbers
Static Types - No Implicit Conversion
ATO 2014 - So You Think You Know 'Go'? The Go Programming Language
Strict Compiler Interrupts Flow
Race Conditions Still Exist
Wait, Go Has ‘goto’!?
Other Fun Keywords 
Proof: http://play.golang.org/p/dFBcMMHq0a
Questions?
Thank You!

Más contenido relacionado

Destacado

Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010JUG Lausanne
 
Go Programming Language by Google
Go Programming Language by GoogleGo Programming Language by Google
Go Programming Language by GoogleUttam Gandhi
 
Physical Computing Using Go and Arduino
Physical Computing Using Go and ArduinoPhysical Computing Using Go and Arduino
Physical Computing Using Go and ArduinoJustin Grammens
 
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 goDvir Volk
 
Google Go! language
Google Go! languageGoogle Go! language
Google Go! languageAndré Mayer
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programmingMahmoud Masih Tehrani
 
Go Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang wayGo Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang wayIndicThreads
 
Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction Ganesh Samarthyam
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programmingExotel
 

Destacado (12)

Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010Introduction à Scala - Michel Schinz - January 2010
Introduction à Scala - Michel Schinz - January 2010
 
Go Programming Language by Google
Go Programming Language by GoogleGo Programming Language by Google
Go Programming Language by Google
 
Physical Computing Using Go and Arduino
Physical Computing Using Go and ArduinoPhysical Computing Using Go and Arduino
Physical Computing Using Go and Arduino
 
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
 
Golang
GolangGolang
Golang
 
Google Go! language
Google Go! languageGoogle Go! language
Google Go! language
 
Introduction to go language programming
Introduction to go language programmingIntroduction to go language programming
Introduction to go language programming
 
Golang
GolangGolang
Golang
 
Go Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang wayGo Programming Language - Learning The Go Lang way
Go Programming Language - Learning The Go Lang way
 
About Go
About GoAbout Go
About Go
 
Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction Google's Go Programming Language - Introduction
Google's Go Programming Language - Introduction
 
Introduction to Go programming
Introduction to Go programmingIntroduction to Go programming
Introduction to Go programming
 

Similar a ATO 2014 - So You Think You Know 'Go'? The Go Programming Language

So You Think You Know 'Go'? The Go Programming Language
So You Think You Know 'Go'? The Go Programming LanguageSo You Think You Know 'Go'? The Go Programming Language
So You Think You Know 'Go'? The Go Programming LanguageAll Things Open
 
GSoC: How to get prepared and write a good proposal (or how to start contribu...
GSoC: How to get prepared and write a good proposal (or how to start contribu...GSoC: How to get prepared and write a good proposal (or how to start contribu...
GSoC: How to get prepared and write a good proposal (or how to start contribu...João Paulo Rechi Vita
 
The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180Mahmoud Samir Fayed
 
How to discover contribution item ?
How to discover contribution item ?How to discover contribution item ?
How to discover contribution item ?Gyuyoung Kim
 
How to master a programming language: a Golang example"
How to master a programming language: a Golang example"How to master a programming language: a Golang example"
How to master a programming language: a Golang example"Evan Lin
 
Android is going to Go! - Android and goland - Almog Baku
Android is going to Go! - Android and goland - Almog BakuAndroid is going to Go! - Android and goland - Almog Baku
Android is going to Go! - Android and goland - Almog BakuDroidConTLV
 
Android is going to Go! Android and Golang
Android is going to Go! Android and GolangAndroid is going to Go! Android and Golang
Android is going to Go! Android and GolangAlmog Baku
 
The Ring programming language version 1.5.4 book - Part 5 of 185
The Ring programming language version 1.5.4 book - Part 5 of 185The Ring programming language version 1.5.4 book - Part 5 of 185
The Ring programming language version 1.5.4 book - Part 5 of 185Mahmoud Samir Fayed
 
PYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptxPYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptxEzatIlman1
 
Bot. You said bot? Let build bot then! - Laurent Ellerbach
Bot. You said bot? Let build bot then! - Laurent EllerbachBot. You said bot? Let build bot then! - Laurent Ellerbach
Bot. You said bot? Let build bot then! - Laurent EllerbachITCamp
 
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...ITCamp
 
The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184Mahmoud Samir Fayed
 
Practical implementation of Natural language processing with python
Practical implementation of Natural language processing with pythonPractical implementation of Natural language processing with python
Practical implementation of Natural language processing with pythonAbdulkereemKereem
 
Intro to Python Programming
Intro to Python ProgrammingIntro to Python Programming
Intro to Python Programmingssuser65af26
 
What is the best programming language for beginner?
What is the best programming language for beginner?What is the best programming language for beginner?
What is the best programming language for beginner?Designveloper
 
Basic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptxBasic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptxAditya Patel
 

Similar a ATO 2014 - So You Think You Know 'Go'? The Go Programming Language (20)

So You Think You Know 'Go'? The Go Programming Language
So You Think You Know 'Go'? The Go Programming LanguageSo You Think You Know 'Go'? The Go Programming Language
So You Think You Know 'Go'? The Go Programming Language
 
GSoC: How to get prepared and write a good proposal (or how to start contribu...
GSoC: How to get prepared and write a good proposal (or how to start contribu...GSoC: How to get prepared and write a good proposal (or how to start contribu...
GSoC: How to get prepared and write a good proposal (or how to start contribu...
 
The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
The Awesomeness of Go
The Awesomeness of GoThe Awesomeness of Go
The Awesomeness of Go
 
How to discover contribution item ?
How to discover contribution item ?How to discover contribution item ?
How to discover contribution item ?
 
How to master a programming language: a Golang example"
How to master a programming language: a Golang example"How to master a programming language: a Golang example"
How to master a programming language: a Golang example"
 
Lecture 1.pptx
Lecture 1.pptxLecture 1.pptx
Lecture 1.pptx
 
Slides kotlin yajug
Slides kotlin yajugSlides kotlin yajug
Slides kotlin yajug
 
Android is going to Go! - Android and goland - Almog Baku
Android is going to Go! - Android and goland - Almog BakuAndroid is going to Go! - Android and goland - Almog Baku
Android is going to Go! - Android and goland - Almog Baku
 
Android is going to Go! Android and Golang
Android is going to Go! Android and GolangAndroid is going to Go! Android and Golang
Android is going to Go! Android and Golang
 
The Ring programming language version 1.5.4 book - Part 5 of 185
The Ring programming language version 1.5.4 book - Part 5 of 185The Ring programming language version 1.5.4 book - Part 5 of 185
The Ring programming language version 1.5.4 book - Part 5 of 185
 
PYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptxPYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptx
 
Bot. You said bot? Let build bot then! - Laurent Ellerbach
Bot. You said bot? Let build bot then! - Laurent EllerbachBot. You said bot? Let build bot then! - Laurent Ellerbach
Bot. You said bot? Let build bot then! - Laurent Ellerbach
 
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...
ITCamp 2017 - Laurent Ellerbach - Bot. You said bot? Let's build a bot then...
 
The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184
 
Practical implementation of Natural language processing with python
Practical implementation of Natural language processing with pythonPractical implementation of Natural language processing with python
Practical implementation of Natural language processing with python
 
Intro to Python Programming
Intro to Python ProgrammingIntro to Python Programming
Intro to Python Programming
 
What is the best programming language for beginner?
What is the best programming language for beginner?What is the best programming language for beginner?
What is the best programming language for beginner?
 
Basic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptxBasic Python Introduction Lecture 1.pptx
Basic Python Introduction Lecture 1.pptx
 

Último

Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampVICTOR MAESTRE RAMIREZ
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyRaymond Okyere-Forson
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLAlluxio, Inc.
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdfMeon Technology
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorShane Coughlan
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native BuildpacksVish Abrams
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeNeo4j
 
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.Sharon Liu
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Incrobinwilliams8624
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024Mind IT Systems
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsJaydeep Chhasatia
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?AmeliaSmith90
 
Webinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptWebinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptkinjal48
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfTobias Schneck
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageDista
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadIvo Andreev
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmonyelliciumsolutionspun
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...OnePlan Solutions
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies
 

Último (20)

Deep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - DatacampDeep Learning for Images with PyTorch - Datacamp
Deep Learning for Images with PyTorch - Datacamp
 
AI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human BeautyAI Embracing Every Shade of Human Beauty
AI Embracing Every Shade of Human Beauty
 
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/MLBig Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
Big Data Bellevue Meetup | Enhancing Python Data Loading in the Cloud for AI/ML
 
online pdf editor software solutions.pdf
online pdf editor software solutions.pdfonline pdf editor software solutions.pdf
online pdf editor software solutions.pdf
 
OpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS CalculatorOpenChain Webinar: Universal CVSS Calculator
OpenChain Webinar: Universal CVSS Calculator
 
Streamlining Your Application Builds with Cloud Native Buildpacks
Streamlining Your Application Builds  with Cloud Native BuildpacksStreamlining Your Application Builds  with Cloud Native Buildpacks
Streamlining Your Application Builds with Cloud Native Buildpacks
 
Salesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptxSalesforce AI Associate Certification.pptx
Salesforce AI Associate Certification.pptx
 
IA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG timeIA Generativa y Grafos de Neo4j: RAG time
IA Generativa y Grafos de Neo4j: RAG time
 
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
20240319 Car Simulator Plan.pptx . Plan for a JavaScript Car Driving Simulator.
 
Enterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze IncEnterprise Document Management System - Qualityze Inc
Enterprise Document Management System - Qualityze Inc
 
Top Software Development Trends in 2024
Top Software Development Trends in  2024Top Software Development Trends in  2024
Top Software Development Trends in 2024
 
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software TeamsYour Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
Your Vision, Our Expertise: TECUNIQUE's Tailored Software Teams
 
How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?How Does the Epitome of Spyware Differ from Other Malicious Software?
How Does the Epitome of Spyware Differ from Other Malicious Software?
 
Webinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.pptWebinar_050417_LeClair12345666777889.ppt
Webinar_050417_LeClair12345666777889.ppt
 
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdfARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
ARM Talk @ Rejekts - Will ARM be the new Mainstream in our Data Centers_.pdf
 
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales CoverageSales Territory Management: A Definitive Guide to Expand Sales Coverage
Sales Territory Management: A Definitive Guide to Expand Sales Coverage
 
Cybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and BadCybersecurity Challenges with Generative AI - for Good and Bad
Cybersecurity Challenges with Generative AI - for Good and Bad
 
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine HarmonyLeveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
Leveraging DxSherpa's Generative AI Services to Unlock Human-Machine Harmony
 
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
Transforming PMO Success with AI - Discover OnePlan Strategic Portfolio Work ...
 
Kawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in TrivandrumKawika Technologies pvt ltd Software Development Company in Trivandrum
Kawika Technologies pvt ltd Software Development Company in Trivandrum
 

ATO 2014 - So You Think You Know 'Go'? The Go Programming Language

Notas del editor

  1. What this presentation is about: Overview of language features, some personal perspective as a newcomer, current perspective NOT a talk on programming language theory NOT an advanced talk For people looking to learn about Go, answer “should I use this language for my next project?”
  2. Me: “Looks kinda like a somewhat crippled C#/Modern C. Clean syntax, and gothreads/channels are nice. Now what’s the syntax to declare an abstract class…?” Founders: Tried to create a simple language (get rid of the “kruft” in C++, that is well prepared for modern runtime environments (concurrency, networking, etc.) Procedural language (mostly), somewhat based on C/C++ Garbage collected Statically typed Compiles to native code Concurrency built-in at the lowest level
  3. “So I’ve heard a lot about how great Go is, tell me about all of the awesome features it has!”
  4. Well…. Go is actually a pretty simple language! Simple, purpose built to address programmer productivity issues experienced by Google in C++ projects Long builds, crazy dependencies (include hell) Programming language not adapted to take advantage of modern hardware (concurrency) Poor integrated tools to support the language Common errors in development (memory leaks, etc)
  5. When you download Go, you get way more than just the compiler/std libs: Go fmt - format code Go Get - fetch remote dependencies Go Test - integrated unit/benchmark testing Go Vet - check for common errors in code Go Doc - Generate code documentation from comments Go Fix - Help upgrade to new releases of Go (when syntax changes break builds - not much of an issue post v1.0) go tool pprof - help profile your Go Application 3rd Party: goimports - remove unused imports automatically (I have my IDE configure to do this on save) golint - another syntax checker, looks for code improvements jd - locked dependency manager (made by VividCortex)
  6. Go Creators have joked that Go was developed between C++ builds at Google. Not entirely untrue Large C++ codebase, build can take over an hour Even large Go projects can compile in seconds Reason is dependency management system (doesn’t lead to recompiling dependencies over and over) Also much simpler language structure (syntax, paired down feature-set) “ Build time matters more than anything else” - Rob Pike
  7. Memory Management is hard. C/C++, mem management left to programmer, bugs ensue Immediate design decision in Go - garbage collector
  8. Similar to C - if you declare an int you get and int (no worrying that your variable type is inferred correctly at runtime) Go also has type inference, but only at declaration Once you create it, you have to explicitly change a variable’s type
  9. Go has support for Objects - but we call them structs Objects can have methods just like classes in most OO languages can In fact, any type you create can have methods! i.e. type Name string can have method func (name Name) Introduce(){} Go has interfaces, but they do not have members, only functions Go does not have the traditional inheritance models in C++/Java We use “Strong Ducktyping” Any struct can “inherit” from an interface if it has the methods defined Standard lib structs can inherit your Interfaces!
  10. No talk about Go is complete without talking about Concurrency! Channels - send data between threads easily, asynchronously or synchronously GoRoutines - spin up another thread, just like that! Concurrency is a fundamental component of the language
  11. Here’s a list (not all inclusive of course): Implicit numeric conversion (int != int32) ‘Implements’ keyword (interface inheritance is implicit) No ‘classes’ (declare structs/methods wherever, any data type can have methods) No constructor/destructors Function overloading (methods match by name, not signature) Pointer arithmetic (unsafe.Pointer exists though) Exceptions and try/catch (although we have panic/recover - for extreme cases) Generics
  12. Simple, productive language for modern hardware Fast Compilation Good tool support included Easy to pick up and understand Can hold the spec in your head No cruft/legacy support Start from scratch, don’t try to “fix” C++
  13. The real world has concurrency - so here’s a “Hello World” that showcases Go’s concurrency model Create a concurrent thread just by prefixing a function with ‘go’ Synchronize your threads with a blocking channel No Imports to access concurrency - they are built right into the language.
  14. And there’s our output (Pirate Slang!)
  15. To be fair, “Hello World” isn’t really a “real world” scenario. Let’s make a simple web-server, that’s a little better!
  16. Do a live demo on your local machine, or just go over the code in the Playground (don’t hit run in the playground!)
  17. A static website server that looks in a single location and responds to requests with the file there. 1 line.
  18. Unlimited concurrency can be dangerous (DDOS?) Let’s see a server that limits the number of concurrent connections This code uses channels to do just that
  19. Go has a couple of things that can be quite annoying at times
  20. Here’s a program, what will it’s output be? Why doesn’t it think there is a bomb? thereIsABomb was actually declared twice! once outside the for-loop and once inside. We change the value of the one that then loses scope, so thereIsABomb is always checked as false. This is a tricky problem that occurs due to Go’s flexible variable declaration syntax Even the creators have said they dislike it as it is Can it be fixed? Maybe make go vet warn?
  21. So what else is interesting, problematic and/or weird about Go?
  22. Go doesn’t have generics One of the most criticized points Considered the biggest feature-screwups (why didn’t they include it!?) by a lot of people Most asked-for feature (to my knowledge) Initially I thought this was a pretty big drawback A Couple Things: I haven’t needed Generics since I switched to Go In fact, I didn’t really use them a lot anyways when I had them Did I ever really “need” them? I’m not so sure Generics are complicated Significant increase in language complexity to add them in all liklihood Compile times will increase The Go Developers are not blatantly against them Have said they would add if a good solution or blatant problem was brought forward So far none has AFAIK Go Mentality: Smallest possible featureset we can be productive with It’s okay if we have to copy some code as a result Productivity is higher priority than hyper-elegant code
  23. Builtin Types - complex64 and complex128 Builtin functions - real() and imag() to get the components math/cmplx package to manipulate them
  24. When you declare a variable, that’s it. Want to treat it as something else? Cast it. int and int32 are different, have to cast to add them (note constants can be added to any numeric type - they are typeless) I thought this sucked when I started using Go “What do you mean I can’t just add this byte to an int!? Are you kidding me?” Luckily, I could usually just change the types interacting and the code got cleaner Why would they do this though? It makes every expression explicit (i.e. “I am specifically choosing to mix these types, as I believe it is okay) Reduces the chance of accidental scope issues (overflow, ect.) Absolutely no ambiguity as to how types interact together (is it safe to mix these?) Annoying? Sure, but not a deal breaker
  25. go fmt - it formats your code, the Go way only If you are the guy on the left (like I was), this will make your brain itch Won’t even compile when you have bracket on its own line “So why can’t I use my own style?” Simplicity (a minor case, I know) Universally formatted code, no matter where you go Lends to readability Google has “solved” the style debate in Go (we have more important things to do as engineers)
  26. I agree that unused vars/imports should be errors, but picture if you will: Hacking on a feature, want to print a value as a sanity check go add “fmt” to imports declare the var, add a print statement It works! Let’s move on: Delete print statement, add some more code Build fails - unused import remove import Build fails - unused variable delete var What was I doing again??? GoImports helps, but requires a mindset change (quick hacks no longer quick, I guess) This still trips me up, but less as time goes on
  27. Go supports concurrency very easily, but race conditions are still a problem builtin “sync” package has mutexes As always, be careful when sharing data across threads!
  28. Why does a language whose creators specifically wanted simplicity and eliminate errors include the ‘goto’ statement? Let’s all agree - the next popular language will not have ‘goto’ - this madness must end.
  29. Here’s something fun: Easter Eggs! These keywords really exist - you can use them anywhere in a Go Program (the compiler simply ignores them all) go fmt will not understand them though