Mono or no Mono, I would not consider C# unless you want to sell your soul to Microsoft. It copies Java (bad idea since Java ain't great anyway) and doesn't really do much but try to subvert it.

I have to disagree with this. C#, IMO, is a major improvement upon Java. Much of what I hated about Java is fixed in C#, and having read many of your gripes about Java in various posts, I actually think you might agree with me.

I hate Java's primative types. IMO, it's a bad attempt by Java's designers to be "pure" about things. Its a pain to upcast primatives into objects, and then the OO syntax is overly tedious. To me its a waste of resources, both CPU and programmer. C#'s approach may not be as "pure", but its alot cleaner for the end-programmer. These 2 lines are basically equivalent:

int i = 5; System.Int32 i = 5;
No tedious new Integer(5) syntax like Java. The simplistic explaination is that int is an alias to System.Int32, but thats not the whole story. The CLR (Common Language Runtime) manages all your types, so int i = 5 is managed as a primative up until it is needed to be an object (System.Int32), at which point the CLR will "box" the (much smaller) primative type into the (really only slightly larger) object type. And because C# has operator overloading (unlike Java), it really makes no difference to your code what it is anyway. It all for free and behind the scences. Sure, this is not okay if we are writing a device driver, but you wouldnt use Java to write a device driver either, so that is of no consequence.

Then there are delegates. I love my anonymous subroutines, I loved them in Javascript, and I love them in Perl (and of course, LISP, SCHEME, etc too). They are the much smarter and sexier evolution of C function pointers. C#, not to be left out in the cold, has delegates. They are basically a type-safe anonymous subroutine on crack! They are too detailed to get into here, but suffice to say, if you ever found your self writing an object in java where all you really needed was an anonymous method, you should check out delegates. (Yes, I know about the Pizza compiler, but thats not Java, thats Pizza).

Casting in Java sucks, its unsafe and a serious source of headaches. And yes, you guessed it, C# is the Extra-Strength Tylenol for your Java headaches once again. Consider the all to common, fetching from a Collection casting idiom:

MyType i = (MyType) c.get(5);
If i is not a MyType derived object, you are in trouble and get an exception. But in C#, you can do this:
MyType i = c.Get(5) as MyType;
If i is not a MyType derived object, you get null in i. Which is much easier to test for than it is to handle exceptions.

And what about foreach, another Perl favorite of mine. C# has it too:

foreach (MyType i in c) { # do something with i }
Thanks to an optimization in the C# compiler this handles all your type casting for you, and just as above, if its not a MyType derived object, its null.

These are just a few things I liked about C#, there is plenty of other cool stuff, like properties and events that really IMO go way past what Java is trying to do in its all too restrictive "pure" OO box. Give it a look, you might like it.

-stvn

In reply to Re: Re: C++, C# or Java by stvn
in thread C++, C# or Java by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.