SlideShare a Scribd company logo
1 of 76
fmt.Printf(“Hello, UNSADA”)
Pramesti Hatta K.
Software Engineer @Tech in Asia
Making things look hard is easy. Making hard
things look easy, that’s hard.
Meet Gopher, the funniest programming
language mascot.
2 types of programming language
compiled | interpreted
compiled languages are converted directly into
machine code
In contrast to compiled languages, interpreted
languages do not require machine code in order to
execute the program; instead, interpreters will
run through a program line by line and execute
each command.
compiled
● often faster execution
time
● often slower development
time
C/C++, Go, Fortran, Pascal
etc
interpreted
● often slower execution
time
● often faster development
time
PHP, Python, Ruby, JavaScript
statically typed
package main
import “fmt”
func main() {
var person string
person = “Maudy Ayunda”
fmt.Println(person)
person = 22
fmt.Println(person)
}
Output:
cannot use 22 (type int) as type
string in assignment
dynamically typed
<?php
$person = “Maudy Ayunda”;
echo $person;
$person = 22;
Echo $person;
Output:
Maudy Ayunda
22
New programming language?
2007
Robert Griesemer, Rob Pike and Ken
Thompson
2009 (became open source)
2012 (finally stable v.)
why?
Go was born out of frustration with existing
languages and environments for systems
programming.
one had to choose either efficient compilation,
efficient execution, or ease of programming
programmers who could were choosing ease over
safety and efficiency by moving to dynamically
typed languages such as Python and JavaScript
rather than C++ or, to a lesser extent, Java.
Go is an attempt to combine the ease of
programming of an interpreted, dynamically typed
language with the efficiency and safety of a
statically typed, compiled language.
designed by Google to solve Google’s
problem.
and Google has big problems.
Big hardware
Big software
● C++ (mostly) for servers, plus lots of java
and python
● thousands of engineers
● gazillions of lines of code
development at Google can be slow,
often clumsy.
Goals
● eliminate slowness
● eliminate clumsiness
● improve effectiveness
Go’s purpose is not research into
programming language design
Go’s purpose is to make software
engineer’s lives better.
Go Programming Language
● open source
● concurrent
● garbage collected
● efficient
● simple
● fun
● boring (to some)
https://golang.org
Go is a statically typed compiled
language.
Golang is a simple language. It has only 25 keywords.
Go keywords
break default func interface select
case defer go map struct
chan else goto package switch
const fallthrough if range type
continue for import return var
Yea I’m ready to learn this language
Basic structure
1.package main
2.
3.import “fmt”
4.
5.func main() {
6. fmt.Printf(“Hello, world.n”)
7.}
Package
1.package main
2.
3.import (
4. “fmt”
5. “math/rand”
6.)
7.
8.func main() {
Function
1.package main
2. …
3.func add(x int, y int) int
{
4. return x + y
5.}
6.
7.func main() {
Output
30
Function with multiple return
1.package main
2. …
3.func swap(x, y string) (string, string)
{
4. return y, x
5.}
6.
7.func main() {
Output
world hello
Variables
1.package main
2. …
3.var x int
4.
5.func main() {
6. var y string
7. y = "Hi!"
8. fmt.Println(y)
Output
Hi!
0
Short declaration variables
1.package main
2. …
3.
4.func main() {
5. y := “Hi!”
6. fmt.Println(y)
7.}
Output
Hi!
Basic types
bool
string
int int8 int16 int32 int64
uint uint8 uint16 uint32 uint64 uintptr
byte // alias for uint8
rune // alias for int32
float32 float64
complex64 complex128
Looping
1.package main
2. …
3.
4.func main() {
5. for i := 1; i <= 10; i++ {
6. fmt.Println(i)
7. }
Output
1
2
3
4
5
6
7
8
9
10
Looping continued
1.package main
2. …
3.
4.func main() {
5. i := 1
6. for i <= 10 {
7. fmt.Println(i)
8. i++
Output
1
2
3
4
5
6
7
8
9
10
If and else
1.package main
2. …
3.
4.func main() {
5. i := 22
6. if i > 10 {
7. fmt.Println(“big”)
8. } else {
Output
big
Struct
1.package main
2. …
3.
4.type PersegiPanjang struct {
5. P, L int
6.}
7.func main() {
Output
{10 22}
Array, slice, map, methods, pointer,
interfaces etc.
https://tour.golang.org/list
What the heck is concurrency
concurrency
concurrency
People will tend to say ...
concurrency is doing two or more things
simultaneously,
parallelism is doing two or more things
simultaneously.
concurrency is not parallelism
concurrency
“Gue lagi ngobrol
sambil ngopi”
parallelism
“Gue lagi ngoding
sambil denger musik”
concurrency is the composition of
independently executing processes
parallelism is the simultaneous
execution of (possibly related)
computations
concurrency is about dealing with lots
of things at once. parallelism is about
doing lots of things at once
concurrency is about the structure.
while parallelism is about the
execution.
but, concurrency can enable parallelism
how?
to have true parallelism you need to
run your program on a machine with
multiple physical processors
You need analogies
Imagine you have a restaurant
you have no employee
You only have one stove
there is one customer
she orders “omelette” and “french fries”
Without concurrency
1.you go to the kitchen
2.you make omelette
3.when omelette is done, give it to the customer
4.you go back to the kitchen
5.you make french fries
6.when french fries is done, give it to the
customer
With concurrency
1.you go to the kitchen
2.you ask your employee to cook french fries
3.you make omelette OR your employee make french
fries
4.when omelette/french fries is done, give it to
the customer
NOTE: THIS TIME YOU HAVE ONE
EMPLOYEE BUT YOU ONLY HAVE ONE
STOVE
With concurrency + parallelism
1.you go to the kitchen
2.you ask your employee to cook french fries
3.you make omelette AND your employee make
french fries
4.when omelette/french fries is done, give it to
the customer
NOTE: THIS TIME YOU HAVE ONE
EMPLOYEE AND YOU HAVE TWO
STOVES
1 2 3 4 5 6 7 8 9 10
DOCTOR
IN (4 MINUTES)
CHECK-UP (5 MINUTES)
TIME REQUIRED FOR 1 PERSON
4 + 5 = 9 MINUTES
TIME REQUIRED FOR ALL PERSON
9 * 10 = 90 MINUTES
WITHOUT
CONCURRENCY
1 2 3 4 5 6 7 8 9 10
DOCTOR
IN (4 MINUTES)
CHECK-UP (5 MINUTES)
TIME REQUIRED FOR 5 PERSON
4 + 5 * 5 = 29 MINUTES
TIME REQUIRED FOR ALL PERSON
29 * 2 = 58 MINUTES
WITH
CONCURRENCY
1 2 3 4 5 6 7 8 9 10
DOCTOR
CHECK-UP (5 MINUTES)
TIME REQUIRED FOR ALL PERSON
4 + 5 * 5 = 29 MINUTES
WITH
CONCURRENCY +
PARALLELISM
DOCTOR
CHECK-UP (5 MINUTES)
Companies currently using Go throughout the world
https://github.com/golang/go/wiki/GoUsers
Where to go
Tour of Go (https://tour.golang.org)
Go by Example (https://gobyexample.com/)
An Introduction to Programming in Go (https://www.golang-
book.com/books/intro)
Google it.
Thank you!

More Related Content

Similar to Golang 101 (Concurrency vs Parallelism)

Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Robert Stern
 
Text editors project
Text editors projectText editors project
Text editors projectMohit kumar
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughgabriellekuruvilla
 
Golang 101
Golang 101Golang 101
Golang 101宇 傅
 
Go language presentation
Go language presentationGo language presentation
Go language presentationparamisoft
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoChris McEniry
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golangBasil N G
 
なぜ検索しなかったのか
なぜ検索しなかったのかなぜ検索しなかったのか
なぜ検索しなかったのかN Masahiro
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsRuth Marvin
 
go language- haseeb.pptx
go language- haseeb.pptxgo language- haseeb.pptx
go language- haseeb.pptxArsalanMaqsood1
 
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
 
Profiling and optimizing go programs
Profiling and optimizing go programsProfiling and optimizing go programs
Profiling and optimizing go programsBadoo Development
 
What every beginning developer should know
What every beginning developer should knowWhat every beginning developer should know
What every beginning developer should knowAndy Lester
 
Happy Go Programming Part 1
Happy Go Programming Part 1Happy Go Programming Part 1
Happy Go Programming Part 1Lin Yo-An
 
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 GolangMender.io
 

Similar to Golang 101 (Concurrency vs Parallelism) (20)

Go. Why it goes
Go. Why it goesGo. Why it goes
Go. Why it goes
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
Text editors project
Text editors projectText editors project
Text editors project
 
Python and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthroughPython and Pytorch tutorial and walkthrough
Python and Pytorch tutorial and walkthrough
 
Golang 101
Golang 101Golang 101
Golang 101
 
Go lang
Go langGo lang
Go lang
 
Go language presentation
Go language presentationGo language presentation
Go language presentation
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
 
Go Programming language, golang
Go Programming language, golangGo Programming language, golang
Go Programming language, golang
 
なぜ検索しなかったのか
なぜ検索しなかったのかなぜ検索しなかったのか
なぜ検索しなかったのか
 
Mastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loopsMastering Python lesson3b_for_loops
Mastering Python lesson3b_for_loops
 
ForLoops.pptx
ForLoops.pptxForLoops.pptx
ForLoops.pptx
 
go language- haseeb.pptx
go language- haseeb.pptxgo language- haseeb.pptx
go language- haseeb.pptx
 
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
 
Profiling and optimizing go programs
Profiling and optimizing go programsProfiling and optimizing go programs
Profiling and optimizing go programs
 
What every beginning developer should know
What every beginning developer should knowWhat every beginning developer should know
What every beginning developer should know
 
Go fundamentals
Go fundamentalsGo fundamentals
Go fundamentals
 
Happy Go Programming Part 1
Happy Go Programming Part 1Happy Go Programming Part 1
Happy Go Programming Part 1
 
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
 

Recently uploaded

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Recently uploaded (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Golang 101 (Concurrency vs Parallelism)

Editor's Notes

  1. Used on github