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

Show parent comments

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.

1

u/afrobee Feb 23 '15

What context could that statement possibly need.

So pretty much you don't even consider the scope of your claims. Because you are alleging things like they where the absolute true for every possible context, and not your experienced context, which is the rational thing to assume. My view.

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

So in conclusion, you are basing your claims on your own individual context, yet you express them as there were absolute and irrefutable applicable out of your own scope to everyone else(How do I know this? I see your propaganda even on my soup).

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.

What is this holy grail, that magically happens to enforce best practices upon inexperience people? I want to know, but I think I already know the answer, Ain't I?

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.

Who are this people and in what is context they belong so I can get a reference if they are really the "the vast majority"?

Mutability is an insane default in my opinion.

I would be less confused if you suffix all your statement with that or something alike.

2

u/yogthos Feb 23 '15

So pretty much you don't even consider the scope of your claims. Because you are alleging things like they where the absolute true for every possible context, and not your experienced context, which is the rational thing to assume. My view.

The claim is very general and simple to understand. Reasoning about local scope is easier than reasoning about global scope. I honestly cannot understand how anybody could find this statement controversial.

So in conclusion, you are basing your claims on your own individual context, yet you express them as there were absolute and irrefutable applicable out of your own scope to everyone else(How do I know this? I see your propaganda even on my soup).

Of course I'm basing these claims on my subjective experience, and if that's where things ended then it would be a pretty weak claim. However, plenty of other companies are using Clojure and overwhelmingly have same feedback. Here's one such example for you. A quick google will show plenty of others.

I honestly do not understand why this is making you upset. If you don't like Clojure nobody is forcing you to use it, and Java is not going to go away either. You can use whatever language you like, it's not a zero sum game.

What is this holy grail, that magically happens to enforce best practices upon inexperience people? I want to know, but I think I already know the answer, Ain't I?

Wow great straw man there. Nobody claims FP is a silver bullet here, but yes it would make it easier for an inexperienced person to write better code. In fact one of the most common things people say after working with FP is that it makes them think about state more carefully, something even experienced imperative developers often fail to do.

Who are this people and in what is context they belong so I can get a reference if they are really the "the vast majority"?

Do you even google?

I would be less confused if you suffix all your statement with that or something alike.

I figured people would understand minimal context, but maybe that's too much to expect from imperative developers. :P

1

u/afrobee Feb 23 '15

The claim is very general and simple to understand. Reasoning about local scope is easier than reasoning about global scope. I honestly cannot understand how anybody could find this statement controversial.

Yeah, I agree with you, but I didn't know that using global scope was the default mantra in OOP design or other paradigms.

I honestly do not understand why this is making you upset. If you don't like Clojure nobody is forcing you to use it, and Java is not going to go away either. You can use whatever language you like, it's not a zero sum game.

I'm not, you should see this as free entertainment, an amusement and a opportunity to learn more for myself. Even I really like Clojure. There is not need to bring up Java here ;)

In fact one of the most common things people say after working with FP is that it makes them think about state more carefully, something even experienced imperative developers often fail to do.

As with most OOP and DOD programmers then to learn too. Also, I don't why you have this idea that declarative style is exclusive to FP languages.

Do you even google?

I wouldn't even know which keywords to search for such data :( Any insight?

I figured people would understand minimal context, but maybe that's too much to expect from imperative developers. :P

As with most of your statements, their base is composed by your own selective and invented assumptions. I then to prefer more declarative style. Regardless of that, where you trying to bug on me with that comment? Cute :)

→ More replies (14)

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.

1

u/BeforeTime Feb 22 '15

Java has classes and objects. You'd be looking long for a more powerful abstraction mechanism than that. Other languages might have more abstraction tools that are more suited to some situations, but objects can almost always get the job done. Other mechanisms are just more terse, which can be valuable, but they are not strictly speaking more powerful.

What Java lacks is some sort of syntactic abstraction such as e.g. macros or haskells handling of two argument functions.

→ More replies (11)