Reply to post: Re: Fantastic

Microsoft to make Xamarin tools and code free and open source

Kristian Walsh Silver badge

Re: Fantastic

To people who say "Java is just the same as C#": that might have been true ten or fifteen years ago, but while Java stagnated the language, and concentrated on bloating the standard library, C# has improved the core language, year after year.

It's not the big-name fatures like LINQ or async, but rather the small things, like 'var', that make life so much smoother for developers, especially when so many libraries depend on generics, and so many classes have descriptive, but long-winded names. Compare these two functionally-identical snippets:

Java WhizzoContainerWrapper<ComplicatedIndexType, BlobWithUnexpectedBehaviours> c = new WhizzoContainerWrapper<ComplicatedIndexType, BlobWithUnexpectedBehaviours>();

APIThing.StatusEnumeration s = api.callMethod();

C# var c = new WhizzoContainerWrapper< ComplicatedIndexType, BlobWithUnexpectedBehaviours>();

var s = api.callMethod();

This isn't dynamic typing: c and s have the same types in both examples. The difference is that the C# compiler writers realised a long time ago that the compiler usually knows, or can infer, the type of pretty much any variable in a piece of code, so there's not much point in asking the programmer to remember it. (C++11's repurposing of the auto keyword does the same thing)

Basically, C# is full of handy stuff like this; Java isn't.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon