Friday, April 18, 2008

Five things I like in .Net that I miss in Java

1. Assemblies.
.Net assemblies (like a jar file) have proper versioning, and when you reference them as a dependency you can also include the version of a specific assembly. The result is the ability to have different versions of the same assembly running at the same time, the correct one being resolved by the CLR.

2. Leadership.
.Net has strong leadership in the form of Anders Hejlsberg. Java is getting closures but C# has them. the downside is that C# is fast approaching C++ bloatiness.

3. Container model.
It seems .Net has dumped the container model of COM+ that Java eventually emulated in EJB. WCF (EJB like managed component model) can be deployed however you like. Most importantly you can write a plain old console application and launch WCF from within it, much in the same manner in which you would launch Spring.

4. Operator overloading.
Nuff said really. It's worth mentioning though that operator overloading in C# doesn't hold much of a candle to Ruby or Scala.

5. Unchecked exceptions.
I know Java also has unchecked exceptions, the big difference is that because .Net doesn't have them, it can make a lot of code a lot cleaner.

4 comments:

paulo said...

Alot cleaner and a lot buggier.

julian_za said...

http://www.alittlemadness.com/2008/03/12/checked-exceptions-failed-experiment/

fabrizio giudici said...

1. Assemblies.

Eclipse offers OSGi modules and NetBeans has its own .nbm modules. Both can handle dependencies as you describe.



2. Leadership.

I would prefer some sort of strong leadership in Java too. But this has been strongly criticized in the past and now Java is open sourced, so this is a difficult issue.


3. Container model.
I have strong doubts that EJB have emulated COM+ :-) also recalling that EJB were specified in 1998. In any case I don't understand your point: you're saying that you like WCF deployment since it's similar to Spring... :-) But Spring is already in Java :-) and there's Guice too.

4. Operator overloading.

I disagree on this. Operator overloading tend to make people produce unreadable code. In any case, if people like them, there's Scala as you suggest.


5. Unchecked exceptions.
I strongly disagree with the article you linked. With the proper care, my code is clean and handles well checked exceptions. They not only make my applications more robust, but make it possible to use an exception not only for representing an error, but also exceptional cases that are likely to happen (this is a point that people criticizing checked exceptions don't cite: "exception" is not a synonym for "error").

julian_za said...

- neither OSGI or NBM is baked into the platform, hopefully JSR-277 will fix this

- WCF can be deployed from a specific container, IIS or from another C# application, Yes there is Spring but in .Net it is the default philosophy

- You can also make readable code, furthermore C# operating allows you to do very expressive type casting.

- Spring doesn't use checked exceptions and it does make coding a lot cleaner, this is my personal experience.