9. 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.
10.
11. 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
12. 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
20. Go was born out of frustration with existing
languages and environments for systems
programming.
21. one had to choose either efficient compilation,
efficient execution, or ease of programming
22. 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.
23. 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.
34. Golang is a simple language. It has only 25 keywords.
35.
36. 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
42. 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
65. Imagine you have a restaurant
you have no employee
You only have one stove
there is one customer
she orders “omelette” and “french fries”
66. 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
67. 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
68. 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
69.
70. 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
71. 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
72. 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)
75. 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.