Stream.forEach() overuse

Starting with Java 8, Java programmers can enjoy the merrits of functional programming thanks to lambdas, java.util.function.* and the stream API. This is great, and allows to improve readability. For example, conversions of lists can be written in a relatively succint way: List<String> hosts =; That is much nicer and easier (or at least faster) to read than this: List<String> hosts = new ArrayList<>(urls.size()); for (final URL url : urls) { hosts. »

Reversing a Linked List

Linked lists are an important data structure and also a popular source of interview questions. Few programmers will actually have to do a fully fledged linked list since most programming languages come with an implementation of it (usually of doubly linked lists). Nonetheless, understanding linked lists and other data structure will help you better understand runtime consequences of choosing one data structure over another. Reversing a linked list is a common task. »

Functional Java

With Java 8 the language got lambdas. This is a huge step towards allowing functional programming in Java and hence brings a fresh breeze. The language designers did not stop by simply providing lambdas but also extended the runtime API significantly to support lambdas and functional programming. What are lambdas? The Java Documentation for Lambda expressions gives a rather dry definition: “Lambda expressions let you express instances of single-method classes more compactly. »

duckprxy with javasist

I just released version 0.2 of duckprxy. It now comes with a duck proxy implementation that uses Javassist: JavassistDuckPrxy. Proxies created with JavassistDuckPrxy are not using runtime reflection, but dynamically created code that is compiled to byte code by Javassist. This should reduce the overhead to that of normal delegation, hence, very little. I did not do any performance tests yet, though. »

Duck Typing for Java

Every now and then I need to implement some interface, but only one (or very few) methods of it. Usually I need something like this in test code, but it is useful elsewhere, too. The mocking libraries I have seen so far offer something similar, but not quite in the way I want to have it. I had the idea to use something like duck typing for it for a while now. »

The Visitor Pattern in Differen Languages

In this post I want to explore the usage of the visitor pattern in different programming languages. The goal is always to represent expression trees, i.e., to have the abstract syntax tree (AST) of an algebraic expression like 2 * 5 - 3. Let us start with a simple implementation in Java: import java.util.HashMap; import java.util.Map; public class ExpressionTree { public static interface Operator { int eval(int ... args); } public static Map&lt;String, Operator&gt; OPERATOR_MAP = new HashMap&lt;String, Operator&gt;(); static { OPERATOR_MAP. »