BOOST/STD/AKKA: How do I do actor programming in C++? - c++

(Question and description rephrased so as to be S.O. compatible)
It is strange that C++ has no widely-adopted, peer-reviewed actor model library yet (on the order of BOOST and STD). I see Theron, but it looks like a man and his code: no matter how good it is, it is not something I would want production code to rely on.
Thus, how do I do Actor Model programming in C++ without having to use unproven libraries? Which BOOST classes should I use?
Note: I am asking this in the face of one or two previous questions on S.O. that show up when one searches for "actor C++" because they had little or no traction. For SEE SHARP, there is this thread But for C++, even the one question that got medium traction this guy, a question from FIVE YEARS AGO was answered with a pointer to a dead link!

libcppa can be a good choice. Looks better than Theron (which seems to be dead -- the author didn't respond to my email about a bug I've found). Also, there's a "fork" of libcppa named Boost.Actor from the same author here. So hopefully in a couple of years we'll have a proper well-tested peer-reviewed actor implementation in Boost :)

The lack of an answer by now seems to imply that there is as of 2014 no strongly peer-reviewed Actor system in platform-independent C++.
If you're using Microsoft VS, you can use the Microsoft Asynchronous Agents library
There is also the Intel TBB FlowGraph library, but global availability seems questionable, so it is unclear as to how well it would work on Android/Exynos/Snapdragon/etc or iOS/armv systems. See this question.

libcppa is not peer reviewed (yet), but it's being developed by the iNET working group at the Hamburg University of Applied Sciences. There are publications surrounding its development, it includes a Benchmark Suite, and it is currently in the preliminary submission process for Boost under the name Boost.Actor. If you want to have a peer reviewed actor system in the future, please go ahead and join the discussion on the Boost Mailing List or give Boost.Actor a (short) review in the brand new Boost Library Incubator.

I agree that code should be peer reviewed, and that there is a need for such a library for C++. I have based my code on Theron, which I find quite complete and very efficient, and with a proper C++ API (much better than libcppa). Ashton has also always responded quickly to all of my requests. Let us hope that it will be released for other committers soon!
The downside with Theron is that its mechanism for distributed communication is broken since it was based on XS a dead variant of ZeroMQ. I am in the process of redesigning the communication mechanism and intend to release this back to Theron by May 2015 with a complete support for ZeroMQ. Thus, Theron is at least properly peer reviewed by me...
I would not recommend building your own Actor mechanism - it will then just be "another man with his code" as you stated. It would be better if we could have a proper release of Theron that we could all work on.

Related

C++ Standardization Net TS1 & Filesys TS

