vlingo/actors

The type-safe Actor Model toolkit for reactive concurrency, scalability, and resiliency using Java and other JVM languages, serving as the foundation for the message-driven platform.

And now, a conversation with one of the vlingo/actors:

Tell me about yourself.

I am a unit of computation. I am lightweight. I have my own mailbox and I actually respond to messages I receive there (unlike that “special someone” you keep texting 😉). I play well with other actors and I know how to work in a system.

What is your background?

Well, I can’t deny I came from object-oriented programming. I take my heritage seriously. I have heard it said before that “when you think of the Actor Model, think of objects done right”. As you know the vlingo/PLATFORM is built on an Actor Model implementation.

What is your communication style?

I deal with messages all the time. I have my own mailbox! In fact, asynchronous messages are my specialty. 😎

So you get a message, now what?

I am glad you asked! I can do three things. I can send messages to another actor, create another actor, or designate the behavior to be used for the next message I receive.

Wow, sounds powerful. But how do you designate the behavior?

Well, I have my own private state. This enables me to change my behavior, if needed, based on my current state. When I receive my next message I am poised to handle it correctly. Simple!

Simple, but powerful! 😮

Totally! I can create other actors, not just one, but thousands, even millions if you like. And you know what is really cool? We are all lightweight. Compared to the overhead of using threads directly, we require miniscule resources. Just sayin’.

Sounds like you work well in a system. How do you operate so successfully?

I don’t share memory and that’s a good thing. Let me tell you why. Because I don’t share memory and receive only one message at a time I can safely react to the message. Focus people, focus! No distraction here. When I receive a message, I give it my full attention.

Why is it you claim that you use less resources than threads?

An individual thread uses a lot of system resources. When you create thousands of them, the threads will bog down because there are too many system resources in use. Have you experienced that? Of course you have! On the other hand, I and my other actor colleagues share a limited number of threads that are appropriately tuned for the number of cores of the computer on which we are running.

Amazing! So if you free up CPU cores…

You got it! You get more throughput because your reactive components constantly move forward efficiently with less resources.

I see! So if you are isolated from other Actors, how do I change your state?

By sending me a message. I have my own mailbox, which is similar to a message queue. My mailbox holds my messages until I am ready to process each one.

How do I send a message to your mailbox?

I have my own address. You need my address to send me a message. Likewise, I can send a message to another actor if I have its address. I can reply to your message when you tell me your address. Naturally, I know the address of all of my children. That’s understandable, isn’t it? Want to know something else?

Sure.

I can have more than one address! This enables me to receive messages based on different protocols. That’s just one way that vlingo/actors differs from other actor implementations.

That’s comforting! All of this sounds organized. I take it you like messages.

I love communicating via messages. Don’t you? I get messages from other actors in my world. I handle them efficiently too in FIFO order. You know, First In First Out.

Is that asynchronous?

Yes, because we are running on threads as they become available. I get so excited when I talk about this! Actors, we are so efficient!! 😍 Remember Carl Hewitt said “One actor is no actors. Actors come in systems.” Thus, your applications should use not just some actors, but many actors. Heads up! Once you start down the road of asynchronous behaviors, you are all in. You don’t kind of use actors. You are either in or out.

Got it! Any more thoughts on messages?

One more thing. A message can be sent to me, the actor through what appears to be a method invocation. Behind the curtain, the actor system turns the method invocation with parameters into an immutable type-safe message and puts it in my mailbox. When a thread becomes available, I handle my next message.

Whoa, sounds techie.

Well, that’s what I am all about—using technology to make computers more efficient and programmers more successful. 💪

Where do you prefer to work, locally or remotely?

I can do both. I can work locally or remotely on another machine. And you know what? Your system won’t know the difference!

What are your supervision skills?

I am a natural at it. I can supervise the other actors I create and I can decide what to do in case of failure. As an added benefit, vlingo/actors supports common supervisors that oversee failures of specific types of actors. This means I can assist in making our world self-healing. I can restart any actors that I supervise or redirect messages to another actor under my supervision. We really empower developers!

Sounds like you have your act together. 😆 But seriously, it can’t all be a bed of roses, surely there is some downside to your way of working?

Does there always have to be a downside? Let’s be frank, my ability to scale easily and my fault tolerance along with the ability to distribute geographically are huge wins. Avoiding a lot of concurrency issues is a major plus. This is guaranteed because we actors do not share state and we process one message at a time, our individual state is safe from race conditions.

Thanks for your time. Where can learn more and keep up with you?

My pleasure! As one of the components on the vlingo/PLATFORM you will find vlingo/actors a powerful, type-safe, implementation of the Actor Model. You can always read more at docs.vlingo.io and follow @vlingo.io But most important, let’s start working together now!

You and the other actors have a job on our project!