On CBS.com: Drew Carey rules Price is Right

C# is just Java--only a little worse

Tags: Ryan Brase

  • Save
  • Print
  • Digg This
  • 41

Takeaway: Few developers would dispute the similarities between C# and Java. But one Builder.com member believes that Java wins a technical comparison hands down. Check out his arguments and add your two cents.


C# and Java are both nice languages. They reach similar goals through similar means, although C# adds some syntactical touches to Java, such as the foreach keyword and a more pleasant extends/implements construct. Unfortunately, the improvements are outweighed by the instances of regression. In this article, I'll compare the languages, while trying to avoid dipping to the JVM and CLR level.

Java: All the greatness of C++ without the hassle
When comparing Java and C#, you can’t help but notice their profound similarity, which is owed in part to their common ancestors, C and C++. However, when Gosling and crew sat down to create Java, they not only borrowed capabilities from C++, but more important, they pared away some of the unnecessary features that made C++ bug prone and difficult to learn. C#'s designers added a lot of the same C++ features that Java added but failed to remove some of the worst features of C++. The result was a language that still tries to be all things for all people and ends up internally conflicted and overly complicated.

Sloppy syntax pitfalls
The easiest errors to pick out are those in flow control and syntax. C# offers the goto command as a mechanism for altering the point of program execution. Computer scientists have been railing against this approach since Edsger W. Dijkstra published "Go To Statement Considered Harmful" in 1968. Goto invites code that is difficult to debug and hard to run through test coverage tools.

On a different note, operator overloading is the same sort of sin on a more subtle level. When '+' can mean anything depending on the type of the operands, the functioning of code is no longer transparent and unintentional side effects abound.

C# weaker security
C# contains a simple mechanism for marking regions of code as unsafe. Within these unsafe regions, the safeguards put in place by Java and later C# to prevent programmers from directly altering memory locations and using point arithmetic are suspect. Dropping to the memory address level when working with a garbage-collected high-level language muddies the intentional object/memory separation. Bugs can slip in easily, debugging is a nightmare, and buffer overruns once again rear their ugly heads to open the security holes for which C and C++ are famous.

C# also allows simple access to native libraries on the host system. This binding to non-.NET objects is similar to the functionality offered by the Java Native Interface (JNI), but it's more insidious. Whereas JNI was designed to carefully limit the interaction between Java code and native code with well-defined interfaces, .NET makes calling off to native object files so invitingly simple that developers can do so without realizing they're throwing platform portability out the window in the process.

SOAP integration
C#, and to a greater extent .NET, has tightly integrated SOAP Web services. SOAP is a fine standard for making remote procedure calls using XML to specify parameters and results values, but it is by no means the only way. Using external libraries for Web services allows Java developers to easily change out their Web service flavor, be it SOAP, XML-RPC, or something as of yet uninvented. C# developers, of course, always have the option of using external libraries for non-SOAP Web services, but the tight integration of the SOAP standard is more limiting than it is empowering.

The owner is scary
Perhaps the scariest feature in C# is its owner. Microsoft has made a good show of opening up C# and .NET for non-Windows platforms, but it is largely all show. Its CLRs for non-Windows platforms are problematic and buggy. It has run C# through the ECMA standardization process—a step Sun is still too cowardly to take with Java. The fear comes in with the level of lockdown Microsoft could apply given the desire to do so. Microsoft has filed for a patent that would preclude the writing of third-party CLRs, such as the Mono project. If Microsoft decided to clamp down on the free C# and .NET communities, it wields enough financial and legal muscle to chase development back into Win32 platforms—a not unfavorable outcome from its position.

The Java language, on the other hand, isn't an ECMA standard, and shame on Sun for that. It is, however, implementable without patent encumbrance, and both its virtual machine and core class libraries are available in both open and closed source implementations from third parties. C# looks free but isn't really, while Java looks restricted but can legally be implemented freely.

