PDA

View Full Version : C# for Java Programmers



M.GhanaatPisheh
یک شنبه 19 شهریور 1385, 23:49 عصر
چند خطی از Larry O’Brien و Bruce Eckel



Of course, no one really believes that Java’s success has
borne out its stated value proposition of “write once, run
anywhere” (at least no one who believes that the
Macintosh is a significant part of “anywhere”).1 Java has
succeeded in two key areas: as the dominant language for
writing server-side applications and as the top language
for teaching computer science in colleges. The .NET
Framework is better for both these areas, although
obviously it is not inevitable that it will become dominant
in either. For writing client applications, there is no
question that C# clearly outstrips Java.
There are several good reasons for a Java programmer to learn C#. Before going
into them, though, it’s important to acknowledge that C# and .NET have been
shaped in part by Sun’s litigation over Microsoft’s version of Java. Although
Microsoft had been talking since at least 1991 about some C++-derived language
to bridge the gap between Visual Basic and C++, Java’s blistering pace of
innovation in 1996 and 1997 gave Sun tremendous credibility regarding the claim
that Java was commoditizing the operating system. By 1998, people (most
importantly, Judge Ronald Whyte) were willing to believe that Microsoft’s
platform-specific variations were “an attempt to fragment the standardized
application environment, and break with cross platform compatibility.”2 Even
1 Yes, yes, the Macintosh supports Java and OS X brings the level of that support to a
reasonable par with what’s available on Windows and UNIX. But this is a recent
occurrence and only became true long after Java had succeeded due to its other merits.
2 Despite, incidentally, a license that said that Microsoft could “modify, adapt, and create
Derivative Works of the Technology.” Further, the finding that Microsoft’s behavior would
cause “irreparable harm” to Sun was not based on an analysis of the market for computer
languages and technology, but on the finding that Microsoft’s behavior constituted a
Bill Gates wrote in those days that “It’s still very unclear to me what our OS will
offer to Java client applications code that will make them unique enough to
preserve our market position.”
Now, it’s much clearer. Java is just another platform, not the end of platforms.
The pace of Java innovation has greatly slowed, especially when it comes to
application-level features. It took years for Java to support mouse-wheels, Swing
is not available on J2ME, J2EE is needlessly complex, and .NET leapfrogs Java in
the area of Web Services.
To the extent that Java’s goal was to commoditize the operating system, it has
utterly failed. Windows is still important, as are the Macintosh operating
systems, Linux, Solaris, and PalmOS. Obviously, a Java programmer has the
advantage of being able to jump back and forth to develop solutions for any of
these platforms, but Java does not come close to subsuming the capabilities of
any operating system. If you’re interested in providing your users a rich clientside
experience, Java just isn’t competitive with native applications. C# makes
writing native Windows applications incredibly easy; Windows Forms is
noticeably easier to program than Swing, has much better performance, a more
comprehensive widget set, and COM Interop and PInvoke (technologies for
accessing non-.NET resources) are vastly easier to use than Java Native
Interfacing.
Obviously, if you choose to write a rich client application in C#, you’re giving up
on alternate operating systems, too. Most significantly, you’re giving up on
Macintosh and the PalmOS, which are the only two non-Windows platforms that
are serious markets for client applications (Linux, which has a strong claim for
being the most significant threat to Microsoft’s OS dominance, is dominated by a
mentality that thinks software should be free). However, there are only three
significant areas where Microsoft does not yet provide a solution – mainframes,
telephones, and the Macintosh. Mainframes are now legacy systems and
Microsoft is poised to enter the telephone market, where it is likely to achieve the
same type of success it has achieved in the handheld market (where PalmOS still
has a marketshare lead, but Microsoft’s PocketPC is an increasingly important
player). Unfortunately, no one has announced any plans for a port of the
Common Language Infrastructure to Macintosh (although Mono does run on
Linux running on the PowerPC chip).
Aside from rich client applications, the .NET Framework SDK is an excellent
programming platform for server-side programming. There is no separate
programming model for enterprise development as there is with EJBs. While
J2EE does provide for scalability, it does so by introducing considerable
complexity and constraining the programmer in annoying ways. Just as Java was
striking for how much easier it made programming network and simple graphical
programs than using Microsoft Foundation Classes and MFC, so too is .NET
striking for how much easier it makes backend programming than using J2EE.
Although .NET is new, Microsoft really bought into the Web Services vision
several years ago and Java is actually playing catch-up to .NET in terms of
delivering value via XML and standard Web protocols.
Finally, .NET turns the value proposition of Java upside-down. Where Java
proposes a single language to “write once, run anywhere,” .NET proposes “Any
language, one platform.” For those who have a broad interest in programming,
the dominance of object-oriented imperative programming has been a mixed
blessing. On the one hand, it’s the common ground from which the patterns
movement sprang and the patterns movement was certainly among the most
significant developments of the 1990s. On the other hand, it’s introduced a
certain blandness to an industry that used to support an “Exotic Language of the
Month Club.” One of the few non-environmental correlates to the highly variable
measure of programmer productivity is the number of programming languages
spoken; it is more significant than age, years of experience, or salary.
Different programming languages allow for much more dramatic differences in
approach than different libraries. Java and C# are likely to produce similar
structures to tackle similar problems; the chief differences would be the use of
Java inner classes versus C#’s delegate types for event handling, C#’s lack of
checked exceptions, and the exact names and methods in the library functions
used. On the other hand, PROLOG (a declarative language) and C# would
produce dramatically different structures to solve the same problem; declarative
programming engages the mind in a different way than imperative programming.
Java’s position as the most-taught language in colleges is all well and good, but it
necessarily limits the audience and constrains the topics of software development
to those aspects of programming that Java embodies. The .NET Framework
provides a much more robust infrastructure for teaching a much broader concept
of programming to a much broader audience.
As a programming language, the Java developer will find in C# an evolutionary
improvement, as a programming platform, .NET is superior to the Java standard
edition and markedly superior to J2EE. For those Java programmers who have
become disillusioned with the evolution of Java and the behavior of Sun, C#
provides a higher-productivity solution for very little investment in time.