10 Features I Wish Java Would Steal From the Kotlin Language

This article is overdue. After the hype around the release of Kotlin 1.0 has settled, let's have a serious look at some Kotlin language features that we should have in Java as well. In this article, I'm not going to wish for unicorns. But there are some low hanging fruit (as far as I naively … Continue reading 10 Features I Wish Java Would Steal From the Kotlin Language

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()

Time for some Funky SQL: Prefix Sum Calculation

This Stack Overflow question has yet again nerd-sniped me [finding the] maximum element in the array that would result from performing all M operations Here's the question by John that was looking for a Java solution: With an array of N elements which are initialized to 0. we are given a sequence of M operations … Continue reading Time for some Funky SQL: Prefix Sum Calculation

Improve Your JUnit Experience with this Annotation

JUnit is probably part of 90% of all Java projects. And the exciting thing is, we'll soon have JUnit 5 with Java 8 support. We've blogged about an improvement recently. Back in JUnit 4 land, there's this little trick that I can only recommend you put in all of your unit tests. Just add this … Continue reading Improve Your JUnit Experience with this Annotation

10 Easy Steps to a Complete Understanding of SQL

Too many programmers think SQL is a bit of a beast. It is one of the few declarative languages out there, and as such, behaves in an entirely different way from imperative, object-oriented, or even functional languages (although, some say that SQL is also somewhat functional). As a SQL trainer (do visit our training, it's … Continue reading 10 Easy Steps to a Complete Understanding of SQL

Ceylon Might Just be the Only (JVM) Language that Got Nulls Right

Here we go again. THAT TOPIC. But hang on. The approach discussed here (and in the Ceylon language) is not something you see every day. At the same time, it is very cunning. Nulls are baked into the language ... or so it may seem. Indeed, in Ceylon, like in Kotlin (and possibly many other … Continue reading Ceylon Might Just be the Only (JVM) Language that Got Nulls Right

Java 10’s new Local-Variable Type Inference

News could hardly get more exciting than this, for a programming language aficionado! There is now a JEP 286 for Local-Variable Type Inference with status "Candidate". And a request for feedback by Brian Goetz, which I would love to invite you to participate in: http://mail.openjdk.java.net/pipermail/platform-jep-discuss/2016-March/000037.html Please do so, the survey remains open only from March … Continue reading Java 10’s new Local-Variable Type Inference

SQL JOIN or EXISTS? Chances Are, You’re Doing it Wrong

I've noticed this very consistently with a lot of customers, and also with participants of our Data Geekery SQL Workshop (which I highly recommend to everyone, if you excuse the advertising): A lot of developers get the distinction between JOIN and SEMI-JOIN wrong. Let me explain... What are JOIN and SEMI-JOIN A little bit of … Continue reading SQL JOIN or EXISTS? Chances Are, You’re Doing it Wrong

UI Developers! Choose Sensible Default Ordering!

Good decisions come from experience. Experience comes from making bad decisions. ― Mark Twain Today, let's look at one piece of experience and how we can turn that into good decisions when implementing UI logic. Please, all UI developers read this. The bad decision When UI developers display tabular data, it is very common for … Continue reading UI Developers! Choose Sensible Default Ordering!

How to Support Java 6, 8, 9 in a Single API

With jOOQ 3.7, we have finally added formal support for Java 8 features. This opened the door to a lot of nice improvements, such as: Creating result streams try (Stream<Record2<String, String>> stream = DSL.using(configuration) .select(FIRST_NAME, LAST_NAME) .from(PERSON) .stream()) { List<String> people = stream.map(p -> p.value1() + " " + p.value2()) .collect(Collectors.toList()); } Calling statements asynchronously … Continue reading How to Support Java 6, 8, 9 in a Single API