Why Developers Should Pay Attention to ZIO in 2021

A growing number of companies try to adopt functional programming or some elements of this programming paradigm, so they can take what’s best from both worlds (functional & object-oriented programming). But, this mindset of people is slowly changing even more now, with the introduction of ZIO. We already know the cases of companies big like Apple, DHL, and Wix.com, and small adopting ZIO in their production apps. So, how is this change coming? Let’s explore it in more detail.

  1. What is ZIO?
  2. Is ZIO production ready?
  3. What’s in ZIO for programmers and the business?
  4. What companies are using ZIO, and how? 
  5. How can I contribute?

What is ZIO?

ZIO is a purely functional, type-safe, and composable library for asynchronous, concurrent programming in Scala. ZIO is ideal for mid to large-scale projects that require a lot of concurrency and speed. 

It was developed to solve complex, modern business problems using simple, testable, and composable code. Powered by highly-scalable, non-blocking fibers that never waste or leak resources, ZIO supports you in developing highly scalable, resilient, and reactive applications.

Is ZIO production ready?

After 3 years, 316 contributors working long hours and many deployments, ZIO 1.0 was released on August 4, 2020. It seems fresh, but we can’t even tell you how game-changing it can be for a project. But is it production-ready? 

Client approved

Instead of telling you straight away about all the benefits and novelties and listing all the companies using ZIO, first, we want you to see for yourself how the CEO of  Fugo.ai and our client, Zuka Kakabadze – answers questions about using ZIO in production.

Fugo is easy digital signage software. It allows users to publish content on their screens and monitor the screens and measure the content’s effectiveness based on face recognition. It was a great challenge to build it together with Fugo from scratch, mainly because it allowed us to use future technologies like ZIO. 

In the above video, Zuka Kakabadze mentions that ZIO

Gives the ability to break down the problem to smaller problems, and then solve them individually. The beauty comes when you start composing those solutions into a new solution. The composition and abstraction gives you the ability to reuse code across your codebase and team members. That’s when you get efficiency and speed. It results in building higher quality software. It’s not only you are building quicker; you build high-quality software as well.

So that’s what the client experience says about ZIO. Now let’s move on to developers and companies they represent. 

How are companies all around the world using ZIO? 

The programmers’ community buzz is on. Hello ZIO!

At the Scale BY The Bay 2020 Conference, we had the opportunity to not only be sponsors and speakers but observe the rise of ZIO with our own ears and eyes. There were quite a few presentations about ZIO from top brands like Apple or Collective Health. Developers use ZIO with microservices and machine learning projects, and that’s just the top of the mountain. Let’s see some examples. 

Increasing type safety and allowing coordination of state changes across multiple actors

Actors are a cornerstone of modern concurrent and distributed systems, propelling Erlang and Scala to early success. Exposing a model that doesn’t require locks and which doesn’t block threads, actors have helped developers build software without worrying about deadlocks, thread management, and other modern software development woes. In this presentation, Salar Rahmanian, Software Engineer at  Collective Health, gave a great introduction to actors, Akka, zio-actors and showed how modern functional effect systems like ZIO allow a reimagining of the actor paradigm in ways that increases type safety, enables coordination of state changes across multiple actors, and still preserves the benefits that brought developers to the actor paradigm.

ZIO based execution engine

In his talk, ‘A tour of String diagrams and Monoidal categories,Juan Pablo Romero,

Software Engineer from Apple described what String diagrams are, how they relate to Monoidal categories and present a Scala declarative DSL inspired by such concepts. He showcased two interpreters –  a GraphViz based renderer and a ZIO based execution engine.

Enhancing Spark’s Power with ZIO

Combining ZIO/Future with Spark can drastically speed up your ML projects’ performance, as data sources can be fetched in parallel without holding up computation. ZIO is much better than the Future, but it can be challenging to set up. Leo Benkel, Data Engineer, showed some benchmark results and explained how his open-source library handles all boilerplate issues to implement Spark and ZIO in Machine Learning projects quickly.

Microservices – from Kafka to ZIO

Let’s start by saying that Wix.com has 1500 microservices in Scala – and they moved all of them from Kafka to ZIO. 

