37 lines
1.4 KiB
Markdown
37 lines
1.4 KiB
Markdown
# Go
|
|
Go (also Golang) is a compiled programming language created by Rob Pike, Ken Thompson and others at [Google](google.md), released in 2009.
|
|
In contrast with other "modern" languages (such as Rust, etc.) Go is relatively simple, with the spec being about 130 pages.
|
|
|
|
Go generated executables are bloated (>1 MiB), since everything is statically linked. Using flags
|
|
like `-ldflags "-s -w"` can aid with the executable size by stripping debug symbols, but getting it under 1 MiB
|
|
is almost impossible with the default compiler. However, alternative implementations such as TinyGo compile to small
|
|
executables, mainly targeted for embedded use.
|
|
|
|
Furthermore, Go's runtime is quite heavy by having a [garbage collector](gc.md) and a weird stack layout for
|
|
supporting the builtin concurrency system, goroutines, which makes C interop slow and cumbersome compared to other
|
|
languages.
|
|
|
|
Go being a Google project, depends on it financially, also it has a [code of censorship](coc.md).
|
|
|
|
## Compilers
|
|
Due to Go having a formal spec (and being simple enough), Go has more than one compiler:
|
|
- The main compiler, written in Go itself. { no idea if it has a name ~tocariimaa }
|
|
- [gccgo](https://gcc.gnu.org/onlinedocs/gccgo/): GNU Compiler Collection's Go compiler
|
|
- [TinyGo](https://tinygo.org/): targeted at embedded systems.
|
|
|
|
## Examples
|
|
### Hello world
|
|
```go
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
fmt.Println("Hello, world!")
|
|
}
|
|
```
|
|
|
|
Compiling and running:
|
|
```
|
|
go run hello.go
|
|
```
|