Table of Contents for Programming Languages: a survey
Go (golang)
Because it is moderately well-known and well-liked, Go (also called Golang) gets its own chapter.
Good for:
- writing internet servers (todo cite). efficient, concurrency, statically-linked executable.
Attributes:
- Compiled
- Garbage-collection
Pros:
- Compiles fast
- Simple grammar
- "Compared to other languages in the C family, its grammar is modest in size, with only 25 keywords (C99 has 37; C++11 has 84; the numbers continue to grow). More important, the grammar is regular and therefore easy to parse (mostly; there are a couple of quirks we might have fixed but didn't discover early enough)." -- https://talks.golang.org/2012/splash.article
- "Unlike C and Java and especially C++, Go can be parsed without type information or a symbol table; there is no type-specific context" -- https://talks.golang.org/2012/splash.article
- Separate compilation (todo)
- Gofmt
- Produces a single statically-linked executable.
- Structurally typed interfaces
- Relatively efficient memory usage compared to many high-level languages
- named return values [1]
- M:N mapped goroutines (by 'M:N mapped' i mean that Go can start multiple threads and migrate goroutines among them so that if a goroutine blocks, the other goroutines aren't blocked; this is in contrast to having all Goroutines on one thread, or to 1:1 mapping (where each goroutine would have its own OS thread))
- these are semi-premptive; the programmer doesn't have to explicitly yield, rather the Go runtime will yield at various places, such as function calls; but it is possible to go into a tight loop in which case the Go runtime never yields
Cons:
- Lack of fine-grained control over memory management
- Bills itself as a 'systems programming language' however does not allow the programmer fine-grained control over memory management, instead providing mandatory garbage collection. Many commentators who use C++ instead of Go say that the lack of fine-grained control over memory management is what is keeping them from using Go instead of C++, and prevent Go from being a true 'systems programming language' (see various comments at https://news.ycombinator.com/item?id=6417859 ).
- No generics
- No dynamic linking
- No exceptions (more of a best practice than a language constraint though)
- Compiler error to have unused variables and imports -- this can make it cumbersome to experiment and debug, as you have to comment out unused stuff
- No scheduler preemption as of this writing (Aug 2013), but they're working on it
- Multiprocess Go programs can use data races to gain access to unsafe pointer manipulation, meaning that sandboxed systems (such as App Engine) must restrict their users to single-threaded Go. See http://research.swtch.com/gorace
Tours and tutorials:
Feature lists and discussions and feature tutorials:
Overviews:
Best practices:
Library highlights:
Respected exemplar code:
- the Go standard library [2]