Coming from a Java background, reflection to me was a useful, albeit highly advanced tool in daily work.
Being mostly used in libraries and frameworks, understanding its possibilities and usages was usually enough for me.
While advancing my career and moving to the scala ecosystem I learned about the existence of macros as a kind of compile-time reflection, used mostly by libraries.
Still, it being a highly advanced language feature and not very ergonomic for daily programming, I felt more comfortable in the regular code world.
Then, during the development of a certain feature for the client I was working at, I felt the code I had written was so much boilerplate, there should be a way to shorten what I’ve written (unfortunately I cannot remember exactly what that was about, but it definitely had to do with some kind of mapping between data and their corresponding case classes…).
In Java I would have tried my hand at reflection to extract and generate POJO’s, which could be done in scala as well, but I’ve always felt reflection isn’t the right tool for custom written production code, it being a slow, purely runtime process, which is never optimized by the compiler.
I asked a senior colleague if using a macro to extract the field names and values would be a way to solve this, since it would bring me some compile-time safety.
He then introduced me to the shapeless library, and the rabbit-hole opened up.
Continue reading →
I’ve made my share of mistakes using Git. This is an easy trick I learned that saved my butt when I would otherwise have lost a bunch of progress after an incorrect Git action.
Continue reading →
Preferable you start a ZIO application with just one runtime.unsafeRun
.
But when you’re migrating an old application to ZIO, you likely have multiple places to do runtime.unsafeRun
.
We will investigate how to deal with the environment (layers).
Continue reading →
Breadcrumb navigation, known to some as cookie crumb navigation or navigational path to others, where a path like structure is displayed, most commonly at the top of the current page, that typically shows you the path of pages that you as the user took to get to the page where you are now is a well known staple of many websites. And, when implemented properly, is a very helpful feature on many websites. But for every good implementation there is a bad one, and all the bad ones are there usually due to an age old mistake: trying to fix a problem by addressing the symptoms instead of solving the actual underlying problem. A problem that should not have been here in the first place. A problem that even the good implementations usually fail to address which in turn has created a much larger problem.
Continue reading →
Let me start off with saying I love functional programming.
Although.. A better way of saying it would be I love what functional programming brings me.
It reduces complexity, the code is nice and explicit and it eliminates certain bugs from occurring.
But there are a few things that I wanted to discuss regarding functional programming.
Continue reading →
There are a lot of how-tos on how to use OpenAPI to document the REST APIs of a Quarkus microservice.
However, none of them show you how to document the schema of your API response.
In this blog post I’ll show you two ways to add schema documentation to your OpenAPI spec.
Continue reading →
In this blog post, I want to clear up some fuzziness that seems to surround Reactive Streams.
It is all too easy to defeat the goals that can be achieved with Reactive Streams, especially where the application is part of an environment with both synchronous and asynchronous inputs and outputs.
Continue reading →
We’ll look at some examples of different kinds of exceptions and how we can deal with them in ZIO.
Continue reading →