Kevin Peterson
Kevin Peterson

Pattern matching in Java with the Visitor pattern

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 […]

February 11, 2015
Kevin Peterson
Kevin Peterson

I can haz lambda on Java 7?

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 […]

April 29, 2013

Ian Atha

Expressive Java & Fluent Interfaces

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 […]

December 15, 2010

Adam Rosien

Computation: “There is no try”

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 […]

November 09, 2010
Kevin Peterson
Kevin Peterson

Elsewhere: Next Generation Java Programming Style

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 […]

July 21, 2010

Vlad Patryshev

A Better Option for Java

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 […]

May 04, 2010