I would like to share some of my opinion as well.
I agree with you that we should have some design guidelines.
For me personally I would prefer protocol-orientated than functional approach for the following reasons, these are just thoughts:
- Life cycle of objects and call back hell.
- in a networking environment it is hard to guarantee if the object still exist over and over different handlers, and since we can only store closures that are escaping, we really can’t guarantee what will happen, which can lead to callbacks hell.
- Retains a lot of “middle men”
- callbacks hells. (For example, Node.js)
- more likely to cause memory leak (If some closure is retaining its owner).
- No need to worry about class inheritance
- Much easily to schedule events.
- for example, if we defines the way to read from the socket as socket.read(), it guarantees we only drain the socket when we need to, instead of letting the socket to make the decision since socket itself has no knowledge of our runtime at all.
- Much more readable
- Clear separation between roles of objects
I think the reactive and functional approach is still necessary, but for higher level api, which I think it’s stakeholder’s job to do with their own web frameworks. Since developer will expect a callback orientated API since it is more expressive to code with.
But sometimes, you might not necessarily want to drain data from the socket immediately (It never happen on me), a reactive model is easy and expressive but not necessarily powerful when we simply don’t want things to happen immediately. I think making functional programming can be danger as a guideline for building building blocks.
I think stick with a model with less callbacks will be much easier and safer. Nevertheless, protocol is much more powerful since we can access the methods and also the properties of an object without worry about an object retaining itself in closures.
I believe I’m might be a little bit off topic here and lot of thing I write can be false as well, but these are just some thoughts I have in my mind.