Home > Java, scala > Code bloat and its inevitability in Java

Code bloat and its inevitability in Java


[I]f you begin with the assumption that you need to shrink your code base, you will eventually be forced to conclude that you cannot continue to use Java. Conversely, if you begin with the assumption that you must use Java, then you will eventually be forced to conclude that you will have millions of lines of code.

Steve Yegge has an excellent rant on code bloat and its inevitability when using Java.  He makes some very cogent points about refactoring and design patterns, using the metaphor of spring cleaning.  Refactoring and design patterns can be seen as neatly organizing your stuff within compartments in a closet, but if you aren’t able to throw things out, you never will really have a clean code base.  Furthermore, he argues that Java necessitates code bloat and duplication, as it lacks certain features that are necessary to really shrink code bases (lambda functions, closures).

He concludes his article by considering some alternative languages that run on the JVM; it’s an older article (from 2007) and he choose Rhino as his language of choice to rewrite his game in (currently 500 thousand lines of Java code).  I’d be interested to see if he were to revisit this article if he would choose Scala instead. It seems to be a natural fit for what he’s trying to do; it runs in the JVM but adds functional programming features that would surely reduce his source code line count. In the comments many people suggested Scala, but he dismisses them by saying

“Scala folks and Groovy folks: you’re not big enough yet. For something as big as my game, I want a proven mainstream language. I picked Rhino as a complicated multidimensional compromise; the actual reasons are a full blog post. But the short answer is “you’re not big enough.” Sorry.

Given Scala’s somewhat more mainstream position these days, I think he’d be forced to reconsider.

This article hits home for me, because the verbosity of Java is a thing I struggle with on a daily basis; it is definitely one of my biggest complaints about the language, and it makes it a breath of fresh air to use something more expressive and concise, like Python.

Categories: Java, scala Tags: , ,
  1. Andrew
    April 28, 2010 at 12:36 pm

    wooo! Python!

  2. November 28, 2012 at 7:04 am

    Exactly. I’ve been studying Java and Python on my free time and I have come to the same conclusion as you: Python is far much concise than Java. The (really) long.Java.statements can be a turnoff to a noob like me. In fact, C looks less verbose than Java :-). BTW, I’m an intermediate PHP developer. Off to study some Python.

  3. Andrew
    February 6, 2014 at 11:07 pm

    Try Xtend by Eclipse. This is Java on steroids, bloatless, easy to learn and very fast.

    • i82much
      February 16, 2014 at 12:25 pm

      Thanks for the link – I’ll check it out. I’m usually hesitant to add additional layers of complexity (in this case another language on top of Java).

  1. April 30, 2012 at 8:36 am

Leave a comment