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

Not too late to sign up for Odersky’s Scala Coursera class

April 02, 2013

Just a quick note if you haven’t seen it. Martin Odersky is teaching a Coursera class Functional Programming Principles in Scala. On the backend we’ve been experimenting with how we can use Scala more easily in our 99% Java project, and apparently we’ve been talking about it enough that Matt Baker decided this was a… Read more

Relaxing visibilities using Javassist

October 25, 2010

I personally like to restrict the visibility of my classes and members as much as possible. However, package-private classes get quickly annoying when used in an interactive environment such as the Scala interpreter. When we encountered this problem with one of our internal tools, we decided to generate derived versions of our JAR files with… Read more

Wealthfront track at the Silicon Valley Code Camp

October 20, 2010

This year’s Silicon Valley Code Camp was the largest and greatest so far. Like last year, Wealthfront (then kaChing) had few packed presentations. This year we had a full Wealthfront track, focusing on software quality starting with the first line of code through testing to production. As requested, here our our presentations.    A well-typed program… Read more

Creating TypeLiterals in Scala

August 30, 2010

In case anyone wondered, here is how one can easily create instances of Google Guice’s TypeLiteral in Scala. Type literals are used for reifying types. def typeLiteralOf[T](implicit m: scala.reflect.Manifest[T]): TypeLiteral[T] = (m match { case m: ClassManifest[T] if m.typeArguments.isEmpty => TypeLiteral.get(m.erasure) case m: ClassManifest[T] => TypeLiteral.get(new ParameterizedTypeImpl(m.erasure, m.typeArguments.map { case n: ClassManifest[_] => typeLiteralOf(n).getType }.toArray))… Read more