Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- it uses "actor model" concurrency. threads manage their own private states and pass messages to each other via channels. you can have shared variables still but it's easily avoided (I didn't have any).
- the runtime runs a threadpool, so new threads in go have little overhead. the "go" statement starts new threads. it also lets you choose to declare variables in-place vs on heap with pointer, but has a garbage collector so you don't care about scopes and lifetimes. so it's a good balance b/w c++ and python/js. uses c * and & syntax
- channels are queues. chan <- thing posts into a channel; thing := <- chan reads from it. both block until the other's available, but the chan can be declared buffered, which allows writes to not block till it gets full.
- A select statement (like in my logger) is a switch statement that waits for the first of a set of channels to have new data, then reads that one. you can for/while loop over select to make it process replies in the order they come in or to have a permanent responder to many things, so u can build dench distributed systems v easily.
Add Comment
Please, Sign In to add comment