Categories
Programming

The problem with EitherT

If you’ve used Scala Future in a real application you probably realised that having a failed Future wrapping any Throwable isn’t the most efficient way to handle errors in your application. I used Scala Future in this example but it applies equally to cats effects. Any type like IO[A] suffers the same issue in that […]

Categories
Programming

Streaming patterns with fs2

After an overview of cats-effect which deals with single effect it feels natural to have a look at fs2 and see how multiple effects can be combined into a stream. As we’ve covered some common streaming patterns with Akka stream a while ago it’ll be interesting to see how they compare with each other.

Categories
Programming

Cats-effect, an overview

After many applications written using Scala’s Futures, Akka Actors or Monix,… Cats-effect is now my favourite stack to write Scala programs. Why is that? Well, it makes your code easier to write and reason about while providing good performances.

Categories
Programming

Dealing with errors

As a programmer we don’t really like to deal with errors. We like to focus on the happy path – the one that provides value – and deal with the errors later because … well, we have to do it! However dealing with failures is crucial if we don’t want our program to stop on […]

Categories
Programming

Leveraging the type system to avoid mistakes

We all know we should write tests to make sure our system behaves as it is supposed to. Surely tests are necessary to ensure correctness of our programs but they only depend on what the programmer is willing to test (or can think of testing). What I mean is that there will always be gaps […]

Categories
Programming

Refined types, what are they good for?

Type refinement is all about making the types more precise. But why would do that? Because using the correct types makes your program safer as you reduce the possibility to introduce bugs. First let’s think about types. For instance String is a type we use all the time. A variable of type String can have […]

Categories
Computing Programming

Akka stream interface for gRPC

Back from holidays let’s continue with some of my favourite topics: AkkaStreams and gRPC. We’ve already seen how can take advantage of the ScalaPB code generation tool to generate new interfaces (GRPCMonix) on top of the grpc-java implementation or to create new tools to integrate gRPC with other services (GRPCGateway). Similarly to GRPCMonix which provides […]

Categories
Programming

Introduction to Tagless final

In this previous post we’ve seen that before using Scala’s Future it might be worth taking some time to think of the use cases (especially error cases), the execution model we need, … as it might be more advantageous to choose a solution like Monix’s Task (although not available in standard library) to gain finer […]

Categories
Programming

Scala Futures vs Monix Tasks

In this previous post we saw how Scala Futures work and why they need an implicit ExecutionContext to run their computation. While there is some trick to pass the ExecutionContext, it’s usually cumbersome and clutter the code. So the question really is: Do you need an ExecutionContext everywhere? Well, you do as long as you […]

Categories
Computing Programming

Understanding Scala Futures and Execution Contexts

Viktor Klang recently published a set of useful tips on Scala Futures. While being widespread and heavily used, people (especially newcomers) are still experiencing problems working with Scala Futures. In my opinion many of the problems come from a misunderstanding or misconception on how Futures work. (e.g. the strict nature of Futures and the way […]