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.

18

u/f2u Feb 22 '15

I am one of those bleeding edge developers you mention, I know Lisp, ML, Haskell

  • Lisp: 1960

  • ML: 1979

  • Caml: 1987

  • Haskell: 1990

It's funny that those are considered bleeding edge. And I picked the year of the first formal publication. In reality, even Haskell is several years older than the mature (read: old-fashioned) Java.

6

u/BobFloss Feb 22 '15

I guess it's more that those languages have seen increased popularity (and changes, probably) recently.

2

u/llogiq Feb 22 '15

Well, at least Haskell has changed quite a bit since the first release. Even Rust, which is pre-1.0 has been there for some years.

Sorry, but Clojure, Ceylon and Kotlin, while being nice, bring no dramatically new ideas to the table.

1

u/yogthos Feb 23 '15

Clojure takes many great ideas from Haskell and makes them accessible to regular developers. It's dramatically new for most people and most importantly it's usable right now on a mature platform.

2

u/llogiq Feb 23 '15

So you're saying I can skip clojure, because I already grok Haskell?

1

u/yogthos Feb 23 '15

If you find yourself productive using Haskell and get to use it professionally then sure. That doesn't appear to be the case for most people though. :)

I think the fact that Clojure runs on the JVM is a huge advantage in terms of practicality. A lot of companies already use Java and there's no technical barrier to introducing Clojure.

You can keep using same tools, same IDEs, same CI, and deployment environment. The only thing that changes is the language you're using. On top of that you can continue to leverage the existing code you have using interop.

2

u/llogiq Feb 23 '15

Interop doesn't stop at the JVM level. I for one have some coworkers who only know Java (and perhaps a bit of Fortran here or R there).

On the other hand, Java devs usually make up for the productivity loss imposed by their languages by (mostly) refraining from language navel-gazing on reddit, hackernews, etc. :-)

→ More replies (1)

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.

0

u/[deleted] Feb 22 '15

[deleted]

3

u/yogthos Feb 22 '15

With Clojure everything is immutable by default and functions are pure. I only need to understand the specific of the code I wish to change in order to know that the change works.

In Java pretty much everything is mutable and you're dealing with references. It's much harder to tell what the scope of a particular change is without knowing every other place in the application that might reference the same data. Any time you call a function with side effects it might be changing something in an unexpected way.

2

u/afrobee Feb 22 '15

Any time you call a function with side effects it might be changing something in an unexpected way.

Alleging thing without giving a concrete context of your claims,

And what is this something that your are talking about, how this something is gonna affect the rest of the program running if it state is changed?

Is this "something", immutable?

How big is the program?

What are the side effects?

Are best practice applied on the overall architecture to avoid or predict the effects that cause this type of change?

Are we talking about global variable?

How the data represented?

How much is the complexity of data?

The cost of copying data vs mutate it is viable for this program?

I could go on. But I think that you are sensationalizing your claims a little bit too much and baking them up with the most convenient scenarios for their sake.

3

u/yogthos Feb 23 '15

Alleging thing without giving a concrete context of your claims,

What context could that statement possibly need.

And what is this something that your are talking about, how this something is gonna affect the rest of the program running if it state is changed?

That's my whole point. Your changes can only affect things within the scope they're made. You can explicitly see what is affected. The way functional programs are written is predominantly by chaining functions together to transform data. When I want to change a result I trace back through the chain to the point where I need to make the change and do it. I'm guaranteed that the change will only have the effect that's explicit.

How big is the program?

My current project has been in development by 4 people for 3 years now. So, not exactly what I would call tiny.

What are the side effects?

Any changed to shared mutable data that are done implicitly. Pretty much how everything works in Java for example. Any time you call a function that doesn't return an explicit value you've got side effects, any time you call a function that does return a value you might have side effects. Mutability is an insane default in my opinion.

Are best practice applied on the overall architecture to avoid or predict the effects that cause this type of change?

You can either have an honor system that you refer to as best practice or have the language do that work for you. I certainly prefer the latter myself.

I could go on. But I think that you are sensationalizing your claims a little bit too much and baking them up with the most convenient scenarios for their sake.

I could go on as well. I'm not sensationalizing anything, but giving my personal experience working in both types of languages. Vast majority of people who have prefer the functional approach. Pretty much the only people who argue against it are the ones who've have little to no experience working with FP.

→ More replies (17)

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.

1

u/loup-vaillant Feb 22 '15

How much shorter do you think your programs would be if you were allowed to write them in either Lisp, ML, or Haskell?

My personal wild guess is somewhere between 3 and a full order of magnitude. Java may be fine, but whenever I see a lost opportunity for brevity and simplicity, the gap between what I have and what I know kills me. The only way I'm still happy at my current, C++/Qt day job, is because I'm currently learning OOP based GUI programming, and don't know any other way yet. I kinda fear the day when I will.

2

u/llogiq Feb 22 '15

Well, part of my programs could be considerably shorter. Of those, I generate a good percentage (e.g. Lombok). But I do a lot of number crunching, and the arithmetic looks the same whether I write it in Java or Haskell.

→ More replies (12)