What is ZIO and how does it compare to Cats Effect?
Answer
ZIO (Zero-Dependency Input/Output) is a functional effects library for Scala. The core type is ZIO[R, E, A] — an effect requiring environment R, failing with E, succeeding with A. Advantages: built-in dependency injection via ZLayer, typed error channel (not just Throwable), structured concurrency with Fiber, comprehensive standard library (Streams, Queue, Ref, STM). Cats Effect: uses IO[A] with untyped errors, more modular (separate libraries for streams, queues), wider ecosystem adoption. Comparison: ZIO is more batteries-included; Cats Effect is more composable with the broader ecosystem (fs2, http4s). Both support fiber-based structured concurrency with millions of lightweight fibers. ZIO's typed error channel allows exhaustive error handling at compile time — a significant advantage for domain modeling. Most new Scala functional projects choose one or the other as their effect system foundation.
Previous
What are Scala macros and when are they used?
Next
What is FS2 (Functional Streams for Scala)?