Live data from Hacker News

"Should I still learn Java?" Answered: Yes.

beginwithjava.blogspot.com

51–60 of 108 posts

Re: "Should I still learn Java?" Answered: Yes.

#51
post #26
post #20

Earlier quoted context omitted.

As someone who programs Java a fair bit, what bad habits do you believe it teaches?

Most of my work these days is Java too, fwiw. But only because I need Lucene and Hadoop ;-) The main bad habit is a gross overuse of patterns to compensate for language stupidity (see: http://norvig.com/design-patterns/ ). A few particular examples include: - Too much global state. You call it a Singleton. I call it a global variable with a fancy name and a lot more code. - You lose the ability to think functionally…

I agree with you about the verbosity of Java, it's driving me nuts. Also, overuse of XML in java-related frameworks/platforms etc. I mean, when it gets to the point where you have to use complex logic to perform a task, you have to start wondering whether xml is the way to go...

As for overuse of patterns - well, to be honest, I sometimes actually wish that my colleagues would learn some (at least basic) patterns. Quite a large number of them wouldn't know how to implement Strategy, for example.

As for your other points.. I don't know. I think this is debatable. What does too much global state mean? Is having singletons in your application inherently wrong, because they introduce global state? I don't think so. Overuse of singletons (and overuse of any pattern for that matter) is certainly a code smell, but there are simply some situations where singletons are appropriate. Or would you argue that this is true for Java simply because of bad design of the language itself?

What I, personally, dislike about Java is it's really bad handling of lists. You see, as somebody working on Java enterprise projects, I constantly have to do something with lists, I fetch them, sort them, filter them, perform operations on certain elements of the lists etc. And it's incredible how verbose and ugly and littered with for-ifs the code gets. Yes, members of JCP EC, we need those closures, and we need them now.

Re: "Should I still learn Java?" Answered: Yes.

#52
post #19

My main problem with Java isn't the language itself. I think it's a pretty ok language as far as statically typed ones go. My problem with Java is the way it's currently being used. E.g. using annotations to fix things that the language won't let you do elegantly. There's a lot of horrible overengineering for relatively simple problems (you don't HAVE to use GOF patterns, they're just a suggestion for a solution. If…

"My problem with Java is the way it's currently being used"

That is a good point. However, comparing the way things are done in Java and they way things are done in Ruby is a really bad comparison. Those languages live in different problem domains and were grown to solve totally different problems.

Re: "Should I still learn Java?" Answered: Yes.

#53
post #15
post #9

Earlier quoted context omitted.

My kids, like their dad, won't have the patience to create a singleton main object, with a print method, just to run "print 'hello world'".

public static void main(String[] a) { System.out.println("Hello world");} Yeah you're right. That's an insane amount of typing which would take any kid hours. I had to muster up all of my patience just to type all that code out. You're right! Java is so verbose! Your "argument" if you can call it that, is like people saying lisp is crap because it uses too many brackets.

No no no...lisp is crap because it has too many parens not brackets. ;-)

Re: "Should I still learn Java?" Answered: Yes.

#54
post #19

My main problem with Java isn't the language itself. I think it's a pretty ok language as far as statically typed ones go. My problem with Java is the way it's currently being used. E.g. using annotations to fix things that the language won't let you do elegantly. There's a lot of horrible overengineering for relatively simple problems (you don't HAVE to use GOF patterns, they're just a suggestion for a solution. If…

> My main problem with Java isn't the language itself. I think it's a pretty ok language as far as statically typed ones go.

Really? Which statically typed languages have you written in? I think Java (together with C and C++, lets not let Java take all the blame here) is pretty much the bottom of the barrel as far as statically typed languages go.

Compare some of the type examples in the threads here with Haskell's type system...

(Is this post meaningless functional programming propaganda? Probably. But for the love of god stop the myth that Java/C/C++ are good examples of static typing...)

Re: "Should I still learn Java?" Answered: Yes.

#55

Nice article. Good to see a positive Java piece. I'm formerly a COBOL developer, now working with Java. Did anyone else think that his main argument for learning Java could also work for learning COBOL? (substitute COBOL for Java in the quote below) It's not going to go away any time soon. There's too much momentum. There's no need to worry. Ever since the launch of Java I've heard that it's going to be gone or unusa…

