Main
.NET

« WSRP and Portlets. | Main | Groovy : A case for Java's Scripting Language. »

November 7, 2005

C# 2.0 / Java 5 compared.

.NET 2.0 and the complementary 2005 product series (SQL-Server, Visual Studio ) have been formally announced by Microsoft. Looks like major improvements all around -- as any major release has -- but lets take a look at some of the core changes in .NET and see how these stack up to the latest Java offerings.

[Entry continues to the left and below ad ]

In this entry I will the address the lowest common denominator for both platforms: Language syntax, since these additions -- more often than not -- make software development easier on any given platform. Given .NET's multi-language focus, I will peg all discussions against C# since its syntax is strikingly similar to that of Java, making the comparison process easier.

Generics.

Generics are new to both Java and C# users, they allow you to restrict a group of objects to a particular type. Generics work more as a safety net when dealing with object groups in both languages, but they are still new to both platforms.

Iterators.

An Iterator in C# is along the lines of the "Enhanced for loop" in Java. Its a quick and dirty way of looping through a group of objects, and getting access to each of its values without all the added syntax. You loose some flexibility getting random access to the group or making fancy iterations, but its a good fit for most scenarios with object groups. Just like Generics, this construct is also new to C# 2.0 and Java 5.0.

Partial Class Definitions.

Allows a class definition to be split over two or more source files, and all parts are later combined when the application is compiled. With a Java background, this functionality seems pretty strange -- splitting a class into various pieces -- version control should take care of this without splitting any files. This is possibly more orientated toward tool usage -- as in Visual Studio -- in which case its seems more logical, but no similar construct exists in Java.

Nullable Types.

This feature primarily alleviates dealing with null references bridging into the relational database world. The syntax is a little confusing, but it does seem to cover a gap for certain situations -- none of which I have personally encountered -- but others are familiar with. On the Java side, this particular issues seems to pop-up when working with primitives and the database tier, an extensive discussion on clean design solution for NULLs with Java primitives is as related a topic there is to C# nullable types, but there is no concrete support for nullable types in Java.

Static Classes.

Are used to create data and functions that can be accessed without creating an instance of the class. Static elements are integral to Java, so nothing Java programmers don't have access to already.

(Asymmetric) Property Accessor Accessibility

Modifying the properties in a class is typically done through getter/setter methods, in the previous C# version you could not define different accessibility levels -- public, protected, private -- on these methods, C# 2.0 incorporates this capability. In the Java world, JavaBeans which are structured around getter/setter methods have had this provision for some time.

volatile

A thread specific functionality, the volatile keyword is also something new to C# 2.0, however, its along the same lines as the Java volatile functionality which has been around from earlier Java releases.

You can find a complete list on these and other C# 2.0 and Java 5 features at :What's New in the C# 2.0 Language and Compiler and New Features and Enhancements J2SE 5.0

[Comments below ad ]

Posted by Daniel at November 7, 2005 11:40 AM


Comments


Post a comment




Remember Me?

(you may use HTML tags for style)

Track back Pings

Track Back URL for this entry:
http://www.webforefront.com/mtblog/mt-tb.cgi/31.

 
XHTML 1.1   Powered by Movable Type 3.33