Hurray! Not. Swift 3.0 Final Release

Exciting: Swift 3.0 has been released last week. Or not so: the embedded libdispatch contains a crasher bug (SR-2656) which seems to render it useless (for channel based I/O) on Linux. And in consequence the Noze.io + Swift 3.0 combination on Linux.

Status of Swift 3.0 Port

The develop branch of Noze.io is converted and compiling with Swift 3.0 on both, tuxOS and macOS. As announced before this branch has all the Swift 2.x bits removed and only compiles with the Swift 3.0 final release. Everything looks much better now without all the #if swift(>=3) conditionals.

However: as mentioned, the Linux release of Swift 3.0 contains a major crasher which we reported a while ago and which now seems to be looked at.

Summary: Everything is compiling with Swift 3.0, it works on macOS but currently doesn’t work on tuxOS.

Due to this we can’t currently make a proper Noze.io release for Swift 3.0. Hence the Noze.io master branch still contains the last working release on Linux: either using Swift 2.2 or Swift 3 Preview 4.

Since it is unclear when a potential Swift 3.0.1 for Linux is being released we looked at options. One happens to be libuv.

libuv

What is libuv? libuv is the C networking library developed for and used by Node.js (and others). It provides asynchronous I/O similar to libdispatch as well as some threading support, process handling etc. It does not have an implementation of the ‘dispatch queue’ concept, but provides mechanisms to build one on top.

It seems perfectly viable (and neither particularily hard nor time consuming) to also provide Noze.io socket/file streams which build on top of libuv instead of libdispatch channels.

Advantages:

  • Presumably very stable, after all it is being used in production on everything Node.js
  • Cross platform - even works on Windoze
  • Potentially more scalable (built specifically for server workloads, while GCD was originally build for client app usage)

Disadvantages:

  • An external C dependency, which we really wanted to avoid in Noze.io (keep it as a pure-Swift project as much as possible)
  • Incompatible versions. E.g. the libuv coming with Ubuntu Trusty is incompatible to the one available in Brew, making the previous point worse.

Decision: Pending. Feedback is welcome :-)

An initial prototype attempt to give libuv a libdispatch like API can be found over here: DispatchUV.

Swift Package Manager

Even with Swift 3.0 released, Xcode 8 is not supporting Swift Package Manager. Since we want to make it easy for the audience, this means that we are going to stick to the “single package with multiple modules” setup (aka Rechargables Included).

That way one only needs to pull a single Noze.io package from GitHub to get going. Note that though that will fetch the full sources, we still build small and focused modules you can selectively link to. You are not required to carry all the cows in your binary!

hh

Written on September 22, 2016