pvdg42 said:
The answer to your first question is that the Java SDK comes with the Java
API, a large collection of classes available for use with Java, the
language. Actually the Java API class library and the .NET Framework class
library are quite similar in some respects. Both are inheritance hierarchies
with a class called Object as the cornerstone of the hierarchy.
That said, I'll give you my *opinion* on possible reasons why so many more
lines of code were needed in Java:
1. Most Java IDE's I've seen are not nearly as sophisticated as Visual
Studio when it comes to supporting drag and drop development of the GUI,
thus Java developers had to write more GUI code.
That's true. However, Eclipse in particular is significantly better
when you *are* actually writing code than Visual Studio is, IMO. (These
days I believe it has a drag and drop visual designer, but I haven't
used it.)
As I spend most of my time writing code rather than dragging and
dropping, I'd rather have a decent editor than a decent designer.
2. Because Java is the "write once, compile once, run anywhere" language
(lot's of caveats to that marketing hype), the GUI development involves
complications like layout managers that simply are not (usually) a worry
factor in Visual Studio.
They're "not a worry" so long as you don't care how your form gets laid
out when you resize it (or when you change display language). Java's
layout managers allow you to relatively easily write UIs which can
easily be resized. .NET has this capability, but it's not as advanced
and tends to be ignored when using the designer, which tends to rely on
absolute positions.
As far as I can tell, WPF (aka Avalon) is closer to Swing/AWT than it
is to WinForms in terms of layout. (And thank goodness, say I.)
3. Based on experience teaching Java, VB and C#, the Java API classes do not
expose as rich or as sophisticated an interface as do the .NET Framework
classes, thus leaving more work (code) for the using developer. (After all,
major portions of the Java API are much older than the .NET Framework).
I think there are pros and cons both ways. Java got close to a
reasonable separation of "point in time" from "point on the calendar"
but only after a few attempts (leaving a huge deprecated API) and its
methods of manipulating it are painful. Java's character encoding
support is much harder to use than .NET's. Java's (W3C) XML APIs are
foul, although there are plenty of open source alternatives.
The latter is a very important point - there's much more community and
open source involvement in Java, IMO, partly due to its age. That's why
important projects like JUnit, Ant, Hibernate and Spring are ported
from Java to .NET rather than the other way round.
When developing a website, for example, with .NET there's effectively
just one big player: ASP.NET. In Java, there are (off the top of my
head):
Struts
JSP
Tapestry
Java Faces
Spring Web Flow
Plain servlets
- and that's just for starters. The downside is that you need to pick
carefully, and all the technologies have their limitations. The upside
is that at least you get a choice.