My first nio project

Hi folks,

To have a grasp on Swift NIO I decided to port my toy project OSCCore on top of it and see if it can work out. Today I reached the completed status so both the core module and the examples now powered by Swift NIO.

What I learned so far

  • The learning curve was a bit steep to me. Dealing with futures and promises (why do they both exist?) is still challenging.
  • However building blocks are easy to understand. To extend the pipeline with a byte pack to OSC message converter was a piece of cake.
  • The whole project looks very Java-ish. It's ok to me, but I hope it will be transformed to more Swift friendly in the future.

My work can be found here: GitHub - segabor/OSCCore at nio
I appreciate your suggestions and tips.



Those are just two sides of the same thing (the consuming side being the Future and the producing side the Promise). Kinda like addObserver and postNotification in NotificationCenter. Makes sense?

1 Like

I got it. But still wondering why both types are used. In Java (or even JS) world they fulfill the same purpose.

I come from Java world. Last time I used Foundation framework it was part of OpenStep API :slight_smile:

The reason for both types is to express intent. A Future can only be waited for, not fulfilled. Conversely, a promise can be fulfilled but not waited for (though you can extract a future from a promise). The type indicates what you should do with the object, which helps you communicate intent.

1 Like

I think I got the point now. Popular implementations deals only with one side of the coin.
Thanks for the clarification,