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

21

u/nickguletskii200 Feb 22 '15 edited Feb 22 '15

What a shitty article.

Please find me a language that has:

  1. Comparable tooling

  2. A set of 3rd party libraries as rich as Java's

  3. Non-retarded standard library

This article doesn't even use modern Java... This:

HashMap<String, Set> depMap = new HashMap();

Should be written like this:

Map<String, Set> depMap = new HashMap<>();

I can't fucking understand what the author is suggesting. C and C++ absolutely can't be used where Java is used. OCaml has a rather small community. Haskell is just too hard to work with for most projects: it becomes a restriction, not a tool.

Edit: fixed code example, thanks /u/TomRK1089!

4

u/yogthos Feb 22 '15

Take a look around on the JVM. You have Clojure and Scala which are both very nice languages. They get the benefits of the exact same tooling and libraries. On top of that you get some nice tooling you don't get in Java. For example, Clojure allows doing REPL driven development and IDEs provide structural code editing. The JVM is a great platform, but there are very few compelling reasons to use Java the language today.

3

u/nickguletskii200 Feb 22 '15

I've used both Clojure and Scala, and I want to try Groovy next (although I'll wait a bit and see if it dies out since Pivotal is no longer behind it).

Clojure gave me a very bad first impression. I liked the language, but the implementation is horrible. Doing something incorrectly results in the compiler throwing exceptions instead of showing what in the code caused the problem. Documentation on some of the more advanced language features was scarce at the time.

Scala has different problems. Or at least it had the last time I used it (I doubt the situation improved though). Compilation is slow, IDEs are mindbogglingly slow and unstable and the language seems to love abusing operator overloading for everything. Oh, and I still don't understand why they chose Pascal-style syntax for variables, parameters, etc...

2

u/yogthos Feb 22 '15

Clojure gave me a very bad first impression. I liked the language, but the implementation is horrible. Doing something incorrectly results in the compiler throwing exceptions instead of showing what in the code caused the problem.

I've been using Clojure professionally for the past 4 years and I can definitively tell you there's nothing wrong with its implementation. The error messages certainly could be better, but figuring them out is not all that difficult once you learn what the errors mean. My experience has been that errors do trace precisely where the problem occurred vast majority of the time. In fact I've practically never had a reason to use a debugger when working with Clojure, something that I relied on constantly with Java.

I also find that the REPL completely eliminates the whole compile/run cycle. I can see what the functions are doing as I'm writing them and I don't have to compile and run the whole application any time I make a change. This means that I'm not building up a lot of code before I'm testing to see whether it does what I want. This keeps the context that I need to keep in my head at any one time very small.

I don't know when you last tried Clojure, but there's a lot of documentation available today and there are a number of great books discussing its advanced features.

Not being a Scala user myself I can't really say what the situation is like there. Lots of companies appear to be using it happily though, so can't be all bad. :)

1

u/nickguletskii200 Feb 22 '15

I've been using Clojure professionally for the past 4 years and I can definitively tell you there's nothing wrong with its implementation. The error messages certainly could be better, but figuring them out is not all that difficult once you learn what the errors mean. My experience has been that errors do trace precisely where the problem occurred vast majority of the time. In fact I've practically never had a reason to use a debugger when working with Clojure, something that I relied on constantly with Java.

When I first used it I kept getting NullPointerExceptions. Maybe you don't use macros that much, but the first thing I did was try to implement a DSL based on Clojure and it was very frustrating.

That said, if/when they do fix the stupid compiler, I will give it another go, because I really like the concept.

2

u/yogthos Feb 22 '15 edited Feb 22 '15

Using macros is generally discouraged and vast majority of problems can be solved with regular functions. Beginners often get overexcited about using macros and that's a mistake in my opinion. Macros are a useful tool, but that's really not the main appeal of Clojure. If you look at popular Clojure libraries in the wild you'll see that there are very few macros in them. As the style guide says: don't write a macro if function will do.

One of the main benefits I see using Clojure over Java is actually how rare null pointers happen, typically when doing Java interop. Since all the standard library functions handle nil values intelligently, they simply bubble up to the top in most cases. Instead of having to pepper null pointer checks all over the place, you can simply check for a value at the end of the transformation.

Again, I'm not sure what you mean by "fix the compiler". The compiler works exactly as it's supposed to, but you have to understand the intricacies of the language in order to use the most advanced features.

Macros require you to understand the details of how the reader and the evaluator work, what macro expansion is, when it happens, how macros interact with one another and so on. It's hands down the most complex feature of the language and I definitely would not recommend focusing on it as a beginner.

-1

u/nickguletskii200 Feb 22 '15

Using macros is generally discouraged and vast majority of problems can be solved with regular functions. Beginners often get overexcited about using macros and that's a mistake in my opinion. Macros are a useful tool, but that's really not the main appeal of Clojure. If you look at popular Clojure libraries in the wild you'll see that there are very few macros in them. As the style guide says: don't write a macro if function will do[1] .

It wasn't enough in my case. Why would I waste my time on fighting macros if it were?

One of the main benefits I see using Clojure over Java is actually how rare null pointers happen, typically when doing Java interop. Since all the standard library functions handle nil values intelligently, they simply bubble up to the top in most cases. Instead of having to pepper null pointer checks all over the place, you can simply check for a value at the end of the transformation.

But the compiler still nullpointed.

Again, I'm not sure what you mean by "fix the compiler". The compiler works exactly as it's supposed to, but you have to understand the intricacies of the language in order to use the most advanced features.

