5 ms·
> As far as I know, no other popular language allows you to read from multiple queues at the same time Off the top of my head, that's certainly possible in Rus
by fasterthanlime 4y ago
> As far as I know, no other popular language allows you to read from multiple queues at the same time
Off the top of my head, that's certainly possible in Rust, C++ and Java - probably many others I just don't know about.
That particular bit of concurrency goodness comes from the 70s, so you can be sure other languages picked it up.
- npe 4y agoAs I understand it, he's talking about select/alt (i.e. guarded commands from CSP) being a native feature of the language rather than callback-based approaches. It's possible to implement CSP channels in most languages, but they're not first-class like go.
- samhw 4y ago> It's possible to implement CSP channels in most languages, but they're not first-class like go. But does that matter? In all my experience, I can't think of any instances where that wouldn't be a distinction without a difference. (Perhaps I'm missing something, though.)
- fasterthanlime 4y agoDefaults matter because friction matters, but friction there is largely removed by having a decent package manager, so I personally don't think it matters (though the topic of "what batteries should be included" has far from run its course).
- npe 4y agoThe minute you put language constructs in the base syntax and runtime of the language, it's a lot more than friction. Love it or hate it, Go is inextricably tied to CSP.
- npe 4y agoIt matters a lot IMO. Most systems programming languages can implement whatever concurrency primitives you care to use, but most people default to whatever is provided by the OS/language because concurrency is hard. Having first-class syntactic sugar over a concurrent runtime bakes in a certain programming style in the language, which strongly determines how the language is used and the programming style. Go comes out of the Newsqueak/Aleph/Limbo family which has a very different style of programming compared to a lot of other languages.
- samhw 4y agoI think there's a difference between 'in the standard library' and 'in the language', though. They seem to be praising Go for doing the latter. And the technical language in which it was expressed gave me to think there was some technical motivation for that, as opposed to sociological - but if what they meant is what you said, then I certainly wouldn't disagree with that.
- npe 4y agoI'd argue that Go is explicitly sociological. Most of the novel ideas in Go (process calculi/guarded commands in a concurrent language) were originally embedded in Cardelli and Pike's Squeak back in the 80s. The rest is trying to standardize the way scalable web applications are built.
- Mawr 4y agoIt's the opposite - pointing out that X can just as well be implemented in language Y is the irrelevant point because anything can be implemented in any turing complete language. Where languages differ is what they make easy to use, or first class. As an example consider Go's autoformatter gofmt. It got released with the language, pushed and marketed as the way to format your code - first class. As a result, virtually all Go code is uniformly formatted. Contrast that with autoformatters in other languages pre-Go. They existed, but often multiple per language, each with hundreds of configuration options, all with minimal uptake in their ecosystems.
- thestoicattack 4y agoAda too, I think.
- pyjarrett 4y agoAda has had this built-in for decades, and even allows selecting from one of multiple waiting queues (entries) using a `select` keyword.
- bheadmaster 4y agoIf you could spare some time, would you please demonstrate an example? Any language of those mentioned would be OK.
- fasterthanlime 4y agoHere's a Rust example, with tokio: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=825256f548eb9bb5df528704867f80fd https://play.rust-lang.org/?version=stable&mode=debug&editio... - I don't have time to come up with Java/C++ examples, but I'm sure others will. (If your point was about it being _built into the language_, then it definitely stands, see the other discussion in the parent comment thread)
- paskozdilar 4y agoYeah, I guess I overestimated the complexity of such mechanisms. I mean, still, you need some kind of runtime for the asynchronicity, but the Rust version seems fairly OK (apart from the function coloring, but that's another story). I guess I just like it being built into the language. Plus no function coloring (everything is asynchronous, but appears synchronous) really makes it easy to build complex systems.
- autarch 4y agoHere's a rust example - https://github.com/autarch/channel-select https://github.com/autarch/channel-select