Kafka is the bedrock of Wix’s distributed microservices’ system. In the last 5 years, we have learned a lot about successfully scaling our event-driven architecture to roughly 1500 microservices, mostly written in Scala. We’ve managed to achieve higher decoupling and independence for our various services and dev teams with very different use-cases while maintaining a single uniform infrastructure in place. Our Kafka infrastructure is called Greyhound and was recently wholly re-written using ZIO. 

Natan Silnitsky, Backend Infrastructure Developer Wix.com

In his blog post on Medium, he also mentioned that he loves coding with ZIO, especially when it comes to concurrent/asynchronous programming.

From my experience, it is a real joy to write code with ZIO, especially in cases where you have complex concurrent/async requirements, which are much simpler to implement with the features this library provides.

In one of his posts, he also mentioned one of ZIO’s most significant benefits –  lowering the entry barrier for functional programming. 

But until ZIO entered the scene, the entry barrier felt too daunting (i.e., tagless final with all those boiler plate LoC just to get some custom composable effects to work with).

ZIO definitely looks much more straight forward than tagless final, including easy interop with Future, Try, and Option, simplified dependency on external resources, and better tracing capabilities 

Analyst productivity improvement & Real-time Event Stream Pattern Matching for DHL

Analyst productivity improvement

Ziverge is a software development company run by John De Goes. Their client DHL  needed a platform for running streaming analytics on event streams coming from a diverse set of sources. The requirement was for analysts to specify queries using a mixture of SQL and domain-specific constructs. For this platform, Ziverge chose a combination of Flink for SQL-based stream processing and ZIO Streams for the required integrations with data sources. The platform is used day-to-day intensively by several groups of analysts, resulting in massive productivity gains through the use of the familiar SQL language and the resilience of ZIO Streams as the integration technology.

Real-time Event Stream PatternPatter

The second project that ZiIverge developed for DHL  resulted in a dramatic reduction in infrastructure costs.

DHL suffered from performance degradation on a legacy Python application, written to match patterns against high-throughput Kafka-based event streams. The application was rewritten in Scala using a combination of Kafka Streams and ZIO Streams components, achieving 5x per-core performance improvements compared to the previous implementation. These improvements translated directly to a reduction in infrastructure costs.

And what does DHL as a client think about ZIO?

Last year, we started using ZIO as a superior alternative to tagless-final and Monad transformers. ZIO is a powerful monad with many combinators, interop with essential libraries, and new integrations with OpenTracing and logging. ZIO lets us focus on our business logic, making it easier to understand and test. There is no doubt ZIO will be one of the significant parts of Scala infrastructure over the coming years!

Jan de Groot, DHL Parcel Netherlands – Head Of Development

What’s in ZIO for programmers and the business?

Why is ZIO so good for business?

  • ZIO’s high-performing scalable applications mean much better performance.
  • Its resource-safe apps never leak resources, including threads, even when they fail.
  • The full power of ZIO’s type-safe Scala compiler can catch bugs at compile time.
  • ZIO’s test services are injected into apps, making for fast, deterministic, and type-safe testing.
  • ZIO’s concurrency means apps without deadlocks, race conditions, or complexity.
  • Its resilience means apps that respond to failures locally and flexibly and never lose errors.
  • ZIO’s sequential code looks the same whether asynchronous or synchronous
  • Its functional, simple building blocks provide rapid solutions to complex problems.
ZIO Functional Scala Developers

Why is ZIO good for developers? 

  • Purely-functional design.

ZIO allows a developer to build highly composable applications from small building blocks, thanks to its purely-functional design.

  • Easy to start working with.

ZIO is excellent for introducing developers to functional programming in Scala, without the need to learn a lot of jargon and hard-to-understand concepts that are typical of other libraries like cats or Scalaz.

  • Catch bugs at compile time.

Thanks to ZIO’s type safety, a developer can use the Scala compiler’s power to catch bugs at compile time. This is great because you don’t have to wait for an application to run in production to see weird bugs. After all, if your application is incorrect, it just won’t compile. Something important to notice here is that type safety is a feature of Scala itself and not exclusive to ZIO, but ZIO uses the type system’s full power. You can see at the type level if a program can fail or succeed, or if it can’t fail, or if it can’t succeed, or if it never ends. You don’t have that ability in other libraries like cats-effect or Monix.

  • Write unit tests easier.

