# Introducing otavia: Your shiny new IO & Actor programming model!

**URL:** <https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615>\
**Category:** Announce\
**Created:** [November 10, 2023, 3:56pm UTC](https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615 "2023-11-10T15:56:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![yankun1992](https://users.scala-lang.org/user_avatar/users.scala-lang.org/yankun1992/32/2812_2.png) [@yankun1992](https://users.scala-lang.org/u/yankun1992)\
**Post date:** [November 10, 2023, 3:56pm UTC](https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615/1 "2023-11-10T15:56:33Z")

</div>

Hi, here!

> This project is still in the incubation stage, it took me about a year to complete the initial design and I currently have a working prototype. I am eager to receive your ideas, suggestions and even criticisms to improve the design of this project!

[GitHub - otavia-projects/otavia: Your shiny new IO & Actor programming model!](https://github.com/otavia-projects/otavia)

## Introduction

`otavia` is an IO and Actor programming model power by Scala 3, it provides a toolkit to make writing high-performance concurrent programs more easily.

You can get a quick overview of the basic usage and core design of `otavia` in the following documentation:

- [Quick Start](https://github.com/otavia-projects/otavia/blob/main/docs/_docs/quick_start.md)
- [Core Concepts and Design](https://github.com/otavia-projects/otavia/blob/main/docs/_docs/core_concept.md)

More document can be found at [website](https://otavia-projects.github.io/otavia/home.html)

## Features at a Glance

- **Full-Link Asynchronous** ：Everything is asynchronous, no blocking, no thread suspending.
- **Forget Threads, Forget Locks** ：You will no longer be plagued by multithreading problems; everything you write runs in a single thread!
- **Simpler Concurrent** : Actors and Channel let you build systems that scale up, using the resources of a server more efficiently, and out.
- **Resilient by Design** : Building on the principles of The Reactive Manifesto Otavia allows you to write systems that self-heal and stay responsive in the face of failures.
- **High Performance** : build Millions actor instance and send many billion message in seconds.
- **Type Safe** : Message send between actor is type safe in compile time.
- **Zero-Cost Ask-Pattern** : Send ask message and get reply message like call a method, but zero-cost.
- **DI of Actor** : An `ActorSystem` is also seen as a container for `Actor` instances, and developers can type-safely inject dependent `Actor`s at compile time.
- **Powerful IO Stack** : The IO stack is ported from [Netty](https://netty.io), but support AIO and file channel.
- **async/await** : Implement `async/await` syntaxes based on the CPS (Continuation Passing Style)  
using `Scala 3` metaprogramming tools.
- **Simple threading model** : The threading model of the `otavia` runtime is very simple and efficient, allowing you to maximize the utilization of your system’s CPU!
- **Zero-Deps** : The core modules does not depend on any third-party packages.
- **Open Ecosystem** : Otavia provides a module mechanism that allows users to easily use third-party module libraries.

---

<div class="post-metadata">

**Author:** ![bjornregnell](https://users.scala-lang.org/user_avatar/users.scala-lang.org/bjornregnell/32/458_2.png) [@bjornregnell](https://users.scala-lang.org/u/bjornregnell)\
**Post date:** [November 12, 2023, 12:33pm UTC](https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615/2 "2023-11-12T12:33:10Z")

</div>

Interesting! Could you, if relevant, summarize some important similarities and differences between Otavia and Akka/Pekko? I think it would be good to have contrasting info about open source alternatives in the Otavia docs, to help understand the sweet-spot of this lib.

---

<div class="post-metadata">

**Author:** ![yankun1992](https://users.scala-lang.org/user_avatar/users.scala-lang.org/yankun1992/32/2812_2.png) [@yankun1992](https://users.scala-lang.org/u/yankun1992)\
**Post date:** [November 13, 2023, 1:43am UTC](https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615/3 "2023-11-13T01:43:48Z")

</div>

Very good suggestion, next I’ll add a comparison document between otavia and AKKA. AKKA is a great project, while otavia in general focuses more on a lightweight Actor model and a better IO model (ported from Netty).

Since real programming requires us to handle a lot of IO tasks, porting the IO model from Netty allows us to port a lot of application-layer protocol coding and decoding code from the Netty ecosystem. Perhaps this will expand the boundaries of the Actor model even more!

---

<div class="post-metadata">

**Author:** ![yankun1992](https://users.scala-lang.org/user_avatar/users.scala-lang.org/yankun1992/32/2812_2.png) [@yankun1992](https://users.scala-lang.org/u/yankun1992)\
**Post date:** [January 10, 2024, 7:38am UTC](https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615/4 "2024-01-10T07:38:14Z")

</div>

Wellcome to the Discussions of Otavia!

[GitHub - Discussions](https://github.com/otavia-projects/otavia/discussions)

---

<div class="post-metadata">

**Author:** ![yankun1992](https://users.scala-lang.org/user_avatar/users.scala-lang.org/yankun1992/32/2812_2.png) [@yankun1992](https://users.scala-lang.org/u/yankun1992)\
**Post date:** [March 1, 2024, 7:33am UTC](https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615/5 "2024-03-01T07:33:27Z")

</div>

Thank you for your interest in otavia. This is a frequently asked question, so I maintain a thread dedicated to it. You are welcome to participate!

[Discussions - Similarities and Differences between Otavia and Akka/Pekko](https://github.com/otavia-projects/otavia/discussions/2)

---

<div class="post-metadata">

**Author:** ![yankun1992](https://users.scala-lang.org/user_avatar/users.scala-lang.org/yankun1992/32/2812_2.png) [@yankun1992](https://users.scala-lang.org/u/yankun1992)\
**Post date:** [May 20, 2024, 4:18pm UTC](https://users.scala-lang.org/t/introducing-otavia-your-shiny-new-io-actor-programming-model/9615/6 "2024-05-20T16:18:25Z")

</div>

## Design principles of otavia

Object-oriented programming is a very useful programming paradigm, and while the original object-oriented idea was somewhat similar to the Actor model, where an object is equivalent to an Actor, modern implementations of object-oriented in the major programming languages have degraded it to a way of organizing and encapsulating the code, since the cost of calling methods directly is much less than message passing. This is wonderful in the single-threaded case, where everything is organized.

But the crisis came with multithreading and multiple CPU cores: multithreading is like a herd of savage bulls rampaging through a fragile jungle of objects! Instead of having a single path of execution, programs are now controlled by a well-organized set of objects. Instead, you need to care carefully whether each object will be accessed by more than one thread at the same time, and you need to double-check your program’s concurrency safety. But it’s not easy to do. Especially for a software system of enormous size, you don’t know how many threads are rushing through your jungle of objects, so you need to go out and simulate every thread with a human brain, track their paths, and then figure out which objects should need to deal with concurrency safety. Imagine tracking down this herd of savage bulls in the jungle, meticulously checking one by one which grasses they’ve stepped on! God, it’s maddening to think about. All this work was already exhausting, but there was an even more serious problem: these bulls would suddenly come to a standstill when they stepped on certain grass! They are blocked and thus suspended, and this reduces the system’s CPU utilization, which in turn may lead to the launching of more threads, with more and more concurrent contention, until the system crashes under a concurrency problem that is not rigorously examined!

Happily, new technologies have emerged to solve these problems. The most popular technical solutions are coroutine and JVM virtual threads. However, in our opinion, these techniques are effective in alleviating the problem of low CPU utilization due to suspended threads, but they do not alleviate the problem of having to carefully design our objects due to concurrency competition.

The main reason the problem has gotten so bad we believe is that the current mainstream programming languages and object-oriented programming paradigms are missing some of their key features! That is, the lack of organization of concurrency and the lack of organization of execution flow! Concurrency and execution flow are currently coupled with objects, which was not a problem in early single-threaded environments, but becomes very serious in multi-threaded, multi-CPU environments!

Organizing concurrency and execution flow is where the Actor model excels! With the advent of `Scala 3`, we saw the possibility of designing an Actor programming tool that was more in line with object-oriented thinking. So, after a long period of conceptualization, I designed `otavia` and its associated toolkit. The goal is to explore a simpler and safer programming paradigm to meet the current challenges. Also hope to open up a new idea to provide everyone to promote the development of programming tools!

We believe that a better programming hierarchy would look like the following, and the design of `otavia` follows this hierarchy

**System \> Process \> Threads \> Virtual Threads/Stacked coroutines \> `Actor > Objects > Functions`**

In this hierarchical design, the Actor is the end point of concurrency, i.e., the Actor and its subsequent parts should all run single-threaded! Actors communicate with each other by sending messages, and multiple messages are processed one by one in the Actor’s mailbox in a single-threaded fashion.The logic inside the Actor can be either object-oriented or functional, or even a combination of them, as in `Scala`! Now everything is simple again and you can boldly use objects without worrying about that wild herd of bulls!

‘otavia’ is a very interesting project, which is currently in the incubation stage. If you are interested, any contribution from you is warmly welcome! We would also love to hear your suggestions or criticisms about the project. All your comments will ultimately help us to improve the quality of the project! You can also give a like to the project to encourage the contributors to the project! You can also give the project a star to encourage contributors!

- [GitHub - otavia-projects/otavia Your shiny new IO & Actor programming model!](https://github.com/otavia-projects/otavia)
- [GitHub - otavia-projects Ecosystem for otavia project.](https://github.com/otavia-projects)
