Difference between revisions of "Team Go"
(→Concurrency) |
|||
Line 39: | Line 39: | ||
Go supports concurrency through '''Goroutines''' and '''Channels''' | Go supports concurrency through '''Goroutines''' and '''Channels''' | ||
+ | |||
+ | == Goroutines == | ||
+ | |||
+ | A goroutine is a function capable of running concurrently with other functions. They're similar to threads except they're much cheaper and are managed automatically. |
Revision as of 22:32, 17 December 2017
Contents
Team Go
Group Members
Go Programming Language (Golang)
Go is an open source programming language made by engineers at Google. The project started development in 2007 and was officially announced in 2009. Built in the gc compiler Google Go is developed as an open source software. The language targets all three major platforms (Linux, OS X and windows) but can also run on mobile devices. The Go language originated as an experiment by a few google engineers with the intention to take all the positive characteristics of existing languages and resolve the common criticism. Go is meant to be statically typed scalable language like C++ or java while also being productive and readable; Go tries to avoid the repetition of too many mandatory keywords
Understanding the language
Syntax
Optional concise variable declaration and initialization
x := 0 not int x = 0
Remote package management
go get
Problem Approaches
Built-in concurrency primitives!
Light-weight processes, channels and select statements
Uses interface system instead of virtual inheritance
Function returns
Functions may return multiple values, and returning a result, err pair is the conventional way a function indicates an error to its caller in Go.
Concurrency
making progress on more than one task simultaneously is known as concurrency. Concurrency is not parallelism! Concurrency is about dealing with lots of things at once while parallelism is about doing lots of things at once. Good concurrency can make it easier to parallelize.
Example: A computer running mouse and keyboard drivers, network drivers, printer drivers etc. is an example of concurrency. These could all run on a single core and don't have to be parallelized but they can also be run on separate cores to increase throughput.
Go supports concurrency through Goroutines and Channels
Goroutines
A goroutine is a function capable of running concurrently with other functions. They're similar to threads except they're much cheaper and are managed automatically.