1 Şubat 2021 Pazartesi

Go Programlama Dili

Giriş
Henüz hiç Go Programlama Dili ile bir iş yapmadım. Ancak bazı notlar almak istedim. Go ile kendi başına çalışabilen bir exe elde edilir. JVM gibi bir şeye ihtiyaç duyulmaz.

Kim Geliştirdi?
Açıklaması şöyle. İlk sürümü 2012 yılında. Yani oldukça yeni
Go was created by Robert Griesemer, Rob Pike and Ken Thomson at Google. Between them they made major contributions to UNIX, B, C, Plan9, UNIX windowing system, and more.) It is open source, had its 1.0 release in 2012 and had its 1.15 release in 2020. It is growing fast both in terms of adoption and the language and tooling ecosystem itself.

Go is influenced by C, Python, Javascript and C++. It is designed to be a best of breed language for high performance networking and multiprocessing.
Statically Typed Bir Dildir
Açıklaması şöyle. Bir derleyicisi vardır. Statically Typed bir dildir ve Garbage Collector kullanır.
Go is a statically-typed, compiled language. Its syntax is C-like. It has memory safety, garbage collection, structural typing, and CSP-style concurrency (communicating sequential processes). It has lightweight processes called goroutines (these are not OS threads), channels for communicating between them (typed, FIFO). The language does not provide race condition protection.
Bazı güzel tarafları şöyle
What’s good about Go (compared to Java) — this is my personal opinion based on my experience:
- It is easier to implement functional patters like composition, pure functions, immutable state.
- There is much less boilerplate code (but still too much).
- It is still early in its lifecycle so it does not have the same crushing burden of backward compatibility — they can still break things to improve it.
- It compiles into a native statically-linked binary — no virtual machine layer — the binary has everything you need to run the program, which is great for “FROM scratch” containers.
- It has small size, fast startup and fast execution.
- No OOP, inheritance, generics, assertions, pointer arithmetic,.
- Less parentheses, e.g. if x > 3 { whatever }
- Enforces that are no cyclic dependencies, no unused variables or imports, no implicit type conversions.
Enum
Örnek
Şöyle yaparız
type BodyPart int

const (
  Head BodyPart = iota // Head = 0
  Shoulder // Shoulder = 1
  Knee // Knee = 2
  Toe // Toe = 3
)

func (bp BodyPart) String() string {
  return [...]string{"Head", "Shoulder", "Knee", "Toe"}
}


Hiç yorum yok:

Yorum Gönder