Live data from Hacker News

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

beginwithjava.blogspot.com

41–50 of 108 posts

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

#41
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.

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:

    print("Hello World")
    puts "Hello World"
    (println "Hello World")

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

#42
post #27

Earlier quoted context omitted.

- It is just barely object oriented (and Alan Kay agrees with me on this). Checkout CLOS and the MOP or Smalltalk sometime for a good object system. - No. Java has a complex syntax. Take a look at the grammar sometime. It's 10s of times longer than Scheme's (see: http://java.sun.com/docs/books/jls/second_edition/html/synta... ). You just like it because it's almost, kind of, a little, like C and C++. - It is, in larg…

- True; I was just considering the mainstream languages. Yes, if you include Smalltalk, LISP, I'm sure there are better alternatives to learn specific concepts. But Java is used a lot in practice, and looks a lot like other languages used in practice (C++, ObjC, C#, and friends), which in my experience makes students more enthusiastic. - I agree the "generics" are complex and overly verbose. They almost look like the…

Ruby and Python are also mainstream, and both provide saner OOP.

C++ templates at least have a purpose and provide extra benefits (e.g. performance, compile-time computations for pre-caching). In Java generics are practically implicit type-casts and nothing else.

About verbosity ... clear conventions are a lot more effective for readability and learning. In a dynamic language like Ruby / Python, if you don't know what an object's type is or what it does, the fix is as easy as ...

    obj = don_t_know_the_return_type()

    # doing lots of stuff

    import pdb
    pdb.set_trace()
That opens up a Python debugging console at the current point of execution, and you can inspect "obj" for its type / members and also modify its state. Also, if you're using "ipdb" instead of pdb then you've also got auto-completion on (e.g. Intellisense). You can do something similar in Ruby, and in Smalltalk the whole application is active while you're typing in the IDE.

There, problem solved.

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

#43
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. [...] My problem with Java is the way it's currently being used.

Absolutely agreed. Java has some weak spots, but the really bad things (and the most criticized things) are not in the language per se.

E.g. the complete over- and abuse of XML for anything. Complex Ant build scripts. The whole EJB disaster (the older versions, that is). Bad APIs (though in all honesty, most of the really bad ones are 3rd party and not from Sun). The over-use of dependency injection, beans, etc. without a justifiable reason.

Many of these things are just stuff we learned to do better by now, for example JSON and/or Yaml over XML configuration, and convention over configuration. That lower overhead and higher understandability are more important than some would be architect's dreams. On some things the jury is still out (e.g. more or less functionality in basic classes like String, List, ...).

Overall, I think some people are overlooking the many benefits Java has made available to the main stream. It's entirely possible to write beautiful Java code, you just have to go the extra mile of leaving the convention sometimes.

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

#44
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'm personally mad at Doug Cutting for perpetuating Java.

Java is a virus. If Lucene and Hadoop were written in C/C++ you'd be able to easily use them from basically any language. Because they're written in Java, it forces the rest of your code to live in Java land as well.

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

#45
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 unusable tomorrow. History shows that just doesn't happen to popular programming languages.

If you learn Java now, you may still be using it 20 years from now. Or 30.

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

#47
post #20
post #10

As someone who rather dislikes Java, I'd still tell others to learn it (but certainly not as their first or even second language - it teaches too many bad habits). The main reason would simply be that a lot of interesting problems require tools/libs written in Java (Hadoop and family, Lucene, etc) if you want to get off the ground quickly and efficiently. Eventually, you're going to need to tweak your tools - so lear…

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

Inheritance instead of composition. Too much worry about security theater public/protected/default/private instead of actually reusing code. The inability to fake stuff for tests without designing ability to fake things into every class. Basically, you write the code, and that's what you have. If anything changes, it's basically a rewrite, even with Eclipse's "refactoring" features. Type erasure.

When all you have is Java-style OO, everything looks like an AbstractHammerFactoryInterface.

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

#48
post #40
post #27

Earlier quoted context omitted.

- It is just barely object oriented (and Alan Kay agrees with me on this). Checkout CLOS and the MOP or Smalltalk sometime for a good object system. - No. Java has a complex syntax. Take a look at the grammar sometime. It's 10s of times longer than Scheme's (see: http://java.sun.com/docs/books/jls/second_edition/html/synta... ). You just like it because it's almost, kind of, a little, like C and C++. - It is, in larg…

Explain to me how: Map >> data = new HashMap >>(); is useful. Firstly, in Java 7 or in Java 6 in a modern IDE, you only have to type: Map >> data = new HashMap (); So let's break this down: if I was using another language, I could just do: var data = {}; But consider what you've now lost: 1. If your code was just a simple associative array, not much. But if you have a complex nested data structure, you need to now pu…

Yes, Java 7 finally will fix this bug (which is 7 years old!). The fact that good IDEs can work around this bug, doesn't mean Java sucks any less for it though. I have similar issues with syntax for anonymous classes (which you need a lot of, to even poorly simulate fp), but we'll save that for another day.

I don't want var data = {} in a statically typed language. I want something like Map]> data = new HashMap(); to use the exact same example that I used above. This way gets all the benefits of what java currently does, with literally half the characters and more readability.

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

#49
post #20

Earlier quoted context omitted.

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

Inheritance instead of composition. Too much worry about security theater public/protected/default/private instead of actually reusing code. The inability to fake stuff for tests without designing ability to fake things into every class. Basically, you write the code, and that's what you have. If anything changes, it's basically a rewrite, even with Eclipse's "refactoring" features. Type erasure. When all you have is…

Yes! It's amazingly hard to do inheritance right. As a rule of thumb, if you can't prove that the inheritance doesn't violate the Liskov substitution principle, you shouldn't be allowed to do it. (It amazes me how many java 'programmers' have never heard of lsp or a refinement proof).

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

#50
post #44
post #26

Earlier quoted context omitted.

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'm personally mad at Doug Cutting for perpetuating Java. Java is a virus. If Lucene and Hadoop were written in C/C++ you'd be able to easily use them from basically any language. Because they're written in Java, it forces the rest of your code to live in Java land as well.

there is a C++ port of Lucene (named CLucene iirc) Not sure if there is such thing for Hadoop though.
Post reply on HN