Server as a function with Kotlin – http4k

Server as a function with Kotlin – http4k

Functional Programming, Java, Kotlin, Software Development, Tutorial, Web
Server as a function with Kotlin - http4k Have you ever heard about the concept of "Server as a Function"? The idea is that we write our server application based on just ordinary functions, which is based on a concept outlined in the paper Your Server as a Function written and published by Twitter/Marius Eriksen. In the Kotlin world, the most prominent implementation of this concept is http4k, which the maintainers describe as an "HTTP toolset written in Kotlin with a focus on creating simple, testable APIs". The best part about it is that http4k applications are just Kotlin functions that we can test straightforwardly. Take a look at this first example: First http4k server example val app: HttpHandler = { request: Request -> Response(OK).body(request.body) } val server = app.asServer(SunHttp(8000)).start()…
Read More
Coping with Kotlin’s Scope Functions: let, run, also, apply, with

Coping with Kotlin’s Scope Functions: let, run, also, apply, with

Functional Programming, Kotlin, Software Development
Coping with Kotlin's Scope Functions Functions in Kotlin are very important and it's much fun() to use them. One special collection of relevant functions can be described as "scope functions" and they are part of the Kotlin standard library: let, run, also, apply and with. You probably already heard about them and it's also likely that you even used some of them yet. Most people tend to have problems distinguishing all those functions, which is not very remarkable in view of the fact that their names may be a bit confusing. This post intends to demonstrate the differences between the available scope functions and also wants to discuss relevant use cases. Finally, an example will show how to apply scope functions and how they help to structure Kotlin code in…
Read More
Kotlin Features I miss most in Java – Kotlin vs Java

Kotlin Features I miss most in Java – Kotlin vs Java

Functional Programming, Java, Kotlin, Software Development
PLEASE find an updated version of this on my Medium: https://medium.com/@s1m0nw1/the-7-features-i-miss-most-when-going-back-to-java-after-spending-time-with-kotlin-2b3a35e0b13f. Let's write an article that covers "Kotlin vs Java" topics - I want to tell you which Kotlin features I miss most when going back to Java. My Life as a Java Dev Although I'm a big supporter of the Kotlin programming language, I still do a lot of Java programming on a daily basis for my employer. Since I'm aware of the great functionalities of Kotlin, I'm often struggling with Java as it has some "pitfalls", requires additional boilerplate and misses many features. In this post, I'd like to describe which Kotlin features I miss most when coding in Java. new and Semicolon Ever since I'm doing Kotlin, there are two things I always forget when coding in…
Read More
Spring WebFlux with Kotlin – Reactive Web

Spring WebFlux with Kotlin – Reactive Web

Functional Programming, Kotlin, Software Development, Spring
Spring 5.0 - even fancier In this article I will show how Spring and Kotlin can be used together. If you’re not familiar with my recent articles, have a look at the other Kotlin related posts here. Besides Kotlin, I’ve always been interested in working with Spring ever since I started with Java back in 2011. I still like the framework although it’s getting bigger and bigger and you often don’t quite know which feature to choose amongst all the alternatives. As the framework itself is growing, the documentation, which is one of best you’ll ever get to see, also is. The thing I like most about Spring is that you can focus on your business logic from day one and don’t have much technical, infrastructural stuff to set up before…
Read More
Kotlin Operator Overloading – Working by Convention

Kotlin Operator Overloading – Working by Convention

Functional Programming, Kotlin, Software Development, Tutorial
Kotlin Operator Overloading and Conventions Introduction Kotlin supports a technique called conventions, everyone should be familiar with. For example, if you define a special method plus in your class, you can use the + operator by convention: Kotlin Operator Overloading. In this article, I want to show you which conventions you can use and I will also provide a few Kotlin code examples that demonstrate the concepts. (more…)
Read More