r/programming • • Feb 22 '15

Java Makes Programmers Want To Do Absolutely Anything Else With Their Time

http://www.forbes.com/sites/quora/2015/02/21/java-makes-programmers-want-to-do-absolutely-anything-else-with-their-time/
35 Upvotes

636 comments sorted by

View all comments

219

u/aldo_reset Feb 22 '15 edited Feb 22 '15

Why do many software engineers not like Java?

They don't.

Seriously, I know it might be hard to believe, especially if you spend time reading reddit, HN or if you are subscribed to a few mailing-lists on the subject (which means you are part of a very tiny minority), but the bottom line is that the majority of Java developers is quite happy with Java.

If you are one of these bleeding edge developers who keep their knowledge current, are aware of Scala, Kotlin, Ceylon, Clojure or maybe even ML or Haskell, you are convinced that Java is an abomination and that certainly, all its users must absolutely hate it. And you are dead, dead wrong about that.

Before Java, we had C++, and if in the 1990-1995 period, you had interviewed C++ developers, you would probably have found out that a huge proportion of C++ developers absolutely hated programming in this language. Which set the stage for Java to take over in 1995.

I'm not seeing this today. There are no rabid mobs of developers with pitchforks massing at the gates and asking for a revolution. Java is respected for its productivity, its readability and its unbeatable fast path to getting things done in a way that's scalable and maintainable.

Which is why that it's not going to be replaced any time soon. Not by Scala, not by Kotlin, not by Ceylon. In a lustrum, maybe. But not in the near future.

Java is fine, it's liked, it's respected (for good and bad reasons) and it's going to be around for a very, very long time.

40

u/llogiq Feb 22 '15

I am one of those bleeding edge developers you mention, I know Lisp, ML, Haskell and am currently looking into Rust. And I'm also a Java developer, and quite happy with Java.

Java sucks at some points, yes, but not as hard as many think. For a lot of problems, it's actually quite capable, and the specific pain points some folks never tire to mention either can be worked around with little effort or don't impair productivity as much as they think anyway. Also, frankly, the tooling just rocks.

12

u/yogthos Feb 22 '15

As one of those bleeding edge developers who developed Java professionally for a decade before moving to Clojure, I would not go back to working with Java.

My team saw a huge leap in productivity compared to the similar scope projects we've done in Java. The language does play a big role in this. Being able to write code close to the problem domain makes the code base much smaller and easier to maintain.

Having drastically less code has impact on things like refactoring. When it takes you a 100 lines to solve a problem you're not all that attached to the code. When it takes you a 1000 then you're much less likely to want to revisit it.

Being able to safely reason about parts of application in is a huge benefit when you're working on a large project with a team. I know that I can work on my piece and I'm guaranteed that it doesn't have any shared state with another piece somebody else is working on.

When I come back to some code 6 months down the road I know that the changes I make are guaranteed to be local. I don't have to remember how it interacts with the rest of the application, where the data is coming from and where it's going.

I also agree that tooling is important. I find REPL to be an indispensable tool. With it I can solve problems interactively and see exactly what the code is doing. Having it integrated into the workflow makes development a far more pleasant experience.

Aside from that, I find you have pretty much the same tooling you have for Java. You've got Leiningen or Maven for doing builds, you can use the same profilers, build servers, and deployment targets.

You can also use the same IDEs such as Eclipse or IntelliJ. The refactoring support might not be as powerful, but you also tend to have orders of magnitude less code. I'd much rather have less code to work with than fancy tools to help me manage giant heaps of it.

2

u/llogiq Feb 22 '15

I usually whip up a quick unit test + debugger if I need to test something, but I also sometimes just start a beanshell.

2

u/yogthos Feb 22 '15

Sure, but that's still more work than simply being able to look at a function and know what it's doing definitely. The other big aspect of it is the REPL, which provides far more fluid integration than the debugger or the beanshell. As you can see here the editor is linked up with the running image of the app and you can evaluate any function you write directly in the context of the application.

1

u/llogiq Feb 23 '15

It may be a bit more work (although given a good IDE, it's but a few keystrokes), but on the plus side, I get a unit test. :-)

1

u/yogthos Feb 23 '15

I get unit tests in Clojure as well, I just don't need nearly as many since the code is stateless. Also recommend looking at this. With Clojure, I can trivially mock any function in a test without having the code being mocked to be designed with that in mind.

For example, let's say there's a function, and it doesn't even have to be in my own code, could be a function from a library I'm using.

(defn get-user [connection id]
  (jdbc/query connection ["select * from users where id = ?" id]))

Now I'm doing unit tests and I want to have a mock user instead of checking the database:

(testing "get-user"
  (with-redefs [get-user (fn [_ _] {:id "bob" :pass "fake"})]
    (is (= {:id "bob" :pass "fake"} (get-user)))))

It's like monkey patching, but safe and locally scoped.

1

u/llogiq Feb 23 '15

I don't care much about mocking. During my time in consulting in an enterprise development scenario, I had to use it on occasion, but it was neither sufficiently awesome nor sufficiently painful to leave much of an impression.

1

u/yogthos Feb 23 '15

Mocking is just an example of how with-redefs can be useful.