Throwing NullPointerExceptions instead of syntax errors isn't "working as it is supposed to" in my book.

1

u/yogthos Feb 22 '15

It wasn't enough in my case. Why would I waste my time on fighting macros if it were?

There's nothing that macros let you do that can't be done without macros. They're a way to template code when you see repetitive patterns. You still haven't described what it is that you were trying to do in the first place.

But the compiler still nullpointed.

I'm not sure what you mean by "compiler nullpointed", are saying you crashed the compiler. I've certainly never seen that happen myself.

Throwing NullPointerExceptions instead of syntax errors isn't "working as it is supposed to" in my book.

Again, perhaps you could actually described exactly you did and how you got a null pointer. Perhaps you can paste your code. I have a rather hard time believing that you managed to crash the compiler.

1

u/nickguletskii200 Feb 22 '15

Again, perhaps you could actually described exactly you did and how you got a null pointer. Perhaps you can paste your code. I have a rather hard time believing that you managed to crash the compiler.

I don't have the code anymore, that happened 1.5 years ago and I pretty much threw away the project.

There's nothing that macros let you do that can't be done without macros. They're a way to template code when you see repetitive patterns. You still haven't described what it is that you were trying to do in the first place.

Yes, but it would be considerably harder to do. If I recall correctly, macros in Clojure are actually implemented in Clojure, so yes...

3

u/yogthos Feb 22 '15

Right, so not knowing what you were trying to do it's really hard to say what went wrong there. As I said, understanding how a macro works can often be non-trivial. There are tools like macroexpand that help you see what the resulting code will look like, but they can be difficult to reason about. This is the reason macro use is discouraged unless it's strictly necessary.

My point is that it's far more likely that you simply didn't understand what the code templated by the macro was doing than there being any actual problem with the compiler.

→ More replies (0)

3

u/TomRK1089 Feb 22 '15

You have your diamonds backwards. The diamond operator infers the RHS type based on the LHS declaration. It annoys some people; I don't particularly mind.

1

u/nickguletskii200 Feb 22 '15

Woups... Thank you, fixed it.

0

u/Dworgi Feb 22 '15

C#.

Mainly because you didn't ask for portability. Which is coming soon anyway.

8

u/txdv Feb 22 '15

A set of 3rd party libraries as rich as Java's

I love C#, but when it comes to 3rd party libs, you can find anything for Java. They even have a git implementation in "pure Java", C# had 2 projects but they both died.

-4

u/[deleted] Feb 22 '15

[removed] — view removed comment

3

u/txdv Feb 22 '15

Which means you can make it run on the CLR by using IKVM or by using an automated java to C# code converter, since java is basically a retarded subset of C# 2.0 from 2005.

You certainly can, but that is additional complexity. Something that Java gets a lot of slack for.

Have you ever done that? Use a Java library with IKVM from C#? Or an automated java to C# code converter?

→ More replies (3)

-1

u/nickguletskii200 Feb 22 '15

C#

C# is a great language, but not a great platform. It's tooling is significantly worse than Java's, the standard library is utter shit and there aren't that many 3rd party libraries (and a lot of them are just half-complete ports of Java libraries).

The only thing I upgrade by switching from Java from C# is the language itself. Everything else is a downgrade. And yes, I've used it.

2

u/fhelwanger Feb 22 '15

Also, tough its tooling is basically only VS, it's really great. Maybe your point is only based on your personal taste

1

u/fhelwanger Feb 22 '15

Why do you think the standard library is utter shit? At least in C# we don't have to use some 3rd party libs to work with dates. We also have LINQ, which is great. I can't get your point

1

u/nickguletskii200 Feb 22 '15

At least in C# we don't have to use some 3rd party libs to work with dates

Neither do we. Java 8 has an amazing date time API.

We also have LINQ, which is great.

And we have streams. And?

2

u/fhelwanger Feb 22 '15

And why C# standard lib is utter shit? Can you point something?

→ More replies (1)

1

u/[deleted] Feb 22 '15

But streams suck compared to enumerables, the nice thing about IEnumerable is that it's for collections and streams. So you don't have to collect anything unless you're casting to a collection, you can make extension methods that work on all collections and streams, and the syntax is way nicer.

→ More replies (12)

0

u/[deleted] Feb 22 '15

Go's standard library is way less retarded then Java's. It's got a pretty extensive set of 3rd party libraries (not as good as Java, but considering how young it is it's really impressive).

I don't know about the tooling, but it is definitely an easy language to parse (unlike C++ for example), so I imagine you could do pretty much anything you wanted. E.g. it has EASY built in support for unit tests and documentation. For Java I imagine you need to download some third party tool and write some XML nonsense.

C and C++ absolutely can't be used where Java is used.

What? Why not?

0

u/nickguletskii200 Feb 22 '15

Go's standard library is way less retarded then Java's. It's got a pretty extensive set of 3rd party libraries (not as good as Java, but considering how young it is it's really impressive).

Go, as a language, is retarded. Generics worse than Java's (bwahaha), shitty error handling system, etc...

I don't know about the tooling, but it is definitely an easy language to parse (unlike C++ for example), so I imagine you could do pretty much anything you wanted. E.g. it has EASY built in support for unit tests and documentation. For Java I imagine you need to download some third party tool and write some XML nonsense.

Is JUnit too hard? And Javadoc? Also, you don't need any XML anymore. Maven can be replaced by Gradle and frameworks like Spring have pure Java configuration nowadays.

What? Why not?

When safety, compilation speed and other factors regarding development speed are important, it's best not to use C and C++ because they are simply a time waste and an overall security risk.