I have a few questions about the standardization, in particulair the prototype of Net TS1 coming this year (see here).
When does it exactly come?
Does it support portable binairy serialization?
Can it serialize to iostreams like files/std::cout etc?
Is there some other place where I can find the current status besides the mailing lists?
When will GCC/Clang implement it?
About the filesystem (Filesys TS):
It was supposed to be finished as prototype this month, why can't I find anything anywhere?
Is it the same a boost::filesystem? (So it can easily be ported.)
I hope I'm not asking too much questions, and I also hope some can be answered!
The latest full Networking Library proposal, based on Boost.Asio, was published in 2007. At that time, C++0x was still planned for sometime before 2010 and there was also a plan for a C++ Technical Report 2. The idea was to get the Networking Library into TR2.
Working on C++0x clearly stole everybody's attention, because not much else happened with the networking library until after it was published. In 2012, they produced a Networking Library Status Report and noticed that a lot had changed with Boost.Asio in the past 5 years. A study group was formed (SG4) to work on the Networking Library.
Now TR2 doesn't seem to be a happening, and it's full steam ahead for C++14 and beyond. As far as I can tell, there has been no explicit mention of a planned time frame for SG4. However, since it was formed, these are the most up-to-date papers from the mailings:
Using Asio with C++11 (N3388)
Urdl: a simple library for accessing web content (N3477)
C++ Internet Protocol Classes (N3477)
A URI Library for C++ (N3507)
IP Address Design Constraints (N3565)
A Three-Class IP Address Proposal (N3603)
Network Byte Order Conversion (N3620)
So combine these with the full TR2 proposal and you have a pretty good picture of the current status.
When does it exactly come?
There doesn't seem to be a specific time frame. Hopefully we'll see a technical specification sometime before C++14 (maybe even in 2013), but this is merely speculation. It'll be done when it's done.
Does it support portable binary serialization?
I don't think so. I can't find any mention of serialization in any of the papers. I think it's probably beyond the scope of the Networking Library.
Can it serialize to iostreams like files/std::cout etc?
See above.
Is there some other place where I can find the current status besides the mailing lists?
Not at the moment. However, they have been gradually making the mailing lists for each of the study groups public, so maybe SG4 will be made public soon. If it is, we'll get a better view of current progress.
When will GCC/Clang implement it?
Not yet!
In January 2013, revision 4 of the Filesystem Library proposal hit the mailing list. Again, I see no explicit time frame, but this and the Networking Library are the two library study groups with the most focus right now. Hopefully we'll be able to see a technical specification for this too sometime this year or at least before 2014.
It was supposed to be finished as prototype this month, why can't I find anything anywhere?
I haven't seen anything about a prototype, but I guess things sometime take a little longer than planned. Perhaps it just isn't public yet. The Bristol meeting is being held next month and all study groups' progress reports are on the agenda. I'm sure we'll see a technical specification when it's ready.
Is it the same a boost::filesystem?
Pretty much! Take a look at the latest revision; it mentions that it is heavily based on the Boost Filesystem Library version 3. There is a small section on differences:
In the Boost library, facilities in class path to handle narrow (i.e. char) character strings with encodings other than the operating system's native encoding depend on codecvt arguments. In the proposal, these facilities depend on locale arguments and additional UTF-8 facilities have been added. The Filesystem Study Group believes this approach is more reliable and useful, particularly as UTF-8 use continues to spread.
Otherwise, the proposal is very similar to the Boost library. Indeed, most of the proposed wording is generated from the same source as the Boost library's reference documentation.
Like all formal ISO C++ documents, Technical Specifications come when they're done. What it will support is hard to say up front. Features may be cut if they're not ready, or conversely publication may be delayed to get a wanted feature in. E.g. C++98 was delayed for ~2 years to merge in the STL.
The FileSystem TS is indeed being derived from Boost FileSystem, so there is very likely a high degree of commonality.

Boost advocacy - help needed

