A very interesting question was posted to Stack Overflow and reddit just recently about Java generics. Consider the following method: <X extends CharSequence> X getCharSequence() { return (X) "hello"; } While the unsafe cast seems a bit wonky, and you might guess there's something wrong here, you can still go ahead and compile the following … Continue reading The Parameterless Generic Method Antipattern
jOOQ Tuesdays: Ming-Yee Iu Gives Insight into Language Integrated Querying
Welcome to the jOOQ Tuesdays series. In this series, we’ll publish an article on the third Tuesday every other month where we interview someone we find exciting in our industry from a jOOQ perspective. This includes people who work with SQL, Java, Open Source, and a variety of other related topics. We have the pleasure … Continue reading jOOQ Tuesdays: Ming-Yee Iu Gives Insight into Language Integrated Querying
Would We Still Criticise Checked Exceptions, If Java had a Better try-catch Syntax?
In the context of a previous blog post about JUnit 5, Maaartinus, one of our readers, has brought up a very interesting idea: The only problem with try-catch is its verbosity, which is something I can live with (IMHO a lone catch would do better, the implicit try would apply to all preceding code in … Continue reading Would We Still Criticise Checked Exceptions, If Java had a Better try-catch Syntax?
Using jOOQ’s ExecuteListener to Prevent Write Operations on a Connection
Security is important, especially on the data access layer. Most commercial databasese allow for fine-grained privilege control using database access grants. For instance, you would be restricting access from a user to a certain set of tables (or even better: views), via GRANT statements: GRANT SELECT ON table TO user; With this fine-grained access control, … Continue reading Using jOOQ’s ExecuteListener to Prevent Write Operations on a Connection
Using SQL to Calculate the Popularity (on Stack Overflow) of Derby, H2, and HSQLDB
Few people know about this very very awesome feature of the Stack Exchange platform. The Stack Exchange Data Explorer To be found here: http://data.stackexchange.com As you may know, much of the Stack Exchange platform runs on SQL Server (interesting architecture details here: http://stackexchange.com/performance), and the team has had the courtesy of making a lot of … Continue reading Using SQL to Calculate the Popularity (on Stack Overflow) of Derby, H2, and HSQLDB
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
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
