News for hackers. Stuff that matters.
Re:The State of Java by DanielStraight on Monday September 21, 2009 @08:46AM (#834464)
I tend to agree with the comments about intentionally controversial headlines, but the article itself was excellent. If you haven't actually read it, please take the time to do so.

I think in the end, the author really nailed it. The important question is, "Is Java dead for me?" I would not use Java for a new personal project (and probably not for a work project either unless the libraries were needed). I do not have a clear replacement in mind... Python stands out the most.

My biggest problems with Java are the compilation step (admittedly not that big a deal with an IDE, but I don't always like to use an IDE), the insistence on objects, and most importantly, the lack of first class functions.

A new issue that has come up for me in comparison to Python is constructor overloading. In Python, constructor overloading is beautiful because of args and kwargs. In any C-family language (including Java here), it's horrible. With small objects where inheritance works well, the constructors in other languages can get unwieldy fast. In Python, they're always concise. I also love keyword arguments in general. It can make code much more readable, especially when using something like wxPython, where the parameter lists are long and otherwise would be quite vague.

Re:The State of Java by plinkplonk on Monday September 21, 2009 @10:16AM (#834614)
"The important question is, "Is Java dead for me?" "

Great Point,

"Is Java dead for me?" (and why or why not) would be an interesting question to ask HN regulars, vs the stupidity of trying to decide whether Java is "dead" or "alive" in general. The former leads a personal statement of intent, and consequently there is no real argument about any answer. The latter is undecideable and leads to plenty of unproductive argument.

As for me, I just transferred the leadership of an Open Source Java library I maintain to someone else, primarily because I am sick of writing and maintaining Java. That said, it is just a personal decision and I can imagine many scenarios where Java (not just the JVM) use would be appropriate. I just hope I am never part of those situations again! :-)

Personally, when I need to build something on the JVM I'll use Scala or Clojure. Else, I'll use Haskell, Python or C as appropriate.

Touch Wood.

Re:The State of Java by prewett on Monday September 21, 2009 @11:16AM (#834738)
I've been wondering about this: for personal projects, Python is compelling. But when you start working with multiple developers, the lack of compile time type checking seems like it would lead to a lot of subtle runtime errors. How do multi-person Python projects deal with this?
Re:The State of Java by steveklabnik on Monday September 21, 2009 @11:57AM (#834844)
I'm a Rubyist, not a Pythonista, but the same principles apply. I love really really strongly/statically typed languages (Haskell) and really really weakly/dynamically typed languages (Ruby).

Generally, it's not a problem. I have a hard time articlating why, exactly... I guess my code just tends to be short, sweet, and to the point. It's very rare that when I code in C, for example, that I try to do something that the type system wouldn't allow anyway.

That's a terrible answer, my apologies. Maybe this would be better: could you provide an example of a situation where you feel that dynamic code would cause a problem?

Mabye a bit of back and forth will help me figure out what I'm trying to say.

Re:The State of Java by prewett on Tuesday September 22, 2009 @12:04PM (#837258)
Is it only you writing the code? If it's just me, generally the names of my variables imply the type ("price" is probably a float, for example). But say you're joining a project with 100 Python classes. How do you write the code so that someone else will know that the arg named "network" is a ip address string and not a network socket or a class, presumably named "Network"?
Re:The State of Java by steveklabnik on Tuesday September 22, 2009 @06:55PM (#838193)
Funny, my "price" would probably be an integer ;).

Maybe it comes down to documentation. If I were to use some sort of function where I wasn't sure what the argument was, I'd look in the docs to see first.

Re:The State of Java by dasil003 on Monday September 21, 2009 @12:05PM (#834866)
This tends not to be a significant problem--if you pass the wrong type you find out the first time you run the code, which is probably not any later than you would have compiled it. A much more common problem are null references, but Java doesn't do anything about those either.

Java is great for the enterprise because it's stable, mature, and doesn't leave any room for cleverness to fly over people's heads. However the compile-time checks don't do much to prevent difficult-to-debug errors. A more powerful type system like Haskell is much more interesting in this regard.

Re:The State of Java by matunos on Friday September 25, 2009 @01:07AM (#842962)
I admit upfront that I'm a static type snob, but I have to disagree here. I've not had much experience with Pythong, but I've had plenty of experience with Perl at the enterprise software level (not just talking shell scripts here) and in my experience, a few of your statements don't hold up.

You definitely compile Java code well before you run it, at least in your full enterprise environment. And if you're using an IDE, you'll probably see any type errors well before you even compile it.

Sure, you might put your code through a workout with unit tests (and you should!), but any programmer knows that unit tests do not guarantee that you are using the right types in production, and they definitely do not ensure that clients of your code will be using the right types from your code.

I can't count the number of times I've had to use Data::Dumper just to figure out what type of object I'm dealing with. And don't even get me started with trying to figure out the right types of arguments to pass!

You are correct that the hardest bugs will be left for run-time, but why add to the hassle?

Re:The State of Java by axod on Monday September 21, 2009 @10:10AM (#834605)
That's not being 'dead' though. That's just choosing the right tool for the job at hand.

It's like proclaiming conventional spanners dead now that you can get adjustable spanners.

Some jobs you want solid object based exception handling water tight programming, and other jobs you want loose runtime based functional stuff.