Possible duplicates
Is there a reason to not use Boost?
What are the advantages of using the C++ BOOST libraries?
OK, the high-level question is "Please provide me with what you consider to be the most effective arguments of why entire Boost, or some specific parts of it, should be compiled on our company's system and endorsed in software engineering standards".
Details of what I need:
Would gladly accept both positive arguments (why install), as well as proposed rebuttals of likely counter-arguments I might hear (see question context below).
Arguments should be made aimed at both technical Software Engineering team members and/or very technical senior managers - in other words, for the latter, the details of the argument may/should be technical, but the thrust of the argument should be "how would this make/save the company X money vs losing the company Y money as a cost of adding it to our toolset".
Context of the question:
I'm a developer in a company with several hundred developers, many dosens of whom do C++.
I had the (mis)fortune of being reassigned from my beloved Perl development spot to a team where I am also doing C++ development. So far I found numerous things that I could easily have done in Perl that are very hard/cumbersome to do in C++ (foreach loop as an example), and anytime I hit one of these, the answer 50% likely ends up being "You can't do this in standard C++ but you can do it with Boost"
Our toolkit includes some legacy RogeWave libraries, and VERY limited number of Boost libraries (e.g. no regex, no foreach), of very old vintage.
Any development must use libraries compiled and vetted by Software Engineering team. That is a hard and fast rule.
SE team is somewhat resistant to adding new libraries, for a variety of reasons (e.g. effort to do this; functionality conflicts with RogeWave, for example for RegEx; the risk of installing and using any new software; cost of educating developers, etc...). They will add the libraries if presented with sufficient business need or majorly convincing cost/benefit ratio argument, but they have pretty tough threshold.
So, I'm looking for examples of which parts of Boost are so wonderful (with exact cost/benefit estimates) that installing them would be an Obviously Worth It Effort for Software Engineering.
Thanks in advance for any ideas/suggestions/examples.
Please don't mark this question as subjective as I am looking for measurable answers, not merely wonderful feelings :)
Wherever I worked in the last decade, when they had their own smart pointer class, I found bugs in that - usually within a few weeks. And, no, I never went and looked at it hoping to find errors.
I got into the habit of posting the following quote from the TR1 smart pointer proposal:
The Boost developers found a shared-ownership smart pointer exceedingly difficult to implement correctly. Others have made the same observation. For example, Scott Meyers [Meyers01] says:
"The STL itself contains no reference-counting smart pointer, and writing a good one - one that works correctly all the time - is tricky enough that you don't want to do it unless you have to. I published the code for a reference-counting smart pointer in More Effective C++ in 1996, and despite basing it on established smart pointer implementations and submitting it to extensive pre- publication reviewing by experienced developers, a small parade of valid bug reports has trickled in for years. The number of subtle ways in which reference-counting smart pointers can fail is remarkable."
This plus a detailed analysis of the bug(s) I found usually got me the job of incorporating the boost libs into the code base. :)
It seems to me you're doing this the wrong way around. Since proposals to add new libraries are going to be met with a lot of resistance, don't even bother trying to argue for boost as a whole. Choose your battles instead.
Find the specific Boost libraries which you know (with your knowledge of the application it's to be used in) will be useful and save time and money. And then propose adding those.
I could easily list the Boost libs I've found useful, and why I think they're great, but I don't know if they'll be of any use in your application.
Push for individual boost libraries to be included, and then perhaps, over time, so many of them will be included that it'll be simpler for everyone to just include all of Boost.
It's an open standard not controlled by a specific company ( no licensing costs )
It's cross platform
It's expertly designed / written and very fast / efficient extensively tested
There are open source implementations which your team can compile themselves.
Boost will soon become part of the standard C++ STL
Here is a slightly oldish 2005 article on Dr. Dobbs discussing the upcoming C++0x standard.
http://www.ddj.com/cpp/184401958
I had to maintain a component using that old vintage Tools.h++ from Roguewave, on a Solaris system.
On Solaris, if we want to use boost, we need to use either gcc, or SunStudio with STLport implementation of the standard (instead of Roguewave one). And as Tools.h++ requires the old Roguewave pre-standard implementation of the standard -- on Solaris --, I had to give up on boost.
In the end I rewrote a simplified version of a few boost-like features I needed.
If you are in that same situation (*) , you would not be able to move from Roguewave library to boost that easily. There is a non negligible cost in this operation, as for instance pointer containers from both libraries have quite different interfaces.
(*) Where we can't slowly change bits by bits of the old code to progressively use boost. In that situation, the migration has to be radical and to change simultaneously every occurrence of Tools.h++ by something more trendy, or even better.
NB: Most people are able to progressively use boost in old projects, and may miss a very important, and yes technical, point. Hence my negative answer.
Boost is a great tool and an invaluable part of our product development (we'd be lost without smart_ptr)... but because it is changing so fast the stability of releases can be effected.
For example, we were happily introducing new versions of Boost as soon as they came out without thinking twice. That is until we were stung with a bug in the 1.35 threading library that produced occassional (ie difficult to debug) but critical errors. Fortunately we identified the issue before anything was released to the public and could move back to 1.34.
Ever since then we've taken a specific version, extensively tested it, and not updated without a compelling reason to do so.
Here are two suggestions for advocating boost:
Who's Using Boost? (http://www.boost.org/users/uses.html)
lots of major projects use boost: (e.g., adobe photoshop, CERN)
Boost Project Cost (http://www.boost.org/development/index.html)
How much it would cost to hire a team to write boost from scratch? There's a nifty (somewhat gimmicky) calculator there that helps to put it in perspective.

How to use the C++ Sockets Library

I'd like to do some network socket programming in C++ and have found the C++ Sockets library.
First, is this a good way to go in C++? Normally in C, I'd use some of the stuff beej describes in his tutorial.
Second, how do I compile the examples given on the site? I can't figure it out from their installation/configuration guide. So I download the tar.gz to my Linux box, then what?
To have a specific example, how do I compile and run the DisplaySocket example?
Thanks.
EDIT: Thank you for the quick answers. A comment though. I'm not really looking into "understanding" network programming as I think I do that well enough already. I want to know if there's anything in particular to take advantage of in C++, and - if "the C++ Sockets Library" is a good choice - how to use it.
That's not "the" C++ sockets library, it's "a" C++ sockets library. Boost.asio has another (http://www.boost.org/doc/libs/1_39_0/doc/html/boost_asio.html).
(Community Wiki since I can't actually help you with your question - I've never compiled the code you ask about, so I don't know at what point you might have tripped over a problem).
Network programming would be better understood by using basic socket api (BSD or WinSock) rather than a socket library which hides most of the intricacies about sockets and their behaviour.
I would second the vote for boost::asio since it encapsulates the inversion of control model that is the current, preferred model, and appears to be standard-bound. To learn what the documentation doesn't tell you, google Douglas Schmidt and his books.
I like to use the ACE networking library when I write networking code in C++. I think it does a nice job abstracting some of the intricate details away that make network coding painful but doesn't do it to the point where it hides what is going on under the hood. It also has facilities for threading and messaging which usually are needed for any project.

ACE vs Boost vs POCO [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have been working with the Boost C++ Libraries for quite some time. I absolutely love the Boost Asio C++ library for network programming. However I was introduced to two other libraries: POCO and Adaptive Communication Environment (ACE) framework. I would like to know the good and bad of each.
As rdbound said, Boost has a "near STL" status. So if you don't need another library, stick to Boost. However, I use POCO because it has some advantages for my situation. The good things about POCO IMO:
Better thread library, especially a Active Method implementation. I also like the fact that you can set the thread priority.
More comprehensive network library than boost::asio. However boost::asio is also a very good library.
Includes functionality that is not in Boost, like XML and database interface to name a few.
It is more integrated as one library than Boost.
It has clean, modern and understandable C++ code. I find it far easier to understand than most of the Boost libraries (but I am not a template programming expert :)).
It can be used on a lot of platforms.
Some disadvantages of POCO are:
It has limited documentation. This somewhat offset by the fact that the source is easy to understand.
It has a far smaller community and user base than, say, Boost. So if you put a question on Stack Overflow for example, your chances of getting an answer are less than for Boost
It remains to be seen how well it will be integrated with the new C++ standard. You know for sure that it will not be a problem for Boost.
I never used ACE, so I can't really comment on it. From what I've heard, people find POCO more modern and easier to use than ACE.
Some answers to the comments by Rahul:
I don't know about versatile and advanced. The POCO thread library provides some functionality that is not in Boost: ActiveMethod and Activity, and ThreadPool. IMO POCO threads are also easier to use and understand, but this is a subjective matter.
POCO network library also provides support for higher level protocols like HTTP and SSL (possibly also in boost::asio, but I am not sure?).
Fair enough.
Integrated library has the advantage of having consistent coding, documentation and general "look and feel".
Being cross-platform is an important feature of POCO, this is not an advantage in relation to Boost.
Again, you should probably only consider POCO if it provides some functionality you need and that is not in Boost.
I've used all three so here's my $0.02.
I really want to vote for Doug Schmidt and respect all the work he's done, but to be honest I find ACE mildly buggy and hard to use. I think that library needs a reboot. It's hard to say this, but I'd shy away from ACE for now unless there is a compelling reason to use TAO, or you need a single code base to run C++ on both Unix variants and Windows. TAO is fabulous for a number of difficult problems, but the learning curve is intense, and there's a reason CORBA has a number of critics. I guess just do your homework before making a decision to use either.
If you are coding in C++, boost is in my mind a no-brainer. I use a number of the low level libraries and find them essential. A quick grep of my code reveals shared_ptr, program_options, regex, bind, serialization, foreach, property_tree, filesystem, tokenizer, various iterator extensions, alogrithm, and mem_fn. These are mostly low-level functionality that really ought to be in the compiler. Some boost libraries are very generic; it can be work to get them to do what you want, but it's worthwhile.
Poco is a collection of utility classes that provide functionality for some very concrete common tasks. I find the libraries are well-written and intuitive. I don't have to spend much time studying documentation or writing silly test programs. I'm currently using Logger, XML, Zip, and Net/SMTP. I started using Poco when libxml2 irritated me for the last time. There are other classes I could use but haven't tried, e.g. Data::MySQL (I'm happy with mysql++) and Net::HTTP (I'm happy with libCURL). I'll try out the rest of Poco eventually, but that's not a priority at this point.
Many POCO users report using it alongside Boost, so it is obvious that there are incentives for people in both projects. Boost is a collection of high-quality libraries. But it is not a framework. As for ACE, I have used it in the past and did not like the design. Additionally, its support for ancient non-compliant compilers has shaped the code base in an ugly way.
What really distinguishes POCO is a design that scales and an interface with rich library availability reminiscent of those one gets with Java or C#. At this time, the most acutely lacking thing from POCO is asynchronous IO.
I have used ACE for a very high performance data acquisition application with real time constraints. A single thread handles I/O from over thirty TCP/IC socket connections and a serial port. The code runs on both 32 and 64 bit Linux. A few of the many ACE classes I have used are the ACE_Reactor, ACE_Time_Value, ACE_Svc_Handler, ACE_Message_Queue, ACE_Connector. ACE was a key factor to the success of our project. It does take a significant effort to understand how to use the ACE classes. I have all the books written about ACE. Whenever I have had to extend the functionality our system it typically takes some time to study what to do and then the amount of code required is very small. I have found ACE to very reliable. I also use a little bit of code from Boost. I do not see the same functionality in Boost. I would use either or both libraries.
I recently got a new job and work on a project that uses ACE and TAO. Well, what I can tell is, that ACE and TAO work and fully accomplish their tasks. But the overall organisation and design of the libraries are quite daunting...
For example, the main part of ACE consists of hundreds of classes starting with "ACE_". It seems like they've ignored namespaces for decades.
Additionally, many of ACE's class names don't provide useful information either. Or can you guess what classes like ACE_Dev_Poll_Reactor_Notify or ACE_Proactor_Handle_Timeout_Upcall can be used for?
Additonally, the documentation of ACE is really lacking, so unless you want to learn ACE the hard way (it is really hard without any good documentation..), I would NOT recommend using ACE, unless you really need TAO for CORBA, If you don't need CORBA, go ahead and use some modern libraries..
Boost enjoys a "near STL" status due to the number of people on the C++ standards committee who are also Boost developers. Poco and ACE do not enjoy that benefit, and from my anecdotal experience Boost is more widespread.
However, POCO as a whole is more centered around network-type stuff. I stick to Boost so I can't help you there, but the plus for Boost is its (relatively) widespread use.
The ACE socket libraries are solid. If you are trying to port a standard implementation of sockets you can't go wrong. The ACE code sticks to a rigid development paradigm. The higher level contructs are a little confusing to use. The rigid paradigm causes some anomolies with exception handling. There are or used to be situations where string value pairs being passed into an exception with one of the pair being null causes an exception throw in the exception that will boggle you. The depth of the class layering is tedious when debugging. I have never tried the other libraries so can't make an intelligent comment.
Boost is great, I've only heard good things about POCO (but never used) but I don't like ACE and would avoid it in future. Although you will find fans of ACE you will also find many detractors which you don't tend to get with boost or poco (IME), to me that sends a clear signal that ACE is not the best tool (although it does what it says on the tin).
Out of those I've only ever really used ACE. ACE is a great framework for cross-platform enterprise networking applications. It's extremely versatile and scalable and comes with TAO and JAWS for quick, powerful development of ORB and/or Web based applications.
Getting up to speed with it can be somewhat daunting, but there is a lot of literature on it, and commercial support available.
It's somewhat heavy though, so for smaller-scale apps it may be a bit of an overkill. Reading the summary for POCO it sounds like they're aiming for a system that can be run on embedded systems so I'm assuming it can be used in a much lighter way. I may now give it a whirl :P
I think it is really matter of an opinion, there is hardly a right answer.
In my experience with writing portable Win32/Linux server code (15+ years), I personally find boost/ACE unnecessarily bloated and introduces maintenance hazards (otherwise known as "dll hell") for the little advantage they give.
ACE also seems to be horribly outdated, it is a "c++ library" written by "c programmers" in the 90-s and it really shows in my opinion. It so happens, right now I am re-engineering the project written with Pico, it seems to me it completely follows the ACE idea, but in more contemporary terms, not much better at that.
In any case for high performance, efficient, elegant server communications you might be better off not using any of them.

Best documentation for Boost:asio?

The documentation available on the boost website is... limited.
From what I've been able to read, the general consensus is that it is simply difficult to find good documentation on the boost::asio library.
Is this really the case? If so, why?
Notes:
I have already found the (non-boost) Asio website - and the documentation looks to be identical to that on the boost website.
I know that Boost::asio is new! I'm looking for solutions not excuses.
Edit:
There is a proposal to add a networking library to standard library for TR2 written by the author of Boost:asio (Christopher Kohlhoff). While it isn't documentation for boost:asio, it does use it as a base for the TR2 proposal. Since the author put more effort into this document, I have found it to be somewhat helpful, if not as a reference, then at least as an overview.
Some nice documentation on boost including a chapter on asio can be found in a (free) boost book at http://en.highscore.de/cpp/boost/index.html. The chapter on asio provides a general overview and then goes as far as how to develop your own custom asio extensions. Really fantastic effort by Boris Schäling!
First, I've been using Boost.Asio for quite a while already -- and I share your concern. To address your question:
There really is very scarce documentation about Boost.Asio aside from the introduction and tutorial. I am not the author, but this is mostly because there are just too many things to document for something as low-level as an Asynchronous IO Library.
The examples give more away than the tutorials do. If you don't mind spending a little time looking at the different examples, I would think they should suffice to get you started. If you want to run away with it, then the reference documentation should help you a lot.
Ask around in the Boost Users and Boost Developers mailing list if you're really stuck or looking for specific guidance. I'm pretty sure a lot of people will be willing to address your concerns on the mailing lists.
There are efforts (not part of Boost.Asio) to expose a lot of the functionality and possible alternative use cases. This at best is scattered around the web in blogs and other forms of non-packaged documentation.
One thing that is unclear and which will really need close coordination with the author and developers of the Boost.Asio library would be as far as extending and customizing it for a specific platform or adding specific new functionality. This should be improved though but the good thing is it's looking like Asio will be a reference implementation for a standard library technical report (for an asynchronous IO library in the STL) in the future.
I wrote two small articles that could be used as introductions to boost.asio. They are available from my site
NOTE: I have contacted gamedev.net to let them know about the formatting issues. Unfortunately at the time of writing this comment, this resource is more difficult to recommend because of some changes with their website which hide/delete the #include statements + a missing .zip file resource.
A relatively new and very good beginner tutorial for Boost.Asio (which also introduces how to use it effectively with bind, shared_ptr, and threads) can be found here:
http://www.gamedev.net/blog/950/entry-2249317-a-guide-to-getting-started-with-boostasio?pg=1
Note: If you're using c++0x features many of the simple uses of bind for creating a functor can be replaced with lambdas, and shared_ptr/bind are also available in the latest version of visual studio (or gcc which also includes threads.)
When I was searching for documentation or a tutorial this question kept popping up at the top of search results, so it is important to keep it updated as new tutorials come around.
I came along to 3 videos that I've found helpful once you get past the official boost asio overview:
Thinking asynchronously - designing applications with asio
Are you ready for ipv6
Why c-0x is the awesomest language for network programming
And
Thinking asynchronously slides
Are you ready for ipv6 slides
Why c-0x is the awesomest language for network programming
slides
The asio documentation, the one available in boost, is minimalist but very precise, each word is significant. That said,I have learned asio (and continue to learn) mainly from SO.
In my opinion, the answer to 'Confused when boost::asio::io_service run method blocks/unblocks' is the very first step, read an read again until you really understand it, second answer is also helpful.
Then I have RSS subscribed to newest SO boost-asio tag question and to these two answerers:
Tanner Sansburry, the author of the answer above, his answers are always very precise, comprehensive, with references, even beautiful schemas. RSS feed
Sehe (sorry Sehe, only 2nd). RSS feed
With all that material, you will soon be an asio expert !
I was quite curious about that, too but this page gave me some head start. It's in French, but you could use google translate which is pretty readable (I had to follow down this path myself).
http://gwenael-dunand.developpez.com/tutoriels/cpp/boost/asio/
A little late to the party but there's a book out called "Boost Asio Network Programming" (Packt publishing).
I bought a copy of this, read it over the weekend and then wrote a full on server in C++ without much problem.
Disclaimer: I have nothing to do with the book
I stumbled on the following pdf:
http://boost.cowic.de/rc/pdf/asio_doc.pdf