Embracing Your Rows With Slick

This post is a follow-up of my talk “Slick in the field, learning to forget ORM” presented at ScalaDays 2014. The video is available on Parleys and can be watched on the bottom of this page.

At Scala Days I presented the project ActiveSlick which is a thin layer on top of Slick (v.20) providing some abstractions to ease object lifecycle management and the implementation of a type-safe ActiveRecord pattern.

Slick is wonderful piece of code that allows you to build and compose sql queries using plain Scala code. The advantages of that are many, but the most important, in my opinion, is the high re-utilisation of queries by composition and the compile time checking offered by the Scala compiler.

This post is NOT an introduction to Slick, neither was my talk at Scala Days. The goal is to explain how I’ve solved part of the object lifecycle management and my vision about how one should model applications using Slick.

written in
Read on →

Macros: Case Class Related Macros

This is a first blog post about Writing Macros in Scala. This blog post covers two interesting pairs of macros dealing with case classes. The macros of the first pair translate case classes to tuples, and tuples to case classes. The macros of the second pair translate case classes to maps, and maps to case classes.

Remark: The macros presented in this blog can be found elsewhere on the internet. We tried to reuse as much code as possible for both pairs of macros using a Common singleton object. Moreover, we end by adding a bit of extra code of our own as well.

written in
Read on →

Reactive Programming: Schedulers and Workers

This is a third blog post about Reactive Programming in Scala. The first two blog posts, Reactive Programming: Try versus Future resp. Reactive Programming: Notification versus Observable, covered reactive programs resulting in one value resp. many values. This blog post covers schedulers and workers. They are used to transform iterables to observables. As mentioned in Reactive Programming: Notification versus Observable, the transformation from iterables to observables is not as trivial as it looks: at any moment subscribed observers should be able to unsubscribe.

Remark: The types that are used in this blog post exist in the Scala Adaptor for RxJava library. We refer to this library as the RxScala library. In contrast with the previous two blog posts, this blog post deals with only one function: iterable2observable. Moreover, the Observable companion object of the RxScala library already has a from method, having an iterable parameter, that is equivalent to iterable2observable. Dedicating a separate blog post on the definition of iterable2observable is done for didactical reasons only.

written in
Read on →

Reactive Programming: Notification Versus Observable

This is a second of two blog posts about Reactive Programming in Scala. The first blog post about Reactive Programming: Try versus Future covered reactive programs resulting in one value. This second blog post covers reactive programs resulting in many (zero or more) values.

Remark: The types that are used in this blog post exist in the Scala Adaptor for RxJava library. We refer to this library as the RxScala library. In contrast with the previous blog post, this blog post puts less emphasis on how to define computations. It puts more emphasis on how to use computations.

written in
Read on →

Reactive Programming: Try Versus Future

This is a first of two blog posts about Reactive Programming in Scala. The blog post about Functional Programming in Scala introduced pure computations resulting in exactly one value. Reactive programming deals, in a functional way, with two fundamental impure aspects of computations: failure and latency. The first blog post covers reactive programs resulting in one value. The second blog post covers Reactive Programs resulting in many (zero or more) values.

Warning: The types that are used in this blog post exist in the standard Scala library. For didactical reasons this blog post sometimes defines extra types and extra methods for existing types.

written in
Read on →

Functional Programming in Scala

This blog post is the first one of a series of blog posts about Functional Programming in Scala. It is also a teaser for series of blog posts of about Reactive Programming in Scala.

Warning: Functional Programming and Reactive Programming are profound topics. Hopefully, you will be rewarded for your effort to read the blog posts.

written in
Read on →