Java is the COBOL of the 21st century. It's every bit as elegant and exciting.

Re: "Should I still learn Java?" Answered: Yes.

#56
post #36
post #15

Earlier quoted context omitted.

public static void main(String[] a) { System.out.println("Hello world");} Yeah you're right. That's an insane amount of typing which would take any kid hours. I had to muster up all of my patience just to type all that code out. You're right! Java is so verbose! Your "argument" if you can call it that, is like people saying lisp is crap because it uses too many brackets.

You forgot the class foo { ... } And that it has to be in a name called foo.java. And that you have to compile it and run it with java foo instead of simply ./foo And that startup time of JVM is orders of magnitude worse than pretty much anything else.

"And that startup time of JVM is orders of magnitude worse than pretty much anything else."

Sure, let's throw out of the window all the optimizations the VM can do at runtime because it takes a whole second to start the VM.

And you need to actually compile the source file before executing it!

Those server applications should all be written in bash because it's instantaneous!

Kidding aside, one prof at my university once told me that she wished students should still have to compile and wait for a program to start. When there is such a delay, it pays to read your code and try to understand it before running it (as opposed to run-and-see-what-happens).

Re: "Should I still learn Java?" Answered: Yes.

#57
post #14

Learning Java itself is simple. As a language it doesn't offer particularly anything that isn't already found in other languages, given you know other languages. The biggest effort would be to learn the libraries and you basically can't do that unless you're regularly writing code that interfaces them. But that you can do from Clojure or Scala or whatever language that runs on JVM.

For someone that didn't grew with Java, what is hard is finding your way on the ecosystem.

If you're a newcomer, and you're going to do a website in Python, you soon find out Django, which recommends you to use, lets say, Apache and PostgreSQL. You feel good because you got a sense, immediately, of what you need to know and install to run a website.

Compare that with Java...

I'm using Clojure with Jetty now, I haven't launched yet, and I'm afraid of things like application servers and doing everything with enormous amounts of XML.

Re: "Should I still learn Java?" Answered: Yes.

#58
post #52
post #19

My main problem with Java isn't the language itself. I think it's a pretty ok language as far as statically typed ones go. My problem with Java is the way it's currently being used. E.g. using annotations to fix things that the language won't let you do elegantly. There's a lot of horrible overengineering for relatively simple problems (you don't HAVE to use GOF patterns, they're just a suggestion for a solution. If…

"My problem with Java is the way it's currently being used" That is a good point. However, comparing the way things are done in Java and they way things are done in Ruby is a really bad comparison. Those languages live in different problem domains and were grown to solve totally different problems.

What problem domains are you refering to? I can think of some quite similar ones..

Re: "Should I still learn Java?" Answered: Yes.

#59
Like others here have said, my main issue with Java is not the Java language itself, but rather with the culture of overcomplexity. As an example, every web framework has the issue of abstracting pieces of templates in a consistent manner. Django solved this by writing their own (simple) template language that supports template inheritance.

The java ecosystem seems to have solved this with Sitemesh, a library that implicitly decorates xhtml for you, based on another XML configuration.

I see a few things wrong with this approach. For one, it presupposes all of this nice template work is only ever going to be needed for xml/html. Need to send a text email? Need to make a latex document? Second, it's entirely implicit. This is a common theme with java libraries-- if the usual task is too verbose, usually implicit is the solution. I don't think there's a good reason Java can't be concise and explicit. It just isn't the thing to do.

Re: "Should I still learn Java?" Answered: Yes.

#60
post #15

Earlier quoted context omitted.

public static void main(String[] a) { System.out.println("Hello world");} Yeah you're right. That's an insane amount of typing which would take any kid hours. I had to muster up all of my patience just to type all that code out. You're right! Java is so verbose! Your "argument" if you can call it that, is like people saying lisp is crap because it uses too many brackets.

You forgot the class: class M { public static void main(String[] a) { System.out.println("Hello World"); } } The problem with using this as learning material is that the teacher has to treat the majority of the code as "magic" until the student is ready to learn about classes, access permissions, methods, arrays, namespaces, types and so forth. In many other languages, there's much less boilerplate to handwave away:…

But you don't actually need the main:

class a{static{System.out.println("Hello world");System.exit(0);}}

Post reply on HN