The Builder pattern provides a way to construct complex objects step by step with a fluent API, where each method call returns the builder itself, allowing for method chaining. Let us play some type gymnastics in Scala to ensure type safety when creating objects via the builder pattern.
A contramap is defined as the converse of the map. I have never been satisfied with the definition. In this post, I will explain the concept in a way that is easy to internalize.
This post provides a concise overview of key symbols used in Scala 2, such as symbols for function types, function literals, import renaming, and more. It serves as a quick reference for Scala developers to understand the functionality and application of these essential symbols.
Recently, someone quizzed me to write a JSON parser. Time was limited. So, I told them I might not be able to write a disciplined parser that builds an AST and creates JSON objects out of it. In the limited time, I could only parse them to create objects directly.
This post explores a functional style implementation in Scala and Java to a famous interview question to find the top k frequent items in an array. Beware the functional implementation may not be encouraged by interviewers because the solution focuses on the what rather than the how.
In the previous post - Why Functional Programming Matters, we explored the design of a high-throughput timed buffered reader in Scala using cats-effect. In this post, we implement the same in Java and see how it looks in comparison to the functional implementation in Scala.
This post explores the similarities between Kotlin and Scala, two modern programming languages. The post highlights key programming constructs, demonstrating how both languages handle basic syntax, variables, conditionals, string interpolation, loops, functions, collections, and classes.
Guest post by Bahul Jain. In this post, he talks about algebraic data types (ADTs) and its benefits. He discusses how ADTs can be used to model complex data and boost developer productivity.
scala-cli, one of the superpowers in the Scala ecosystem, is a versatile tool for running Scala scripts. It has a ton of options to play with. One of the arguments you can pass to scala-cli is to specify the JVM version to run a script under, which is as follows:
scala-cli --jvm 17 my-script.scala
When done so, scala-cli first looks for JDK installed in the system1, if not found, downloads the specified JVM using Coursier. It does not consider the JVM installed via package/version managers like sdkman.
More ...This post takes a more relatable and realistic yet complex problem to demonstrate how it is straightforward and concise to implement it in functional programming. It makes the case why functional programming matters; especially large and/or complex programs.