Notepad/enter/Coding Tips (Classical)/Terminal Tips/Languages/Go/Welcome to Go.md

51 lines
1.5 KiB
Markdown
Raw Normal View History

# Go Programming Language
For a great textbook to learn Go, read [this textbook by Donovan & Kernighan](https://drive.google.com/file/d/1-n9s6Qc0JYdQHz86GbUTaJ_j3Fzp7IE7/view?usp=sharing)
2023-07-05 18:29:11 +00:00
Why learn Go? Well, their entire [webpage](https://go.dev/solutions/#case-studies) that explained literally that exact question may have had something to do with it. And I saw a youtube video yesterday saying how it was better than Rust, the literal most "loved" language currently in terms of long-term performance. So both of those two things got me sold.
They have a rather intuitive learning module called [The Go Playground ](https://go.dev/play/)which makes it actually desirable to learn even.
```
// You can edit this code!
// Click here and start typing.
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
```
And tons more examples to try and out and learn from such as [Conway's Game of Life](https://go.dev/play/) and more.
This is how a fibonacci sequence could be implemented:
```
package main
import "fmt"
// fib returns a function that returns
// successive Fibonacci numbers.
func fib() func() int {
a, b := 0, 1
return func() int {
a, b = b, a+b
return a
}
}
func main() {
f := fib()
// Function calls are evaluated left-to-right.
fmt.Println(f(), f(), f(), f(), f())
}
```
With the output being: 1 1 2 3 5
When actually looking at it, it's kinda cool. It's not actually hard recursion like the way that it seemed like before with lisp.