Finally, and I never though I'd get to say this, but Java has better tool support even when integrated development environments (IDEs) are taken into account. Visual Studio .NET is a fine IDE. It represents years of work and is feature rich. However, the Eclipse IDE, which includes Java support, has pulled ahead of Visual Studio in stability, ease of use, and offered features. IBM contributed significantly to Eclipse, and if you buy into the old software development adage "Build one to throw away," you can count Visual Age as its first, now discarded, attempt. Fortunately for the C# folks, a .NET version of Eclipse is in the works.

Not so bad, but not Java
Appraised honestly, there's really nothing that terrible in C#. It isn't the horror that Visual Basic is, and it doesn't practically insist that developers shoot themselves in the foot like C does. The bottom line, however, is that C# doesn't do much, if anything, better than Java, and it's measurably worse in a few areas. When selecting between these two largely identical languages, pick the one that's slightly better and battle-tested: Java.
  • Save
  • Print
  • Digg This
  • 41

Print/View all Posts Comments on this article

COM Integration not a flawITGuru  | 04/06/03
Much ado over (Microsoft?)jwallison@...  | 04/07/03
Yes, Java is "battle-tested"ngrilly  | 04/07/03
platform independence is not closerkilgore@...  | 04/20/03
Both Suckjdieter@...  | 04/08/03
Dude you are on drugszane.kelly@...  | 04/09/03
zane is the zany onejdieter@...  | 05/08/03
Wow!don@...  | 08/12/04
Poor publishing standards.

Exactly what ...
J. Buelna  | 04/12/03
couldn't agree moreburbl@...  | 04/19/03
most MSFT product users aren't geeksseanyunt@...  | 05/19/03
Huh?elron@...  | 04/20/03
What does the author think?brian428  | 07/07/03
You're missing the pointhoop@...  | 04/07/03
where did you learn ...?ijib@...  | 04/07/03
no, goto does suckrkilgore@...  | 04/20/03
VS.NET vs. Eclipsemiles@...  | 04/07/03
Glass half-empty?ms5813@...  | 04/07/03
See Eclipse live in actionceperez@...  | 04/18/03
IdioticGoober Bob  | 04/07/03
Java and C# balancengrilly  | 04/07/03
Its Not Culture, Its BUSINESSrivsys  | 04/07/03
The C thru Java, C# family as OOP toolsian_ison@...  | 05/06/03
Not realitysryan@...  | 06/29/03
Totally agreechriswfl  | 04/07/03
WHY use java?kalim@...  | 04/19/03
windows tookalim@...  | 04/19/03
100% correct my friendzane.kelly@...  | 04/09/03
run for officerkilgore@...  | 04/20/03
100% nonsense from Zanejdieter@...  | 05/08/03
Re: name-callingJavaDeveloper725  | 06/30/03
It's all right here...VisualDragon  | 04/08/03
Blah Blah Blahrjlorimer@...  | 04/14/03
Did you read this then?ceperez@...  | 04/18/03
Give me C++ anytimefrule@...  | 04/16/03
Say what your *really* thinkingthorskettle@...  | 04/18/03
linuxkalim@...  | 04/19/03
101 Reasons why Java is betterceperez@...  | 04/18/03
URLkalim@...  | 04/19/03
Just Java? Different is not worserondeth@...  | 04/19/03
the real power of c sharpburbl@...  | 04/19/03
defending gotokalim@...  | 04/19/03
for karimburbl@...  | 04/19/03
you're welcome!kalim@...  | 04/19/03
ooga-boogaburbl@...  | 04/20/03
whoof whooffkalim@...  | 04/20/03
power vs. safetyrkilgore@...  | 04/20/03
power vs. safetyrkilgore@...  | 04/20/03
power vs. safety (1)burbl@...  | 04/20/03
power vs safety (2)burbl@...  | 04/20/03
power vs. safety (3)burbl@...  | 04/20/03
litterwill_senn@...  | 04/19/03
The writer is a boob with a vengeancejdbaker01@...  | 04/21/03
yeah now that was accurateianm@...  | 04/27/03
Give me a breakJohn Torjo  | 05/14/03
A tired excusebrettn  | 06/30/03
Like all of you are doing NASA software.georgescu@...  | 07/31/03
Regarding the sloppy syntaxntcse@...  | 12/04/03

What do you think?

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET
advertisement
Click Here