5 ms·
> Another weird omission is lack of any kind of concurrency story Grand Central Dispatch (GCD or libdispatch) is generally the concurrency story on Darwin plat
by eunoia 9y ago
> Another weird omission is lack of any kind of concurrency story
Grand Central Dispatch (GCD or libdispatch) is generally the concurrency story on Darwin platforms. There has been an ongoing effort to port it to Linux. Not sure how complete that is but I linked the Github below. Swift on Linux still has a lot of rough edges in general.
https://developer.apple.com/documentation/dispatch https://developer.apple.com/documentation/dispatch
https://github.com/apple/swift-corelibs-libdispatch https://github.com/apple/swift-corelibs-libdispatch
- Cyberdog 9y agoIt's quite complete. Cross-platform Server-Side Swift systems like Kitura use it to do things like multi-threaded HTTP serving. I imagine if you tried hard enough you could find edge cases that work on macOS but not on Linux, but the Linux support is complete enough for everyday production work.
- eunoia 9y agoHey that's fantastic. It's admittedly been a while (6-12 months) since I've tried to run any non trivial Swift code on Linux.
- aplummer 9y agoA good read on the future of Swift concurrency is this from Chris Lattner, https://gist.github.com/lattner/31ed37682ef1576b16bca1432ea9f782 https://gist.github.com/lattner/31ed37682ef1576b16bca1432ea9.... I think currently still slated for Swift 5
- bsaul 9y agoThis is going to be very interesting to watch. They decided to add concurrency after having built an extraordinary complex language. Something people like rob pike thought would be very hard to do (and as both a go and a swift coder, i must say i tend to think he's probably got a point).
- gilgoomesh 9y agoThe concurrency model was planned before the first betas but has been delayed. The devs always knew how they wanted concurrency to work.
- bsaul 9y agoI didn't know that, but i'm not surprised because chris lattner clearly knows what he's doing. I'm still curious to see how it ends up integrating in a language that's been evolving a lot since its design. Saying that they managed to keep concurrency orthogonal to the rest of the language means Rob Pike was "wrong" (or at least what i understood from his point). However, after reading the conversations around the async proposal, it seems to me on the contrary that it is very tightly related to other parts (such as error throwing mechanism, GCD library and syntax in general). We'll see. I wish i didn't have the feeling swift core team is understaffed, because at least for iOS development it is really a joy to program with.
- bsaul 9y agogcd still doesn't enable you to properly create mutexes or the equivalent of @synchronized. Concurrency is still a work in progress in swift, in the most fundamental levels.
- gilgoomesh 9y agolet mutex = DispatchQueue(label: “”) mutex.sync { /* protected code here */ } As for @sychronized, the devs have talked about why it is flawed (requires double locking) and why use should always use a manual mutex scope.
- bsaul 9y agoCreating a closure and scheduling it on a queue seems like a pretty heavyweight way to ensure exclusive access (see https://www.cocoawithlove.com/blog/2016/06/02/threads-and-mutexes.html#mutexes-and-closure-capture-pitfalls https://www.cocoawithlove.com/blog/2016/06/02/threads-and-mu... for more). EDIT: aren't you the one that wrote this article ? :))