Posts for: #Scala

Moving away from a legacy system using Scala and Kafka - Part 1

My team at Canal+ is building a new media asset management (MAM) platform. To put it simply, Mediahub, our platform, stores video files and information regarding these files:

  • Technical information (how many audio channels does this video have? what’s the video’s resolution?)
  • Editorial information (is it a movie? A show? A TV series episode? Who is speaking in the sequence? What about?)
  • Legal information (when can we air this content? When did we acquire this contract?)

On top of storing and exposing tools to manipulate video files and their related metadata, Mediahub allows third parties to send us new content that can be shipped to VOD platforms and TV channels. A built-in workflow orchestration engine takes care of receiving, quality-checking, assembling and shipping footage. The platform can execute hundreds of these workflows concurrently and treats more than 3000 workflows a day.

[Read more]

Working with JSON in Scala, a Circe Crash Course

This tutorial covers Circe, a functional JSON handling library for Scala, part of the Typelevel ecosystem and well integrated with Cats.

The video covers:

  • 00:00 The overall structure of the library
  • 04:43 The Json data type
  • 13:51 Encoders
  • 17:14 Decoders
  • 30:39 Automatic derivation
  • 32:33 Semi-automatic derivation
  • 34:55 Automatic derivation considered harmful and conclusion

A note about the placement of Json codecs and the “automatic derivation considered harmful” part of the video: placing our Encoder[YoutubeVideo] in the companion object of YoutubeVideo would have solved the problem. Since Scala automatically imports implicits from companion objects, we would have never forgotten the import in the first place.

[Read more]

Functional stream processing with Scala, a crash course on fs2

Fs2 is a Scala library for stream processing. This video is an introductory tutorial on fs2, which covers building streams, inifinte streams, effects, and files IO.

We use fs2 to read a very big CSV file (more than 3 GB), parse it, and transform every row to a JSON object, by taking advantage of the file reading and writing abilities of the library. No previous knowledge of fs2 is needed.

[Read more]

Functional error handling with monads, monad transformers and Cats MTL

The way we deal with failure in most OOP applications is itself a common source of unexpected behaviors. I believe exceptions and try/catch statements are overused. Most of the time, it isn’t obvious what a method might throw and when. Edge cases should be treated with the same amount of caution, if not more, than the rest of the code, yet they are rendered invisible by error-handling mechanisms that hide failures instead of highlighting them.

[Read more]

Attending NE Scala 2020, my first online-only conference

Last week I had the opportunity to attend and speak at Northeast Scala Symposium, this is the story of my experience.

The symposium has been gathering Scala enthusiasts for ten years now, and while most of the attendees come from the east-coast of the U.S., it’s usual for European folks to join as well. It’s really three different conferences on three successive days. The first day of talks is the Typelevel Summit, followed by the proper NE Scala lineup, and a day of unconference. My talk was part of the first day. If you’re not familiar with the Scala ecosystem, Typelevel is an organization of volunteers that develop open-source libraries geared toward functional programming. They have set a goal of promoting functional programming through not only through code, but also through great learning material; and they are committed to building a welcoming, inclusive community. The most popular Typelevel project is Cats, a library for functional programming that is also one of the best documented pieces of software I know.

[Read more]

Understanding Type classes in Scala : extending types you don’t own

Type classes are a very common pattern in Scala. My goal in this post is to demystify what they are, how they are useful, and how they are supposed to evolve in the next big iteration of Scala, currently known as Dotty.

Why do we need type classes ?

Type classes are a programming technique that allows you to define common behavior for multiple types. Type classes act as a kind of interface, providing a common way of interacting with multiple types, while each of those type have different concrete implementation for this interface.

[Read more]