D vs. C#

Reiner Pope some at address.com
Sun Oct 21 00:55:09 PDT 2007


Yigal Chripun wrote:
> David Brown wrote:
>> On Sun, Oct 21, 2007 at 01:25:55AM +0200, Yigal Chripun wrote:
>>
>>> 1) it's a poor imitation of Java. Java may have its cons but at least 
>>> they try to be consistent with the design of the language - every new 
>>> feature goes through a JSR. this may make the language to evolve in a 
>>> slower rate though. compare that to the MS approach of including the 
>>> kitchen sink. the language has many features meant for corner cases 
>>> which makes it bloated.
>>> on the other hand other features were discarded like the covariance 
>>> of return types, which is heavily used in Java land.
>>
>> C# fixes many problems with Java, at least in my opinion.  C# 2.0 adds
>> generics which cover many of the cases of templates.  It has full support
>> of the VM, so executes efficiently and safely.
>>
> 
> What exactly is broken in Java that C# does better, in your opinion?
> from what i see, anything that needs fixing is being fixed within the 
> Java community and I personally trust their decisions a lot more than 
> MS. Adding properties to a languages isn't considered "fixing" it, it's 
> just a convenience feature. On the other hand, removing covariance of 
> return types is a very big mistake. there are others of course, but that 
> one really pissed me off.
> 

C# has lexical closures, operator overloading, structs, and nullable 
types. I don't feel as dismissive of properties as you do because, in 
conjunction with operator overloading, they lead to a much cleaner (IMO) 
code look and feel than Java. Instead of writing

     foo.setAmount(foo.getAmount().add(5));

you get the much cleaner

     foo.Amount = foo.Amount + 5;

which you are in fact allowed to rewrite to

     foo.Amount += 5;

Another nice feature is C#'s System.Reflection.Emit package, which 
allows you to compile new code at runtime -- a useful optimization which 
can be used, for instance, for regexes.

     -- Reiner



More information about the Digitalmars-d mailing list