5 ms·
I just want to say that I'm so glad people are developing concurrent languages. The day that concurrency became of paramount importance to computing, all of the
by jacinabox 8y ago
I just want to say that I'm so glad people are developing concurrent languages. The day that concurrency became of paramount importance to computing, all of the old languages became obsolete! That's also why we have Go; goroutines are a major innovation upon threads.
- bjoli 8y agoHow does go select over N channels where N is not known at compile time these days? I remember the helper API as clumsy and unintuitive. I am sure this has changed since I last used go. Back then (about 2014?) I found go's concurrency model lacking, or at least a little bit too opinionated when compared to CML. Sure, it was possible to work around the limitation, and the extra performance you got from utilising all cores was worth it (parallel CML is a rather new thing, but is getting more common.).
- cdoxsey 8y agoHere's one way: func fanin(out chan<- int, ins ...chan int) { switch len(ins) { case 0: case 1: for msg := range ins[0] { out <- msg } case 2: for { var msg int select { case msg = <-ins[0]: case msg = <-ins[1]: } out <- msg } default: go fanin(out, ins[:len(ins)/2]...) go fanin(out, ins[len(ins)/2:]...) } } https://play.golang.org/p/9KNkheXHUBr https://play.golang.org/p/9KNkheXHUBr You can also use reflect: https://golang.org/pkg/reflect/#Select https://golang.org/pkg/reflect/#Select
- pjmlp 8y agoModula-2 already had co-routines in 1978. Concurrent Pascal had them in 1976. And there are plenty of other examples gaining digital dust.
- bakul 8y agoConcurrent pascal didn't allow unsafe concurrent access to shared data structures. Go allows safe concurrent access but doesn't stop such access. Its authors encourage people to use channels but this sharing is intrinsic -- one can start a nested function as a concurrent goroutine & it has full concurrent access to its environment. Go tools can check for race conditions but ideally such support should be in the language itself. So in a sense Go is worse than Concurrent Pascal for the main feature it touts!
- teamfrizz 8y agoallows and doesn't stop are the same thing.
- kazinator 8y agoMaybe OP means "allows safe concurrent access but doesn't stop unsafe concurrent access".
- bakul 8y agoIndeed. Meant to write "Go allows safe concurrent access but doesn't stop unsafe concurrent access to shared data structures" Thanks & sorry for the confusion.
- espeed 8y agoAnd that capabilities model is one of the big differences in Pony and was the key to achieving Pony's parallel lock-free provably correct concurrency model. Most lang/system capability models (including Go's) are open from the start -- where anyone can do anything -- and then when designing the lang/system you try to restrict access between some things at some of the time, but this gets messy fast and it's hard to get right and thus it's almost never optimal. So rather than trying to start with an open model that's inherently flawed by definition, Pony flips the model on its head and begins from the perspective that everything is denied unless specified. You would say Pony has a deny-first capabilities model, which you can see explicitly defined here in Pony's capabilities matrix... https://soyyomakesgames.wordpress.com/2016/10/10/ponys-capabilities-made-simple/ https://soyyomakesgames.wordpress.com/2016/10/10/ponys-capab... And if you listen to Sylvan's talks, he is emphatic that solving the capabilities problem upfront was key that made everything else possible. All the other cool stuff you hear about in Pony like the provably correct runtime and finally achieving something approaching Hewitt's elusive Actor model that's been theoretically true for 40 years but never fully realized. Well the key to solving that mystery and unlocking the door was to take a new view on the capabilities model and building everything off that from the start.
- espeed 8y agoPony's new novel lock-free Actor model is of considerable note. Sylvan (https://github.com/sylvanc https://github.com/sylvanc) has since joined MSR Cambridge and is working on the distributed model now... https://github.com/ponylang/ponyc https://github.com/ponylang/ponyc https://www.ponylang.io/discover/#what-is-pony https://www.ponylang.io/discover/#what-is-pony https://www.youtube.com/results?search_query=ponylang https://www.youtube.com/results?search_query=ponylang
- YorickPeterse 8y ago> goroutines are a major innovation upon threads. Not exactly, Erlang has had them for almost three decades.
- dragonwriter 8y agoGoroutines are not Erlang processes; they are similar in that each is multiplexed M:N style onto native threads, but goroutines aren't shared-nothing, and they communicate with channels rather than each process having a mailbox.
- abrookewood 8y agoArguably, new styles of programming are making concurrency less important. You won't always need a concurrent language when you can spin up a thousand instances of your function on platforms like AWS Lambda etc.
- espeed 8y agoNo, don't think like that. Concurrency is becoming more important, that's just the new reality on the other side of Moore's Law. Concurrency doesn't just happen. Someone has to design the AWS Lambda concurrency model and build the system to scale even if it's not you. And unless the system's design is improving over time and approaching optimal, eventually no one's going to use it because it will cost more than it should so people will move on toward the optimal one. And just like we have multi-layer caching models, distributed means we now have multi-layer concurrency models. Message passing Actors might be optimal between nodes, but within nodes matrix-multiply tensor models running on GPU/TPU accelerators is where optimal's at. And unless you understand it, you won't even be on the map.