ZIO makes applications more testable, so it’s a lot easier to write unit tests.

  • Refactoring that you can like. 
  • Refactoring ZIO code is a delight; you don’t have to worry about changing your program’s behavior while you do it.
  • Build highly concurrent applications. 
  • Last but not least – functional programming is in demand!

How can I contribute?

Now is an excellent time to get involved in the ZIO community! If you’re a ZIO rookie, read the How to page to get started. 

There are two basic ways you can help ZIO evolve:

  • Participate in the development of  ZIO.

The ZIO community welcomes contributors, including first-timers. It has already benefited from developers from all over the world who committed their code on GitHub. For guidance and knowledge exchange, there is an active Discord Channel. There are many ways to help that don’t require years of experience, so don’t hesitate – just try. 

If you are already a ZIO contributor… high five, and welcome to the club! 🙌🏻 


As a matter of fact, Scalac has recently made the partnership with Ziverge official, and the primary goal of our collaboration is to support Scala and ZIO in their development because we believe that functional programming is what next-generation apps look like. We also want to give every company that uses these technologies to succeed and hit the ground running!

So if you need mentoring, training, or just want to talk ZIO (no strings attached!), then you’re in the right place. Drop us a line at zio@scalac.io or use our on-page chat to let us know we’ve got a ZIO lover on the other side. 👇🏻

  • Give feedback.

Tell us if something blocks you or if something is missing that would make ZIO perfect for your project.

Thank you for reading!

If you’d like to get updates on our experiences with ZIO, follow us on Twitter. You can also find our previous blog posts about ZIO on our blog, the talks we gave at conferences, and open-source projects we’re involved in

If anything is unclear, or you have some questions, please comment down below.

 
Sources

  1. https://zio.dev/
  2. https://ziverge.com/blog/zio-1.0
  3. https://ziverge.com/portfolio/
  4. https://scalebythebay2020.sched.com/event/e54O/acting-lessons-for-scala-engineers-with-akka-and-zio?iframe=no&w=100%&sidebar=yes&bg=no
  5. https://scalebythebay2020.sched.com/event/e55b/enhancing-sparks-power-with-zio?iframe=no&w=100%&sidebar=yes&bg=no
  6. https://scalebythebay2020.sched.com/event/e54v/a-tour-of-string-diagrams-and-monoidal-categories?iframe=no&w=100%&sidebar=yes&bg=no
  7. https://medium.com/wix-engineering/5-tips-for-writing-great-client-libraries-f6d02d57fdcc
  8. https://medium.com/wix-engineering/5-lessons-learned-from-my-continuing-awesome-journey-with-zio-66319d12ed7c
  9. https://medium.com/wix-engineering/5-pitfalls-to-avoid-when-starting-to-work-with-zio-adefdc7d2d5c
    Flink-based Analyst Workbench
  10. https://medium.com/wix-engineering/5-more-pitfalls-to-avoid-when-starting-to-work-with-zio-d0cdd44fa439

Author

Daria Karasek

Marketing Hero at Scalac. I strongly believe in creating opportunities rather than waiting for them to come. As befits Scalac team member I'm a hard worker, I always try to do the right thing and have a lot of fun! I'm an awesome friend and content writer, in that order. When I'm out of the office, I love to cook delicious Italian food and play board games with my friends. #boardgamegeek

Latest Blogposts

24.02.2021 / By Daria Karasek

Technical debt: the nuts and bolts

Today, we’re going to cover this topic in detail, highlighting the challenges and characteristics of technical debt for each and every company.

23.02.2021 / By Jesus Aguilar

What is Apache Kafka, and what are Kafka use cases?

Apache Kafka is the most popular event streaming platform, used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications

16.02.2021 / By Emanuel Oliveira

Scala 3 / Dotty – Facts and Opinions. What do we expect?

Scala 3 is the new major version of the Scala programming language. In this article we’ll highlight some of the changes that we think are of great value for day-to-day Scala programmers. We’ll also talk about the migration process and binary compatibility. Finally, we will conclude with our opinion on this new version.

Need a successful project?

Estimate project