My experience of returning to Java

Posted by    |       Ceylon

So my recent return to writing code in Java has been interesting. Most of my Java programming experience has been in web apps, where there is a lot of UI/declarative code, and state-holding classes, or in framework development where I need a lot of interception and reflective code, and in those domains I have often found that Java gets in the way. But now I'm writing a compiler (well, a type checker/analyzer to be precise), and I don't have much use for declarative code, interception, or reflection. And there is a lot more code that does stuff rather than represents state or data. Java is honestly a quite different experience in this domain. My overall reaction is that Java is simply very reasonable and non-annoying for this kind of work. It just doesn't get in my way much. And in an IDE like Eclipse, Java's static typing saves me enormous gobs of time.

Nevertheless, there are definitely some moments where I find myself wishing I had Ceylon already. Here are the things I really miss:

  • Typesafe null. One of the things about a compiler is that it needs to be able to accept input that is partly rubbish and partly meaningful and just keep going and do the best it can with what it has. That means that there are a lot of null checks in my code, and, frankly, catching all the places an NPE could occur is very tough work. I wish the compiler would help me here.
  • Algebraic types. There's lots of instanceof in my code. Indeed, the whole thing is a bunch of tree Visitors. Algebraic types, typesafe narrowing, and built-in support for the visitor pattern would help enormously.
  • Mixin inheritance. The metamodel classes which represent Ceylon types would turn out much cleaner if I had concrete methods on interfaces. As it is, I'm stuck with some code duplication.

These are the three things I really miss. Sure, there are other bits of Java that I don't love, but for now they're just not bothering me much.

Back to top