OT: What's wrong with Java-the-language (was: Re: D vs. C#)

Julio César Carrascal Urquijo jcarrascal at gmail.com
Sun Oct 21 08:18:18 PDT 2007


Yigal Chripun wrote:
> 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.

Auto-boxing in C# works as expected. In Java you have to take care of 
implementation details that really don't concern to your code:

C#
	Int32 a1 = 1, a2 = 1;
	Int32 b1 = 128, b2 = 128;
	Console.WriteLine(a1 == a2);	// True
	Console.WriteLine(b1 == b2);	// True

Java-the-language:
	Integer a1 = 1, a2 = 1;
	Integer b1 = 128, b2 = 128;
	System.out.println(a1 == a2);	// true
	System.out.println(b1 == b2);	// false

This is because they cache the first 127 integers as a singleton while 
you'll get different objects for 128 and up.

Also, Generics don't guarantee that a collection will only contain 
elements of the same type:

	List<Integer> lint = new ArrayList();
	List lobj = lint;
	lobj.add("hello");	// WTF?


And how come in Java you have to check your enums for null before using 
them? :D

	void foo(Color c) {
		if (null = c)
			// throw something.
		switch (c) {
			case Color.red: break;
			case Color.green: break;
			case Color.blue: break;
			default: break;
		}
	}

Java-the-vm is a great implementation and I expect with anticipation a 
lot of useful languages to evolve on top of it, but Java-the-language 
isn't really a great example of language design.


>>> 2) who needs another proprietary language?? that's the most important 
>>> issue for me. the mono project is a VERY stupid idea. it's a lost 
>>> cause and a wasted effort - trying to play catch-up to MS while it 
>>> constantly introduces breaking changes to the spec.
>>
>> C# is not proprietary.  It is an ECMA and ISO standard.  What makes mono
>> stupid?  I've done development under mono and found it to work quite 
>> well.
> 
> well, who is to prevent MS to publish a new "standard" every year? as I 

And who is to prevent SUN from publishing a new "standard" every year? 
The might have open sourced it's implementation but they still control 
the certifications that allow you to call your implementation *JAVA*.


> would you call Microsoft's document format standard? being a standard 
> means being accepted as the default by all parties, not just by one.

Do you mean Microsoft's OOXML? Yes, it was accepted by ECMA last 
December. I think that qualifies as a "standard".

http://www.ecma-international.org/publications/standards/Ecma-376.htm


>> I think for the most part, D is a better language.
> 
> i agree fully with that.
> 
>>
>> David

I'm not defending Microsoft of its monopolistic practices but C# is a 
very nice language and it has a very comprehensive library with 
independent implementations. Mono's implementations even has a more 
liberal license than Java's GPL.

I'd like you to take a closer look at Mono's C# and reconsider your 
position.

Of course I still prefer D when speed is important but the huge class 
library in Mono is certainly appealing. Maybe Tango in a couple of years 
will be there and this conversation can be dropped.

--
Julio César Carrascal Urquijo
http://www.artelogico.com/



More information about the Digitalmars-d mailing list