views:

1036

answers:

12
+10  Q: 

Is Java incomplete?

Why do I always feel that Java never worried about growing its own API (the one that comes with it)?

I've got several examples..

  1. File upload. Servlet API does not handle it.
  2. Easy XML reading
  3. Connection pooling
  4. HttpClient support
  5. Good logging
  6. Encoders

And so goes on... several lacks that we have to look for third party APIs and its requirements and etc.

Why? I came from C#, and I am feeling a bit disappointed. Do Java developers have an explanation?

+11  A: 

People that came from Java to C# think the same thing as you (but in reverse). It might not be the same but both as great resources. Stuff isn't located in the same place but if you search you will be able to do about the same. It might not be directly in the API, but C# as not always all in the API too.

This is good for all language...

Daok
+18  A: 
  1. File Upload, yep not ideal, but third party libraries exist
  2. Easy XML Reading: DOM, SAX, StAX, JAXB ... lots of solutions out there
  3. Handled by the JDBC driver or by wrapping your JDBC driver in a pooling driver, works transparently (if you're talking about DB connections, otherwise please clarify)
  4. URL.openConnection() provides a simple HTTP client, for more complex requirements see the commons HttpClient
  5. Define "good". java.logging is available, log4j is another common library.
  6. Encoders for what?

Also, I'd like to add that for some items not having a central instance dictate the "one true way" is actually an advantage. This allows alternative implementations to be chosen based on their merits. If there is a officially blessed implementation for everything then this kind of competition becomes less efficient.

Joachim Sauer
I am sorry, but I don't agree any of DOM, SAX, StAX, JAXB is "EASY XML READING".
Dennis Cheung
I think what HttpClient he said is a stateful HttpClient support cookies and else, like apache-httpclient.
Dennis Cheung
@somecharacters: it's fine if you disagree, but would you like to be a little bit more verbose on this? JAXB for example gets pretty simple.
Joachim Sauer
JAXB is good but not simple. It is required to prepare before use it. You'll need a XSD, JARs and more JARs depends by JAR.What simple is that can be done within three lines, which is enough to do it in DHTML, dotNET, Perl, etc.
Dennis Cheung
The JDK 1.4 logging is truly awful. log4j is probably the best of a bad bunch. For something so simple, Java logging is in a woeful state.
cletus
And if you look at the log4j code... well, don't. Just use it.
Adam Jaskiewicz
Easy XML reading: XOM.
Peter Štibraný
+9  A: 

In my experience, both .NET and Java have a rich collection of libraries - just in different places.

Microsoft tend to provide an implementation of almost everything you want - but there haven't historically been many open source alternatives. This is gradually changing, but there still seem to be far fewer widely-used third party libraries in .NET than in Java - and the discrepancy is more than just age would suggest.

In the Java world, it's the reverse - for things like logging, the JDK version came after the open source version. Heck, even generics as a language feature came after open source projects (Pizza and GJ).

Jon Skeet
I think that by Microsoft providing an implementation of as you put it "almost everything you want" is a very good thing, as you can trust the quality of the library. You are less likely to have to maintain a project where somebody decided to use a weird 3rd party library. What are your thoughts?
DoctaJonez
I have mixed feelings about this. The diversity of Java web frameworks is a good example - there's a lot of choice, and a lot of quality too. In .NET there are far fewer choices, which means you're less likely to find an ideal match to your project, but there's more common knowledge.
Jon Skeet
@DoctaJonez: Heheh , that's a joke right?... good one!!.. :)
OscarRyz
+6  A: 
Guillaume
+4  A: 

I started my career working in Java, and after 4 or 5 years switched to .NET. From my experience, your feeling of Java being slightly crippled is somewhat true, but only in the fact that Java has to re-create many of the features that are built-in to the operating system. So whereas .NET can talk directly to a lot of these OS level libraries or modules (MSMQ for instance), or at least wrap it, Java has to re-create it in a platform independent way.

Since I haven't worked in Java for a while, I can't really say that Java is currently lacking compared to .NET, but at the time, in 2004 when I switched, it certainly was (especially when comparing ASP.NET to servlets or JSP).

Sam Schutte
+4  A: 

Yeah, some parts of the Java API are lacking. I don't see this as a problem.

Plenty of great third-party APIs exist, which allows the best of the best to bubble to the top. The good stuff becomes popular and widely used, books get written about it, and it pretty much becomes a de-facto part of the language. The bad stuff falls by the wayside. It's just a different development model that is as valid as any other. Some of the stuff even gets rolled up into "official" API, or at least heavily influences it.

Also, what is "complete"?

Adam Jaskiewicz
A: 

I am not sure is that truth, but I had heard that Sun tried to put "Minimum" API in the early release in Java. Sun was want it as tiny and small as possible. Many unnecessary or "you can do it yourself" API are excluded from the standard JRE/JDK. I thing that it was a good decision at the beginning.

Compare to .NET. CLR can reuse many things from Windows, but Java cannot as it wants to keep cross-platform as possible. More provided in J2SE JRE means, more bugs on more platforms and longer development cycle.

Java guys feel incomplete, and people use more and more 3rd party API. Then, every one addicted to de facto standard and less want to switch to standard. Finally, less pressure on rich API in JRE.

Dennis Cheung
A: 

Maybe because Java wants to keep its "simplicity" by not trying to add built-in features too much. And I think most of the tasks listed can be done with popular frameworks such as Spring or Struts easily. I once had to code a file upload page in JSP to find out later that doing the same task using Struts Framework is much easier!

m3rLinEz
+1  A: 

I like that Java doesn't bolt everything in. It gives you choice over what library you want to use for each task. Definitely take a look at Jakarta commons. For webapps choose a framework like Struts, Spring or JSF. For database access I highly recommend Hibernate which provides ORM, caching, database interoperability and many other features. For logging you can use the built-in java logging API or log4j.

sjbotha
+1  A: 

Jose seems to be the personification of how I think Sun is messing up - there are tons of things out there like Spring, Jakarta, Hibernate, a billion ways to do logging, etc. But they aren't standards.

Now a new programmer comes in. He's experienced. But just looking at the "standard" Java toolset, he thinks the language is lacking. It's not, because there are 3rd party ways to do all that he wants, but at first glance it looks like Java sucks.

Sun should be adopting the best stuff to be part of core Java. It's too confusing for new people coming in and they shouldn't be expected to do tons of research to figure out how to do things.

People say "it gives you choice" but how the heck do you choose?

bpapa
The DO adopt the best stuff. Example: Hibernate came first, then defined as a standard JPA API.
Chase Seibert
It's still confusing. What's the difference between JPA and Hibernate? Which one should I choose? etc. Put yourself in the shoes of somebody is a developer who has never used Java before, coming in and trying to do the "right" thing seems an impossible task.
bpapa
Even gets worse, I'm Starting to use joda time, now it looks to be part of java 7. do I stay with joda when it comes out or do I switch back to the java API for DateTime.
WolfmanDragon
+1  A: 

As long as what Microsoft gives you is what you need, everything in one place is handy. The moment that you run into an issue where Microsoft libraries are lacking, you are in a world of hurt. Yes, Toto, there are places where the .Net Libraries are horrid, text manipulation for one.

Remember C# and Java are both neutered C++, but Java has many more uses than C#. Code bloat is a bad thing, and code bloat is what would happen to get all of the functions that .Net has. Java runs on Unix, Linux, Mac, Windows, mobile devices, Cell chip sets, yada yada.

That's not to say that Java is perfect by any means. You have to look no farther than the Date Class to see proof of that. Documentation is also a weak point in many of the 3rd party libraries for java as well.

WolfmanDragon
I agree in general but not in particular. Text manipulation via RegEx is sublime in .NET. A very powerful engine with a very simple API. Granted, no native support for parser generators. I use Antlr (written in Java) or Gold for that. What other general-purpose text manipulation do you want?
Konrad Rudolph
Having never used Antlr, will it work with PowerShell? I know that that is somewhat off-topic, but I am curious.
WolfmanDragon
A: 

In C#, it's just MS who controls the decision making, they decide what goes in and out of the API. Whereas in Java, a lot of people are involved. It's not that easy to get libraries be a part of the API. (Which, in my opinion, is a good thing. It's KISS.)

mives