\section{First Steps}

%\subsection{Why Actors?}

%\subsection{Some Terminology}

To compile \lib, you will need CMake and a C++11 compiler. To get and compile the sources, open a terminal (on Linux or Mac OS X) and type:

\begin{verbatim}
git clone https://github.com/actor-framework/actor-framework
cd actor-framework
./configure
make
make install [as root, optional]
\end{verbatim}

It is recommended to run the unit tests as well:

\begin{verbatim}
make test
\end{verbatim}

Please submit a bug report that includes (a) your compiler version, (b) your OS, and (c) the content of the file \texttt{build/Testing/Temporary/LastTest.log} if an error occurs.

\subsection{Features Overview}

\begin{itemize*}
  \item Lightweight, fast and efficient actor implementations
  \item Network transparent messaging
  \item Error handling based on Erlang's failure model
  \item Pattern matching for messages as internal DSL to ease development
  \item Thread-mapped actors for soft migration of existing applications
  \item Publish/subscribe group communication
\end{itemize*}


\subsection{Supported Compilers}

\begin{itemize*}
  \item GCC $\ge$ 4.8
  \item Clang $\ge$ 3.2
\end{itemize*}

\subsection{Supported Operating Systems}

\begin{itemize*}
\item Linux
\item Mac OS X
\item \textit{Note for MS Windows}:
\lib relies on C++11 features such as unrestricted unions.
We will support this platform as soon as Microsoft's compiler implements all required C++11 features.
In the meantime, \lib can be used with MinGW.
\end{itemize*}

\clearpage
\subsection{Hello World Example}

\begin{lstlisting}
#include <string>
#include <iostream>

#include "caf/all.hpp"

using namespace std;
using namespace caf;

behavior mirror(event_based_actor* self) {
    // return the (initial) actor behavior
    return {
        // a handler for messages containing a single string
        // that replies with a string
        [=](const string& what) -> string {
            // prints "Hello World!" via aout
            // (thread-safe cout wrapper)
            aout(self) << what << endl;
            // terminates this actor
            // ('become' otherwise loops forever)
            self->quit();
            // reply "!dlroW olleH"
            return string(what.rbegin(), what.rend());
        }
    };
}

void hello_world(event_based_actor* self, const actor& buddy) {
    // send "Hello World!" to our buddy ...
    self->sync_send(buddy, "Hello World!").then(
        // ... wait for a response ...
        [=](const string& what) {
            // ... and print it
            aout(self) << what << endl;
        }
    );
}

int main() {
    // create a new actor that calls 'mirror()'
    auto mirror_actor = spawn(mirror);
    // create another actor that calls 'hello_world(mirror_actor)';
    spawn(hello_world, mirror_actor);
    // wait until all other actors we have spawned are done
    await_all_actors_done();
    // run cleanup code before exiting main
    shutdown();
}
\end{lstlisting}
