Menu

Pattern matching in Java with the Visitor pattern

February 11, 2015

I once read an essay—I cannot find it now—that talked about how learning a more advanced programming language can improve your coding even in a language that lacks those features because those language features are really ways of thinking, and there’s no reason you cannot think in terms of more powerful abstractions just because you… Read more

I can haz lambda on Java 7?

April 29, 2013

Superficially, lambda expressions in Java 8 are just syntactic sugar for instances anonymous inner classes. Syntactic sugar should not require classfile changes, so one might expect that code compiled with Java 8 lambdas could run on a Java 7 JRE. It turns out that you can’t do this, and not just because of an automatic… Read more

Expressive Java & Fluent Interfaces

December 15, 2010

In this article I briefly explore Wealthfront’s extensive usage of expressive and fluent interfaces in Java such as Kawala, Guice, Mockito, and Guava. To the uninitiated, Java invokes parables of moronic XML, obtuse syntax, and Nile-like constructor calls. As a result, Java’s status as a living language is often questioned and it’s “uncoolness” is dogmatically… Read more

Computation: “There is no try”

November 09, 2010

Often a complex, multi-step calculation requires your code to react to many circumstances. Typically you use exception handling to separate the normal control flow from error handling: Option<BigDecimal> result = Option.none(); try { result = compute(); } catch (WhateverException e) { // Perhaps rethrow. } if (result.isEmpty()) { // Perhaps retry, or set a dummy… Read more

Elsewhere: Next Generation Java Programming Style

July 21, 2010

Vlad sent around a very good article on good Java coding style, which we all liked. Most of the suggestions are exactly what we do here, with a heavy functional influence on our Java code. A sample: Final is your new love: More and more Java developers in the teams I’ve worked with, started to… Read more

A Better Option for Java

May 04, 2010

If you are somewhat familiar with Scala or Haskell, you are probably used to Option[T] or Maybe a, the neat way to pass around “partial values” – values that may be missing. Maybe a in Haskell represents either Nothing or Just x for some x of type a. In Scala Option[T] is either Nothing or… Read more