What does HackerNews think of swift-corelibs-libdispatch?

The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware

Language: C

GCD/libdispatch is a fantastic approach to concurrency and you can build and install support for non-Apple operating systems:

https://github.com/apple/swift-corelibs-libdispatch

Here’s a simple echo server:

https://github.com/williamcotton/c_playground/blob/master/sr...

Here’s a simple multithreaded database pool:

https://github.com/williamcotton/express-c/blob/master/src/d...

> But I would certainly be more enthusiastic if any effort was presented to make it cross-platform and, hopefully, open-source and/or standardized.

They opensourced libdispatch[1] and ported it to linux, so there's hope they might do the same with Network.framework. It would be time consuming, but it shouldn't be hard for someone in the opensource community to write a linux / BSD implementation of this stuff on top of posix sockets & libdispatch.

I suspect the reason they didn't opensource it is that it looks like it was designed mostly with phone apps in mind, not servers. And thats a shame - it looks like it would be a great addition to the swift server story, especially given it does user-space networking out of the box. I still prefer swift's ergonomics over rust for application development, and this would help immensely. (Rust is steadily closing that gap though, what with native wasm support and async/await on their way.)

[1] https://github.com/apple/swift-corelibs-libdispatch

> 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://github.com/apple/swift-corelibs-libdispatch

Good question.

For networking, Kitura uses Kitura-net, which uses BlueSocket, which in turn uses C library's sockets[1]. On GNU/Linux, this is the GNU C Library, for which a package (Glibc) is provided by the Swift port[2].

For asynchrony they seem to be using libdispatch despite it being "early in the development"[3], but I've also noticed they're wrapping epoll and curl (see 1.B again), so it's hard to gauge the real extent of the hack.

[1]: https://github.com/IBM-Swift/Kitura/blob/master/Package.swif...

https://github.com/IBM-Swift/Kitura-net/blob/master/Package....

https://github.com/IBM-Swift/BlueSocket/blob/master/Sources/...

[2] https://swift.org/blog/swift-linux-port/

[3] https://github.com/apple/swift-corelibs-libdispatch

> Because concurrency is supported through an Apple API rather than being explicit in the language’s design, using it is currently very much coupled to iOS or macOS development.

I am not sure this is accurate, because libdispatch has been ported to Linux:

https://github.com/apple/swift-corelibs-libdispatch

They are "...early in the development of this project..." but server-side frameworks use it.