Watch Out For Recursion in Java 8’s [Primitive]Stream.iterate()

An interesting question by Tagir Valeev on Stack Overflow has recently caught my attention. To keep things short (read the question for details), while the following code works: public static Stream<Long> longs() { return Stream.iterate(1L, i -> 1L + longs().skip(i - 1L) .findFirst() .get()); } longs().limit(5).forEach(System.out::println); printing 1 2 3 4 5 The following, similar … Continue reading Watch Out For Recursion in Java 8’s [Primitive]Stream.iterate()

A Very Peculiar, but Possibly Cunning Kotlin Language Feature

This has caught me by surprise. After studying the Kotlin language to learn about how to best leverage this interesting new language for jOOQ, I stumbled upon this puzzler. What do you think the following program will print? fun main(args: Array) { (1..5).forEach { if (it == 3) return print(it) } print("done") } Well... You … Continue reading A Very Peculiar, but Possibly Cunning Kotlin Language Feature

Fast File System Operations with Xtend, Lambdas, and ThreadPools

Recently, I've blogged about 10 Subtle Best Practices when Coding Java, and I have mentioned that you should start writing SAMs (Single Abstract Method) now, in order to be prepared for Java 8. But there's another language gem out there, which comes in handy every once in a while, and that's Eclipse Xtend. Xtend is a … Continue reading Fast File System Operations with Xtend, Lambdas, and ThreadPools