• After a long long time… Immutability also Empowers Type Safety. There are many reasons to use immutable data structures and you may have heard many of them. For example, immutable data is safe to be shared across multiple threads etc. Apart from all of these awesome benefits, immutability helps us to employ better type systems.…


  • Recently, a colleague of mine and I gave a presentation in Lambda Days conference about CRDTs. Its video has just been released, so I decided to dedicate a blog post to it: And here is another version of our talk which has been presented on Curry On conference: And yet another version presented on StrangeLoop by my friend Dmitry…


  • Scala provides different language constructs by which a wide variety of DSLs can be made. Implicits, operators as name of functions, macros, higher order functions etc. are examples of those constructs. However, building a DSL is not a trivial task especially when performance matters. In this blog post, I am going to talk about a…


  • To start, let’s take a look at the following code: process function is just a chain of transformations on the given Traversable. Each of these transformations will create an intermediate traversable to be passed to the next transformation function. Given xs = Array(1, 2, 5), the manual tracing output would be: 1 is increased by…


  • Scala Futures do not support built-in timeout unless you block on the future using scala.concurrent.Await as follows: The above code will timeout: java.util.concurrent.TimeoutException: Futures timed out after [1 second] at scala.concurrent.impl.Promise$DefaultPromise.ready(Promise.scala:219) at scala.concurrent.impl.Promise$DefaultPromise.result(Promise.scala:223) at scala.concurrent.Await$anonfun$result$1.apply(package.scala:107) at scala.concurrent.BlockContext$DefaultBlockContext$.blockOn(BlockContext.scala:53) … Sometimes non-blocking external libraries are providing futures as their functions return type but you cannot provide any…