Hacker News new | ask | show | jobs
by mabbo 2495 days ago
Oh, we also own plenty of those in Java. That's the job- carefully lay the legacy to rest as you replace it with something better.

But at least the Java is overly verbose. It takes a while to read all that code. With the clojure stuff, I'm staring at the same line for just as long and getting no where.

2 comments

I find that I have the opposite problem myself. With Clojure, the code tends to be more declarative and it tells me what it's doing. Meanwhile, Java leaks a lot of implementation details into the code, and I find it much harder to decipher the intent.

For example if I see something like (filter even? numbers) I immediately know what is being done and why. There aren't any surprises there.

Meanwhile, when I see something like:

    List<Integer> acc = new ArrayList<Integer>();
    for (int number : numbers) {
      if (number % 2 == 0) acc.add(number);
    }
then I have to walk through that code in my head to figure out what the intent is, and whether it's actually doing what it's meant to. On top of it I have to worry about mutability. Should a new variable like acc be used, or should the numbers list be updated in place, if it is updated in place where are all the other places that it's used, and are they being affected when I make a change, and so on.

So, there's a lot more to think about even in a completely trivial case such as the example here. In real world code that complexity quickly becomes overwhelming in my experience.

Clojure is not a particularly cryptic or difficult language so maybe a refresher in the language and standard library might help.