265818 (16) [Avatar] Offline
#1
I just started to understand C++ Actor Framework (http://actor-framework.org/) .
Do you know any projects, better oper-source, which actually use this C++ Actor Framework in conjunction with functional approach, thus implementing "Functional Reactive Programming"? I do not really grasp how to use this framework with the functional approach and "tools" you explained in your good book.
Looking for Functional Reactive examples in C++ I found this two libraries: https://github.com/grantila/q (http://libq.io/) and https://github.com/SodiumFRP/sodium-cxx a porting to C++ of a sodium library , both of which seem interesting but not enough mature to be deployed
Looking forward to your kind hints.
Marco
265818 (16) [Avatar] Offline
#2
.
Ivan Cukic (92) [Avatar] Offline
#3
Hi,


The problem is that FRP means a dozen different things to different people.

The C++ Actor Framework implements (CAF) the so-called "actor model" which some people call FRP.

From my point of view, actors are for FRP what a for-loop is for imperative programming. They are a low-level primitive that can be used to build reactive systems. Each actor can receive and send messages asynchronously, and they are isolated from one another - much like the simplified actors from the book.

The reason why actors are considered FRP is that they are reactive - receive messages and react to them, and that they are immutable (though, not completely - each actor can change its behaviour function as a reaction to a particular message).

It is up to the developer to build abstractions over that low-level primitive. I don't know of a library that uses CAF to implement reactive streams for C++.

As for reactive streams in general, there are a few libraries like RX for C++ (from the Reactive eXtensions project by one of the great Haskell, F# people Erik Meijer) and STLab (from Felix Petriconi and Sean Parent).

The main downside of all of them is that FRP/reactive streams have only recently started to become popular so most libraries are young which makes them a risk to use in production. RX for C++ is probably the most mature of them all.

The second downside is that all the libraries focus on different things. And it might lead you to paying for a feature that you don't need in your project with client's CPU cycles.

With all that said, I see the following options:

1) Create your own library from scratch (and later publish it under LGPL or some other free license so that we all can use it)
2) Create the reactive stream abstraction for CAF - you can create actors similar to what is shown in the book
3) Use one of the existing reactive stream libraries




265818 (16) [Avatar] Offline
#4
Dear Ivan,

thank you very much for your kind explanation and hints about possible options.
I got deep into RxCpp and Rx. While Rx is quite an impressively good library, its implementation in C++ is rather lacking: both the documentation and the actual code do cover only a small percentage of the original Rx library.
I know that implementing my own reactive streams library would be the ideal choice, but ...: due to mismatch between my requirements and existing libraries, I had to already implement most of my own numerical linear algebra library, and I'm now implementing my own deep learning library for which the functional reactive approach would be optimal....
So... having to implement also my own reactive streams library seems to me too much, at the moment.
Any other options? ahaha...
Marco
265818 (16) [Avatar] Offline
#5
This issue "Future of RxCpp" already publish more than 40 days ago makes me thinking :
https://github.com/ReactiveX/RxCpp/issues/439
"If you compare development with the other reactive libraries, I get the impression rxcpp is dying. This is a shame since in my opinion there is no alternative in the world of C++"

And matches with my impression.
Ivan Cukic (92) [Avatar] Offline
#6
Well, functional reactive programming is just getting traction in the world, and the C++ community is usually slower to react (pun not intended) than communities of, let's say, hipster languages like Rust, Haskell, etc.

Now, the things are changing a bit - C++ is becoming cool again, and we are getting some really high-quality new libraries (Catch2, Outcome, etc.) and I expect that we'll get a decent reactive stream library at a near point in the future. I know that Eric (the author of range-v3) and a few others are investigating the possibility of having asynchronous ranges with the Coroutines TS. If that pans out, we'll get a new reactive stream library without much work - the range-v3 library itself.

Until that happens, I'd still go for implementing my own (I'm currently doing that for one of my projects smilie - you can see the general idea for what I want to do at https://cukic.co/2018/05/16/voy-reactive-streams-for-distributed-computing-blade/ )
265818 (16) [Avatar] Offline
#7
Dear Ivan,
what do you think about the cppcoro experimental library https://github.com/lewissbaker/cppcoro " target="_blank" rel="nofollow"> https://github.com/lewissbaker/cppcoro which aims to anticipate the features described in the C++ Technical Specification for Coroutines? http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4680.pdf " target="_blank" rel="nofollow"> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4680.pdf
Can be reliably used to implement our own reactive stream library or used in conjunction with, for example, Voj library ?
Ivan Cukic (92) [Avatar] Offline
#8
Haven't seen cppcoro until now, but it does look interesting.

Coroutines TS is great for writing imperative-style async code, or for implementing async libraries. But they are not necessary for implementing FRP libraries (though, co_yield and co_await can make things easier). I'm not sure cppcoro would make implementing Voy much easier - for the time being, all I need is already in boost.asio - no language extensions needed.
265818 (16) [Avatar] Offline
#9
Where can I find Voj library in order to have a look at it? May be I didn't look properly, but I didn't find it in github

Marco
265818 (16) [Avatar] Offline
#10
.
Ivan Cukic (92) [Avatar] Offline
#11
It is not yet public. Damn, you shouldn't have posted the link smilie

It has a long way to go still, I was planning to make a first preview release in November (at Meeting C++).
265818 (16) [Avatar] Offline
#12
I removed the link to Voj. Sorry for such a mistake.
I'm going to have a look at it..